PBMining

Searching...
Monday, July 30, 2012

Exploring MVC framework in deep - BuildManagerWrapper Class

10:15 AM

From this post i am going to start deep explanation of mvc framework it can be useful for good consideration in your web project and learning about working mechanism of MVC framework.in this post i am going to explain about BuildManagerWrapper class of MVC framework.for good understanding its better if you download source of MVC framework from Codeplex.here is link ASP.NET MVC 3 RTM. BuildManagerWrapper is built in internal class of MVC framework.

This class contain some helper method that uses System.web.compilation.BuildManager class for compiling a code file at runtime and return its type,getting all referenced assemblies,reading and creating cache files,and get the object factory from specified virtual path. let's see its definition.

    namespace System.Web.Mvc {
        using System.Collections;
        using System.IO;
        using System.Web.Compilation;

        internal sealed class BuildManagerWrapper : IBuildManager
        {
            bool IBuildManager.FileExists(string virtualPath) {
                return BuildManager.GetObjectFactory(virtualPath, false) != null;
            }

            Type IBuildManager.GetCompiledType(string virtualPath) {
                return BuildManager.GetCompiledType(virtualPath);
            }

            ICollection IBuildManager.GetReferencedAssemblies() {
                return BuildManager.GetReferencedAssemblies();
            }

            Stream IBuildManager.ReadCachedFile(string fileName) {
                return BuildManager.ReadCachedFile(fileName);
            }

            Stream IBuildManager.CreateCachedFile(string fileName) {
                return BuildManager.CreateCachedFile(fileName);
            }


        }
    }

you can see here it implement IBuildManager interface and use BuildManager class.BuildManager class contain lots of other methods that is not used here.This is the class that is used by TypeCacheUtil class for reading controller Type's cache file, searching Controller classes in referenced assemblies if cache doesn't exists and storing it back to the disk cache. There are some other operations performed by TypeCacheUtil class for retrieving controller types.

0 comments:

Post a Comment

Write your review about this post.