public ClientBuildManager(string appVirtualDir, string appPhysicalSourceDir, string appPhysicalTargetDir, ClientBuildManagerParameter parameter, TypeDescriptionProvider typeDescriptionProvider)
 {
     this._lock = new object();
     if (parameter == null)
     {
         parameter = new ClientBuildManagerParameter();
     }
     this.InitializeCBMTDPBridge(typeDescriptionProvider);
     if (!string.IsNullOrEmpty(appPhysicalTargetDir))
     {
         parameter.PrecompilationFlags |= PrecompilationFlags.Clean;
     }
     this._hostingParameters = new HostingEnvironmentParameters();
     this._hostingParameters.HostingFlags = HostingEnvironmentFlags.ClientBuildManager | HostingEnvironmentFlags.DontCallAppInitialize;
     this._hostingParameters.ClientBuildManagerParameter           = parameter;
     this._hostingParameters.PrecompilationTargetPhysicalDirectory = appPhysicalTargetDir;
     if (typeDescriptionProvider != null)
     {
         this._hostingParameters.HostingFlags |= HostingEnvironmentFlags.SupportsMultiTargeting;
     }
     if (appVirtualDir[0] != '/')
     {
         appVirtualDir = "/" + appVirtualDir;
     }
     if (((appPhysicalSourceDir == null) && appVirtualDir.StartsWith("/IISExpress/", StringComparison.OrdinalIgnoreCase)) && (appVirtualDir.Length > "/IISExpress/".Length))
     {
         int index = appVirtualDir.IndexOf('/', "/IISExpress/".Length);
         if (index > 0)
         {
             this._hostingParameters.IISExpressVersion = appVirtualDir.Substring("/IISExpress/".Length, index - "/IISExpress/".Length);
             appVirtualDir = appVirtualDir.Substring(index);
         }
     }
     this.Initialize(VirtualPath.CreateNonRelative(appVirtualDir), appPhysicalSourceDir);
 }
Exemplo n.º 2
0
        public static Object CreateApplicationHost(Type hostType, String virtualDir, String physicalDir)
        {
#if !FEATURE_PAL // FEATURE_PAL does not require PlatformID.Win32NT
            if (Environment.OSVersion.Platform != PlatformID.Win32NT)
            {
                throw new PlatformNotSupportedException(SR.GetString(SR.RequiresNT));
            }
#else // !FEATURE_PAL
            // FEATURE_PAL
#endif // !FEATURE_PAL

            if (!StringUtil.StringEndsWith(physicalDir, Path.DirectorySeparatorChar))
            {
                physicalDir = physicalDir + Path.DirectorySeparatorChar;
            }

            ApplicationManager appManager = ApplicationManager.GetApplicationManager();

            String appId = StringUtil.GetNonRandomizedHashCode(String.Concat(virtualDir, physicalDir)).ToString("x");


            ObjectHandle h = appManager.CreateInstanceInNewWorkerAppDomain(
                hostType, appId, VirtualPath.CreateNonRelative(virtualDir), physicalDir);

            return(h.Unwrap());
        }
