VirtualPathProvider Performance

I'm currently trying to create a class library and embed MVC views in it so that we can share it on several sites, as described here: http://www.wynia.org/wordpress/2008/12/aspnet-mvc-plugins/

Performance is important, so I'm trying to figure out if this is the way to go. Can someone explain VirtualPathProvider for a little while, if possible?

I noticed that this method is called only once for each file.

public override VirtualFile GetFile(string virtualPath)
{
    if (ResourceFileExists(virtualPath))
         return new EmbeddedVirtualFile(virtualPath);

    return base.GetFile(virtualPath);
}

Does VirtualPathProvider create a file / view automatically? In another article (explaining the same thing) they stated that you should override GetCacheDependency:

public override CacheDependency GetCacheDependency(string virtualPath, IEnumerable virtualPathDependencies, DateTime utcStart)
{
    if (ResourceFileExists(virtualPath))
        // Return null or otherwise ASP.NET will try to monitor the file.
        // Is actually the default implementation.
        return null;

    return base.GetCacheDependency(virtualPath, virtualPathDependencies, utcStart);
}

, null "" ? , , , VirtualFile, , EmbeddedVirtualFile, Open() - method:

var assembly = Assembly.LoadFile(assemblyName);
if (assembly != null)
{
    Stream resourceStream = assembly.GetManifestResourceStream(resourceName);
    return resourceStream;
}

, . - ?

+5

All Articles