Click here to Skip to main content
15,881,600 members
Articles / Web Development / HTML

Signum Framework Tutorials Part 3 - Southwind Load

Rate me:
Please Sign up or sign in to vote.
4.62/5 (7 votes)
21 Nov 2012CPOL23 min read 24.3K   319   10  
In this part we'll write the loading application to move data from Northwind to Southwind.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.IO;
using System.Web.Hosting;

namespace Signum.Web.PortableAreas
{
    public class CompiledVirtualPathProvider : VirtualPathProvider
    {
        private readonly VirtualPathProvider virtualPathProvider;

        public CompiledVirtualPathProvider(VirtualPathProvider defaultPathProvider)
        {
            this.virtualPathProvider = defaultPathProvider;
        }

        public override bool FileExists(string virtualPath)
        {
            return
                GetCompiledType(virtualPath) != null
                 || virtualPathProvider.FileExists(virtualPath);
        }

        private Type GetCompiledType(string virtualPath)
        {
            return CompiledViews.GetCompiledType(virtualPath);
        }

     
        public override VirtualFile GetFile(string virtualPath)
        {
            if (virtualPathProvider.FileExists(virtualPath))
            {
                return virtualPathProvider.GetFile(virtualPath);
            }
            var compiledType = GetCompiledType(virtualPath);
            if (compiledType != null)
            {
                return new CompiledVirtualFile(virtualPath, compiledType);
            }
            return null;
        }

        public override System.Web.Caching.CacheDependency GetCacheDependency(string virtualPath, System.Collections.IEnumerable virtualPathDependencies, DateTime utcStart)
        {
            return GetCompiledType(virtualPath) != null ? null : base.GetCacheDependency(virtualPath, virtualPathDependencies, utcStart);
        }

    }

    public class CompiledVirtualFile : VirtualFile
    {
        public CompiledVirtualFile(string virtualPath, Type compiledType)
            : base(virtualPath)
        {
            CompiledType = compiledType;
        }

        public Type CompiledType { get; set; }
        public CompiledVirtualFile Type { get; set; }

        public override Stream Open()
        {
            return Stream.Null;
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Signum Software
Spain Spain
I'm Computer Scientist, one of the founders of Signum Software, and the lead developer behind Signum Framework.

www.signumframework.com

I love programming in C#, Linq, Compilers, Algorithms, Functional Programming, Computer Graphics, Maths...

Comments and Discussions