Exemplo n.º 3
0
        public virtual IHttpHandler GetHandler(HttpContext context, string requestType,
                                               string virtualPath, string path)
        {
            // This should never get called
            //Debug.Assert(false);

            return(((IHttpHandlerFactory2)this).GetHandler(context, requestType,
                                                           VirtualPath.CreateNonRelative(virtualPath), path));
        }
        public virtual IHttpHandler GetHandler(HttpContext context, string requestType, string virtualPath, string path)
        {
            Debug.Trace("PageHandlerFactory", "PageHandlerFactory: " + virtualPath);

            // This should never get called in ISAPI mode but currently is in integrated mode
            // Debug.Assert(false);

            return(GetHandlerHelper(context, requestType, VirtualPath.CreateNonRelative(virtualPath), path));
        }
        internal void FillInRegisterEntries()
        {
            //



            TagNamespaceRegisterEntryTable tagNamespaceRegisterEntries = new TagNamespaceRegisterEntryTable();

            foreach (TagNamespaceRegisterEntry entry in DefaultTagNamespaceRegisterEntries)
            {
                tagNamespaceRegisterEntries[entry.TagPrefix] = new ArrayList(new object[] { entry });
            }

            Hashtable userControlRegisterEntries = new Hashtable(StringComparer.OrdinalIgnoreCase);

            // Fill in the collection
            foreach (TagPrefixInfo tpi in Controls)
            {
                if (!String.IsNullOrEmpty(tpi.TagName))
                {
                    UserControlRegisterEntry ucRegisterEntry = new UserControlRegisterEntry(tpi.TagPrefix, tpi.TagName);
                    ucRegisterEntry.ComesFromConfig = true;
                    try {
                        ucRegisterEntry.UserControlSource = VirtualPath.CreateNonRelative(tpi.Source);
                    }
                    catch (Exception e) {
                        throw new ConfigurationErrorsException(e.Message, e,
                                                               tpi.ElementInformation.Properties["src"].Source,
                                                               tpi.ElementInformation.Properties["src"].LineNumber);
                    }

                    userControlRegisterEntries[ucRegisterEntry.Key] = ucRegisterEntry;
                }
                else if (!String.IsNullOrEmpty(tpi.Namespace))
                {
                    TagNamespaceRegisterEntry nsRegisterEntry = new TagNamespaceRegisterEntry(tpi.TagPrefix, tpi.Namespace, tpi.Assembly);
                    ArrayList entries = null;

                    entries = (ArrayList)tagNamespaceRegisterEntries[tpi.TagPrefix];
                    if (entries == null)
                    {
                        entries = new ArrayList();
                        tagNamespaceRegisterEntries[tpi.TagPrefix] = entries;
                    }

                    entries.Add(nsRegisterEntry);
                }
            }

            _tagNamespaceRegisterEntries = tagNamespaceRegisterEntries;
            _userControlRegisterEntries  = userControlRegisterEntries;
        }
        /*
         * Creates an instance of the PrecompilationManager.
         * appPhysicalSourceDir points to the physical root of the application (e.g "c:\myapp")
         * appVirtualDir is the virtual path to the app root. It can be anything (e.g. "/dummy"),
         *      but ideally it should match the path later given to Cassini, in order for
         *      compilation that happens here to be reused there.
         * appPhysicalTargetDir is the directory where the precompiled site is placed
         * typeDescriptionProvider is the provider used for retrieving type
         * information for multi-targeting
         */
        public ClientBuildManager(string appVirtualDir, string appPhysicalSourceDir,
                                  string appPhysicalTargetDir, ClientBuildManagerParameter parameter,
                                  TypeDescriptionProvider typeDescriptionProvider)
        {
            if (parameter == null)
            {
                parameter = new ClientBuildManagerParameter();
            }

            InitializeCBMTDPBridge(typeDescriptionProvider);

            // Always build clean in precompilation for deployment mode,
            // since building incrementally raises all kind of issues (VSWhidbey 382954).
            if (!String.IsNullOrEmpty(appPhysicalTargetDir))
            {
                parameter.PrecompilationFlags |= PrecompilationFlags.Clean;
            }

            _hostingParameters = new HostingEnvironmentParameters();
            _hostingParameters.HostingFlags = HostingEnvironmentFlags.DontCallAppInitialize |
                                              HostingEnvironmentFlags.ClientBuildManager;
            _hostingParameters.ClientBuildManagerParameter           = parameter;
            _hostingParameters.PrecompilationTargetPhysicalDirectory = appPhysicalTargetDir;
            if (typeDescriptionProvider != null)
            {
                _hostingParameters.HostingFlags |= HostingEnvironmentFlags.SupportsMultiTargeting;
            }

            // Make sure the app virtual dir starts with /
            if (appVirtualDir[0] != '/')
            {
                appVirtualDir = "/" + appVirtualDir;
            }

            if (appPhysicalSourceDir == null &&
                appVirtualDir.StartsWith(IISExpressPrefix, StringComparison.OrdinalIgnoreCase) &&
                appVirtualDir.Length > IISExpressPrefix.Length)
            {
                // appVirtualDir should have the form "/IISExpress/<version>/LM/W3SVC/",
                // and we will try to extract the version.  The version will be validated
                // when it is passed to IISVersionHelper..ctor.
                int endSlash = appVirtualDir.IndexOf('/', IISExpressPrefix.Length);
                if (endSlash > 0)
                {
                    _hostingParameters.IISExpressVersion = appVirtualDir.Substring(IISExpressPrefix.Length, endSlash - IISExpressPrefix.Length);
                    appVirtualDir = appVirtualDir.Substring(endSlash);
                }
            }

            Initialize(VirtualPath.CreateNonRelative(appVirtualDir), appPhysicalSourceDir);
        }
Exemplo n.º 7
0
        internal void FillInRegisterEntries()
        {
            TagNamespaceRegisterEntryTable table = new TagNamespaceRegisterEntryTable();

            foreach (TagNamespaceRegisterEntry entry in DefaultTagNamespaceRegisterEntries)
            {
                table[entry.TagPrefix] = new ArrayList(new object[] { entry });
            }
            Hashtable hashtable = new Hashtable(StringComparer.OrdinalIgnoreCase);

            foreach (TagPrefixInfo info in this.Controls)
            {
                if (!string.IsNullOrEmpty(info.TagName))
                {
                    UserControlRegisterEntry entry2 = new UserControlRegisterEntry(info.TagPrefix, info.TagName)
                    {
                        ComesFromConfig = true
                    };
                    try
                    {
                        entry2.UserControlSource = VirtualPath.CreateNonRelative(info.Source);
                    }
                    catch (Exception exception)
                    {
                        throw new ConfigurationErrorsException(exception.Message, exception, info.ElementInformation.Properties["src"].Source, info.ElementInformation.Properties["src"].LineNumber);
                    }
                    hashtable[entry2.Key] = entry2;
                }
                else if (!string.IsNullOrEmpty(info.Namespace))
                {
                    TagNamespaceRegisterEntry entry3 = new TagNamespaceRegisterEntry(info.TagPrefix, info.Namespace, info.Assembly);
                    ArrayList list = null;
                    list = (ArrayList)table[info.TagPrefix];
                    if (list == null)
                    {
                        list = new ArrayList();
                        table[info.TagPrefix] = list;
                    }
                    list.Add(entry3);
                }
            }
            this._tagNamespaceRegisterEntries = table;
            this._userControlRegisterEntries  = hashtable;
        }
 public virtual IHttpHandler GetHandler(HttpContext context, string requestType, string virtualPath, string path)
 {
     return(((IHttpHandlerFactory2)this).GetHandler(context, requestType, VirtualPath.CreateNonRelative(virtualPath), path));
 }
        public static object CreateApplicationHost(Type hostType, string virtualDir, string physicalDir)
        {
            if (Environment.OSVersion.Platform != PlatformID.Win32NT)
            {
                throw new PlatformNotSupportedException(System.Web.SR.GetString("RequiresNT"));
            }
            if (!StringUtil.StringEndsWith(physicalDir, Path.DirectorySeparatorChar))
            {
                physicalDir = physicalDir + Path.DirectorySeparatorChar;
            }
            ApplicationManager applicationManager = ApplicationManager.GetApplicationManager();
            string             appId = (virtualDir + physicalDir).GetHashCode().ToString("x");

            return(applicationManager.CreateInstanceInNewWorkerAppDomain(hostType, appId, VirtualPath.CreateNonRelative(virtualDir), physicalDir).Unwrap());
        }