コード例 #1
0
ファイル: ConfigUtility.cs プロジェクト: kmeze/Rhetos
 private static System.Configuration.Configuration InitializeWebConfiguration()
 {
     VirtualDirectoryMapping vdm = new VirtualDirectoryMapping(Paths.RhetosServerRootPath, true);
     WebConfigurationFileMap wcfm = new WebConfigurationFileMap();
     wcfm.VirtualDirectories.Add("/", vdm);
     return WebConfigurationManager.OpenMappedWebConfiguration(wcfm, "/");
 }
コード例 #2
0
        public static void RefreshAllBundles(IBundleContext context)
        {
            // parse each folders to register new bundles
            foreach (var folderPath in Directory.GetDirectories(Path.GetFullPath(string.Format("Bundles"))))
            {
                var bundleName = new DirectoryInfo(folderPath).Name;
                var bundleInfo = context.GetBundle(bundleName);
                if (bundleInfo == null)
                {
                    string path = Path.GetFullPath(string.Format("Bundles\\{0}\\{0}.dll", bundleName));

                    // the assembly doesn't exist, try the bundle.config? Web.config?
                    if (!File.Exists(path))
                    {
                        System.Configuration.Configuration configuration = null;

                        if (File.Exists(Path.GetFullPath(string.Format("Bundles\\{0}\\{0}.dll.config", bundleName))))
                        {
                            configuration = ConfigurationManager.OpenExeConfiguration(path);
                        }
                        else if (File.Exists(Path.GetFullPath(string.Format("Bundles\\{0}\\web.config", bundleName))))
                        {
                            VirtualDirectoryMapping vdm =
                                new VirtualDirectoryMapping(
                                    Path.GetFullPath(string.Format("Bundles\\{0}", bundleName)), true);
                            WebConfigurationFileMap wcfm = new WebConfigurationFileMap();
                            wcfm.VirtualDirectories.Add("/", vdm);

                            // Get the Web application configuration object.
                            configuration = WebConfigurationManager.OpenMappedWebConfiguration(wcfm, "/");
                        }
                        else
                        {
                            throw new BundleNotFoundException(bundleName, new Version());
                        }

                        // TODO : better error handling
                        var section = (BundleConfigurationSection) configuration.GetSection("bundleConfiguration");

                        path = Path.GetFullPath(string.Format("Bundles\\{0}\\{1}", bundleName, section.BundlePath));
                        if (!File.Exists(path))
                            throw new BundleNotFoundException(bundleName, new Version());
                    }

                    // create the bundle with all information needed
                    var assembly = Assembly.ReflectionOnlyLoadFrom(path);
                    var version = assembly.GetName().Version;
                    bundleInfo = new BundleInfo
                    {
                        Path = path,
                        Name = bundleName,
                        Version = assembly.GetName().Version,
                        State = BundleState.Installed
                    };

                    // and then, register it
                    context.RegisterBundle(bundleInfo);
                }
            }
        }
コード例 #3
0
 /// <summary>
 /// Open the web.config file
 /// </summary>
 /// <param name="configPath"></param>
 /// <returns></returns>
 public static Configuration OpenWebConfiguration(string configPath)
 {
     VirtualDirectoryMapping vdm = new VirtualDirectoryMapping(Path.GetDirectoryName(configPath), true);
     WebConfigurationFileMap wcfm = new WebConfigurationFileMap();
     wcfm.VirtualDirectories.Add("/", vdm);
     return WebConfigurationManager.OpenMappedWebConfiguration(wcfm, "/");
 }
 IConfigMapPath IConfigMapPathFactory.Create(string virtualPath, string physicalPath)
 {
     WebConfigurationFileMap fileMap = new WebConfigurationFileMap();
     VirtualPath path = VirtualPath.Create(virtualPath);
     fileMap.VirtualDirectories.Add(path.VirtualPathStringNoTrailingSlash, new VirtualDirectoryMapping(physicalPath, true));
     fileMap.VirtualDirectories.Add(HttpRuntime.AspClientScriptVirtualPath, new VirtualDirectoryMapping(HttpRuntime.AspClientScriptPhysicalPathInternal, false));
     return new UserMapPath(fileMap);
 }
コード例 #5
0
 static StateRuntime()
 {
     WebConfigurationFileMap fileMap = new WebConfigurationFileMap();
     UserMapPath configMapPath = new UserMapPath(fileMap);
     HttpConfigurationSystem.EnsureInit(configMapPath, false, true);
     StateApplication customApplication = new StateApplication();
     HttpApplicationFactory.SetCustomApplication(customApplication);
     PerfCounters.OpenStateCounters();
     ResetStateServerCounters();
 }
コード例 #6
0
 public virtual void SetUp()
 {
     var rootPathProvider = new InvoiceGenRootPathProvider();
       var webConfigFile = new FileInfo(Path.Combine(rootPathProvider.GetRootPath(), "web.config"));
       var virtualDirectoryMapping = new VirtualDirectoryMapping(webConfigFile.DirectoryName, true, webConfigFile.Name);
       var webConfigurationFileMap = new WebConfigurationFileMap();
       webConfigurationFileMap.VirtualDirectories.Add("/", virtualDirectoryMapping);
       var configuration = WebConfigurationManager.OpenMappedWebConfiguration(webConfigurationFileMap, "/");
       _sut = CompositionRoot.Compose(configuration);
 }
コード例 #7
0
        public override void Initialize(RazorHost razorHost, IDictionary<string, string> directives)
        {
            string projectPath = GetProjectRoot(razorHost.ProjectRelativePath, razorHost.FullPath).TrimEnd(Path.DirectorySeparatorChar);
            string currentPath = razorHost.FullPath;
            string directoryVirtualPath = null;

            var configFileMap = new WebConfigurationFileMap();

            var virtualDirectories = configFileMap.VirtualDirectories;
            while (!currentPath.Equals(projectPath, StringComparison.OrdinalIgnoreCase))
            {
                currentPath = Path.GetDirectoryName(currentPath);
                string relativePath = currentPath.Substring(projectPath.Length);
                bool isAppRoot = currentPath.Equals(projectPath, StringComparison.OrdinalIgnoreCase);
                string virtualPath = relativePath.Replace('\\', '/');
                if (virtualPath.Length == 0)
                {
                    virtualPath = "/";
                }

                directoryVirtualPath = directoryVirtualPath ?? virtualPath;

                virtualDirectories.Add(virtualPath, new VirtualDirectoryMapping(currentPath, isAppRoot: isAppRoot));
            }

            try
            {
                var config = WebConfigurationManager.OpenMappedWebConfiguration(configFileMap, directoryVirtualPath);
                RazorPagesSection section = config.GetSection(RazorPagesSection.SectionName) as RazorPagesSection;
                if (section != null)
                {
                    string baseType = section.PageBaseType;
                    if (!DefaultBaseType.Equals(baseType, StringComparison.OrdinalIgnoreCase))
                    {
                        _transformers.Add(new SetBaseType(baseType));
                    }

                    if (section != null)
                    {
                        foreach (NamespaceInfo n in section.Namespaces)
                        {
                            razorHost.NamespaceImports.Add(n.Namespace);
                        }
                    }
                }
            }
            catch (IndexOutOfRangeException)
            {
                // Bug in Mono framework.
                // Configure namespaces using the RazorGenerator directives file instead.
            }
            base.Initialize(razorHost, directives);
        }
コード例 #8
0
		public void OverrideAppSettingsWithEnvironmentVars ()
		{
			throw new NotImplementedException ("Not implemented as WebConfigurationManager seems buggy in Mono 3.2.4");

			string directory = Path.GetDirectoryName(Path.GetFullPath(configFile));
			WebConfigurationFileMap wcfm = new WebConfigurationFileMap();
			VirtualDirectoryMapping vdm = new VirtualDirectoryMapping(directory, true, "Web.config");
			wcfm.VirtualDirectories.Add("/", vdm);

			//WebConfigurationManager seems bugging in Mono 3.2.4
			Configuration webConfig = WebConfigurationManager.OpenMappedWebConfiguration(wcfm, "/");

		}
コード例 #9
0
		public override object Clone ()
		{
			WebConfigurationFileMap map = new WebConfigurationFileMap ();
			map.MachineConfigFilename = MachineConfigFilename;
			
			map.virtualDirectories = new VirtualDirectoryMappingCollection ();
			foreach (VirtualDirectoryMapping vmap in virtualDirectories) {
				VirtualDirectoryMapping nvmap = new VirtualDirectoryMapping (vmap.PhysicalDirectory, vmap.IsAppRoot, vmap.ConfigFileBaseName);
				map.virtualDirectories.Add (vmap.VirtualDirectory, nvmap);
			}
			
			return map;
		}
コード例 #10
0
 internal UserMapPath(ConfigurationFileMap fileMap, bool pathsAreLocal)
 {
     this._pathsAreLocal = pathsAreLocal;
     if (!string.IsNullOrEmpty(fileMap.MachineConfigFilename))
     {
         if (this._pathsAreLocal)
         {
             this._machineConfigFilename = Path.GetFullPath(fileMap.MachineConfigFilename);
         }
         else
         {
             this._machineConfigFilename = fileMap.MachineConfigFilename;
         }
     }
     if (string.IsNullOrEmpty(this._machineConfigFilename))
     {
         this._machineConfigFilename = HttpConfigurationSystem.MachineConfigurationFilePath;
         this._rootWebConfigFilename = HttpConfigurationSystem.RootWebConfigurationFilePath;
     }
     else
     {
         this._rootWebConfigFilename = Path.Combine(Path.GetDirectoryName(this._machineConfigFilename), "web.config");
     }
     this._webFileMap = fileMap as WebConfigurationFileMap;
     if (this._webFileMap != null)
     {
         if (!string.IsNullOrEmpty(this._webFileMap.Site))
         {
             this._siteName = this._webFileMap.Site;
             this._siteID   = this._webFileMap.Site;
         }
         else
         {
             this._siteName = WebConfigurationHost.DefaultSiteName;
             this._siteID   = "1";
         }
         if (this._pathsAreLocal)
         {
             foreach (string str in this._webFileMap.VirtualDirectories)
             {
                 this._webFileMap.VirtualDirectories[str].Validate();
             }
         }
         VirtualDirectoryMapping mapping2 = this._webFileMap.VirtualDirectories[null];
         if (mapping2 != null)
         {
             this._rootWebConfigFilename = Path.Combine(mapping2.PhysicalDirectory, mapping2.ConfigFileBaseName);
             this._webFileMap.VirtualDirectories.Remove(null);
         }
     }
 }
コード例 #11
0
        internal UserMapPath(ConfigurationFileMap fileMap, bool pathsAreLocal) {
            _pathsAreLocal = pathsAreLocal;


            if (!String.IsNullOrEmpty(fileMap.MachineConfigFilename)) {
                if (_pathsAreLocal) {
                    _machineConfigFilename = Path.GetFullPath(fileMap.MachineConfigFilename);
                }
                else {
                    _machineConfigFilename = fileMap.MachineConfigFilename;
                }
            }

            if (string.IsNullOrEmpty(_machineConfigFilename)) {
                // Defaults for machine.config and root web.config if not supplied by user
                _machineConfigFilename = HttpConfigurationSystem.MachineConfigurationFilePath;
                _rootWebConfigFilename = HttpConfigurationSystem.RootWebConfigurationFilePath;
            } else {
                _rootWebConfigFilename = Path.Combine(Path.GetDirectoryName(_machineConfigFilename), "web.config");
            }

            _webFileMap = fileMap as WebConfigurationFileMap;
            if (_webFileMap != null) {

                // Use the site if supplied, otherwise use the default.
                if (!String.IsNullOrEmpty(_webFileMap.Site)) {
                    _siteName = _webFileMap.Site;
                    _siteID = _webFileMap.Site;
                }
                else {
                    _siteName = WebConfigurationHost.DefaultSiteName;
                    _siteID = WebConfigurationHost.DefaultSiteID;
                }

                if (_pathsAreLocal) {
                    // validate mappings
                    foreach (string virtualDirectory in _webFileMap.VirtualDirectories) {
                        VirtualDirectoryMapping mapping = _webFileMap.VirtualDirectories[virtualDirectory];
                        mapping.Validate();
                    }
                }

                // Get the root web.config path
                VirtualDirectoryMapping rootWebMapping = _webFileMap.VirtualDirectories[null];
                if (rootWebMapping != null) {
                    _rootWebConfigFilename = Path.Combine(rootWebMapping.PhysicalDirectory, rootWebMapping.ConfigFileBaseName);
                    _webFileMap.VirtualDirectories.Remove(null);
                }

            }
        }
コード例 #12
0
 internal UserMapPath(ConfigurationFileMap fileMap, bool pathsAreLocal)
 {
     this._pathsAreLocal = pathsAreLocal;
     if (!string.IsNullOrEmpty(fileMap.MachineConfigFilename))
     {
         if (this._pathsAreLocal)
         {
             this._machineConfigFilename = Path.GetFullPath(fileMap.MachineConfigFilename);
         }
         else
         {
             this._machineConfigFilename = fileMap.MachineConfigFilename;
         }
     }
     if (string.IsNullOrEmpty(this._machineConfigFilename))
     {
         this._machineConfigFilename = HttpConfigurationSystem.MachineConfigurationFilePath;
         this._rootWebConfigFilename = HttpConfigurationSystem.RootWebConfigurationFilePath;
     }
     else
     {
         this._rootWebConfigFilename = Path.Combine(Path.GetDirectoryName(this._machineConfigFilename), "web.config");
     }
     this._webFileMap = fileMap as WebConfigurationFileMap;
     if (this._webFileMap != null)
     {
         if (!string.IsNullOrEmpty(this._webFileMap.Site))
         {
             this._siteName = this._webFileMap.Site;
             this._siteID = this._webFileMap.Site;
         }
         else
         {
             this._siteName = WebConfigurationHost.DefaultSiteName;
             this._siteID = "1";
         }
         if (this._pathsAreLocal)
         {
             foreach (string str in this._webFileMap.VirtualDirectories)
             {
                 this._webFileMap.VirtualDirectories[str].Validate();
             }
         }
         VirtualDirectoryMapping mapping2 = this._webFileMap.VirtualDirectories[null];
         if (mapping2 != null)
         {
             this._rootWebConfigFilename = Path.Combine(mapping2.PhysicalDirectory, mapping2.ConfigFileBaseName);
             this._webFileMap.VirtualDirectories.Remove(null);
         }
     }
 }
コード例 #13
0
        public override object Clone()
        {
            WebConfigurationFileMap map = new WebConfigurationFileMap();

            map.MachineConfigFilename = MachineConfigFilename;

            map.virtualDirectories = new VirtualDirectoryMappingCollection();
            foreach (VirtualDirectoryMapping vmap in virtualDirectories)
            {
                VirtualDirectoryMapping nvmap = new VirtualDirectoryMapping(vmap.PhysicalDirectory, vmap.IsAppRoot, vmap.ConfigFileBaseName);
                map.virtualDirectories.Add(vmap.VirtualDirectory, nvmap);
            }

            return(map);
        }
コード例 #14
0
        static void Main(string[] args)
        {
            if (string.IsNullOrEmpty(ConfigurationManager.AppSettings["WindowsLoginCredentials"]))
            {
                VirtualDirectoryMapping vdm = new VirtualDirectoryMapping(@"C:\LDS\Phoenix\PhoenixWeb", true);
                WebConfigurationFileMap wcfm = new WebConfigurationFileMap();
                wcfm.VirtualDirectories.Add("/", vdm);

                // Get the Web application configuration object.
                Configuration config = WebConfigurationManager.OpenMappedWebConfiguration(wcfm, "/");

                string s = config.AppSettings.Settings["WindowsLoginCredentials"].Value;
            }

            Console.Read();
        }
コード例 #15
0
ファイル: ModelLoader.cs プロジェクト: aries544/eXpand
        private string[] GetModulesFromConfig(XafApplication application) {
            Configuration config;
            if (application is IWinApplication) {
                config = ConfigurationManager.OpenExeConfiguration(AppDomain.CurrentDomain.SetupInformation.ApplicationBase + _moduleName);
            } else {
                var mapping = new WebConfigurationFileMap();
                mapping.VirtualDirectories.Add("/Dummy", new VirtualDirectoryMapping(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, true));
                config = WebConfigurationManager.OpenMappedWebConfiguration(mapping, "/Dummy");
            }

            if (config.AppSettings.Settings["Modules"] != null) {
                return config.AppSettings.Settings["Modules"].Value.Split(';');
            }

            return null;
        }
コード例 #16
0
        internal static System.Configuration.Configuration OpenConfiguration(WebLevel webLevel, ConfigurationFileMap fileMap, VirtualPath path, string site, string locationSubPath, string server, string userName, string password, IntPtr tokenHandle)
        {
            if (!IsValidSiteArgument(site))
            {
                throw System.Web.Util.ExceptionUtil.ParameterInvalid("site");
            }
            locationSubPath = ConfigurationFactory.NormalizeLocationSubPath(locationSubPath, null);
            if ((((!string.IsNullOrEmpty(server) && (server != ".")) && (!System.Web.Util.StringUtil.EqualsIgnoreCase(server, "127.0.0.1") && !System.Web.Util.StringUtil.EqualsIgnoreCase(server, "::1"))) && !System.Web.Util.StringUtil.EqualsIgnoreCase(server, "localhost")) && !System.Web.Util.StringUtil.EqualsIgnoreCase(server, Environment.MachineName))
            {
                object[] hostInitConfigurationParams = new object[9];
                hostInitConfigurationParams[0] = webLevel;
                hostInitConfigurationParams[2] = VirtualPath.GetVirtualPathString(path);
                hostInitConfigurationParams[3] = site;
                hostInitConfigurationParams[4] = locationSubPath;
                hostInitConfigurationParams[5] = server;
                hostInitConfigurationParams[6] = userName;
                hostInitConfigurationParams[7] = password;
                hostInitConfigurationParams[8] = tokenHandle;
                return(ConfigurationFactory.Create(typeof(RemoteWebConfigurationHost), hostInitConfigurationParams));
            }
            if (string.IsNullOrEmpty(server))
            {
                if (!string.IsNullOrEmpty(userName))
                {
                    throw System.Web.Util.ExceptionUtil.ParameterInvalid("userName");
                }
                if (!string.IsNullOrEmpty(password))
                {
                    throw System.Web.Util.ExceptionUtil.ParameterInvalid("password");
                }
                if (tokenHandle != IntPtr.Zero)
                {
                    throw System.Web.Util.ExceptionUtil.ParameterInvalid("tokenHandle");
                }
            }
            if (fileMap != null)
            {
                fileMap = (ConfigurationFileMap)fileMap.Clone();
            }
            WebConfigurationFileMap map = fileMap as WebConfigurationFileMap;

            if ((map != null) && !string.IsNullOrEmpty(site))
            {
                map.Site = site;
            }
            return(ConfigurationFactory.Create(typeof(WebConfigurationHost), new object[] { webLevel, fileMap, VirtualPath.GetVirtualPathString(path), site, locationSubPath }));
        }
コード例 #17
0
ファイル: Setting.cs プロジェクト: rocker8942/Utility
        /// <summary>
        /// Get web configuration
        /// </summary>
        /// <param name="physicalPath"></param>
        /// <returns>configuration object</returns>
        public static Configuration GetConfig(string physicalPath)
        {
            Configuration configuration;
            if (string.IsNullOrWhiteSpace(physicalPath))
                configuration = WebConfigurationManager.OpenWebConfiguration("~");
            else
            {
                var configFile = new FileInfo(physicalPath);
                var vdm = new VirtualDirectoryMapping(configFile.DirectoryName, true, configFile.Name);
                var wcfm = new WebConfigurationFileMap();
                wcfm.VirtualDirectories.Add("/", vdm);
                var websiteName = HostingEnvironment.SiteName;
                configuration = WebConfigurationManager.OpenMappedWebConfiguration(wcfm, "/", websiteName);
            }

            return configuration;
        }
コード例 #18
0
		public void ShouldAddModifiedAt ()
		{
			CreateSampleConfigFile ();

			new WebConfigUpdater("Web.config")
				.OverrideAppSettingsWithEnvironmentVars ();

			string directory = Path.GetDirectoryName(Path.GetFullPath("Web.config"));
			WebConfigurationFileMap wcfm = new WebConfigurationFileMap();
			VirtualDirectoryMapping vdm = new VirtualDirectoryMapping(directory, true, "Web.config");
			wcfm.VirtualDirectories.Add("/", vdm);

			//WebConfigurationManager seems bugging in Mono 3.2.4
			Configuration webConfig = WebConfigurationManager.OpenMappedWebConfiguration(wcfm, "/");

			CollectionAssert.Contains (webConfig.AppSettings.Settings.AllKeys, "AppSettingsAutoReconfiguration_ModifiedAt");
			Console.WriteLine (webConfig.AppSettings.Settings ["AppSettingsAutoReconfiguration_ModifiedAt"].Value);
		}
コード例 #19
0
ファイル: WCFBuildProvider.cs プロジェクト: dox0/DotNet471RS3
        /// <summary>
        /// Get the appropriate tool configuration for this service reference.
        ///
        /// If a reference.config file is present, the configuration object returned
        /// will be the merged view of:
        ///
        ///    Machine Config
        ///       ReferenceConfig
        ///
        /// If not reference.config file is present, the configuration object returned
        /// will be a merged view of:
        ///
        ///     Machine.config
        ///         web.config in application's physical path...
        ///
        /// </summary>
        /// <param name="mapFile">SvcMapFile representing the service</param>
        /// <returns></returns>
        private System.Configuration.Configuration GetToolConfig(SvcMapFile mapFile, string mapFilePath)
        {
            string toolConfigFile = null;

            if (mapFile != null && mapFilePath != null)
            {
                foreach (ExtensionFile extensionFile in mapFile.Extensions)
                {
                    if (String.Equals(extensionFile.Name, TOOL_CONFIG_ITEM_NAME, StringComparison.Ordinal))
                    {
                        toolConfigFile = extensionFile.FileName;
                    }
                }
            }

            System.Web.Configuration.WebConfigurationFileMap fileMap;
            fileMap = new System.Web.Configuration.WebConfigurationFileMap();

            System.Web.Configuration.VirtualDirectoryMapping mapping;
            if (toolConfigFile != null)
            {
                //
                // If we've got a specific tool configuration to use, we better load that...
                //
                mapping = new System.Web.Configuration.VirtualDirectoryMapping(System.IO.Path.GetDirectoryName(mapFilePath), true, toolConfigFile);
            }
            else
            {
                //
                // Otherwise we fall back to the default web.config file...
                //
                mapping = new System.Web.Configuration.VirtualDirectoryMapping(HostingEnvironment.ApplicationPhysicalPath, true);
            }
            fileMap.VirtualDirectories.Add("/", mapping);

            return(System.Web.Configuration.WebConfigurationManager.OpenMappedWebConfiguration(fileMap, "/", System.Web.Hosting.HostingEnvironment.SiteName));
        }
コード例 #20
0
        private Configuration OpenWebConfiguration(string path, string appPhysPath, bool getWebConfigForSubDir)
        {
            // check if session expired
            if (String.IsNullOrEmpty(ApplicationPath) || String.IsNullOrEmpty((string)Session[APP_PHYSICAL_PATH])) {
                Server.Transfer("~/home2.aspx");
            }

            if (String.IsNullOrEmpty(path)) {
                return WebConfigurationManager.OpenWebConfiguration(null);
            }

            string appVPath = (string)Session[APP_PATH];
            if (!getWebConfigForSubDir) {
                appVPath = path;
            }

            WebConfigurationFileMap fileMap = new WebConfigurationFileMap();
            fileMap.VirtualDirectories.Add(appVPath, new VirtualDirectoryMapping(appPhysPath, true));
            return WebConfigurationManager.OpenMappedWebConfiguration(fileMap, path);
        }
コード例 #21
0
        // Create an instance of a Configuration object.
        // Used by design-time API to open a Configuration object.
        static internal Configuration OpenConfiguration(
            WebLevel webLevel, ConfigurationFileMap fileMap, VirtualPath path, string site, string locationSubPath,
            string server, string userName, string password, IntPtr tokenHandle)
        {
            Configuration configuration;

            if (!IsValidSiteArgument(site))
            {
                throw ExceptionUtil.ParameterInvalid("site");
            }

            locationSubPath = ConfigurationFactory.NormalizeLocationSubPath(locationSubPath, null);

            bool isRemote = !String.IsNullOrEmpty(server) &&
                            server != "." &&
                            !StringUtil.EqualsIgnoreCase(server, "127.0.0.1") &&
                            !StringUtil.EqualsIgnoreCase(server, "::1") &&
                            !StringUtil.EqualsIgnoreCase(server, "localhost") &&
                            !StringUtil.EqualsIgnoreCase(server, Environment.MachineName);


            if (isRemote)
            {
                configuration = ConfigurationFactory.Create(typeof(RemoteWebConfigurationHost),
                                                            webLevel, null, VirtualPath.GetVirtualPathString(path), site, locationSubPath, server, userName, password, tokenHandle);
            }
            else
            {
                if (String.IsNullOrEmpty(server))
                {
                    if (!String.IsNullOrEmpty(userName))
                    {
                        throw ExceptionUtil.ParameterInvalid("userName");
                    }

                    if (!String.IsNullOrEmpty(password))
                    {
                        throw ExceptionUtil.ParameterInvalid("password");
                    }

                    if (tokenHandle != (IntPtr)0)
                    {
                        throw ExceptionUtil.ParameterInvalid("tokenHandle");
                    }
                }

                // Create a copy of the fileMap, so that it cannot be altered by
                // its creator once we start using it.
                if (fileMap != null)
                {
                    fileMap = (ConfigurationFileMap)fileMap.Clone();
                }

                WebConfigurationFileMap webFileMap = fileMap as WebConfigurationFileMap;
                if (webFileMap != null && !String.IsNullOrEmpty(site))
                {
                    webFileMap.Site = site;
                }

                configuration = ConfigurationFactory.Create(typeof(WebConfigurationHost),
                                                            webLevel, fileMap, VirtualPath.GetVirtualPathString(path), site, locationSubPath);
            }

            return(configuration);
        }
コード例 #22
0
        public override void InitForConfiguration(ref string locationSubPath, out string configPath, out string locationConfigPath,
                                                  IInternalConfigRoot root, params object[] hostInitConfigurationParams)
        {
            WebLevel webLevel = (WebLevel)hostInitConfigurationParams[0];
            // ConfigurationFileMap    fileMap = (ConfigurationFileMap)    hostInitConfigurationParams[1];
            string path = (string)hostInitConfigurationParams[2];
            string site = (string)hostInitConfigurationParams[3];

            if (locationSubPath == null)
            {
                locationSubPath = (string)hostInitConfigurationParams[4];
            }

            string server      = (string)hostInitConfigurationParams[5];
            string userName    = (string)hostInitConfigurationParams[6];
            string password    = (string)hostInitConfigurationParams[7];
            IntPtr tokenHandle = (IntPtr)hostInitConfigurationParams[8];

            configPath         = null;
            locationConfigPath = null;

            _Server   = server;
            _Username = GetUserNameFromFullName(userName);
            _Domain   = GetDomainFromFullName(userName);
            _Password = password;
            _Identity = (tokenHandle == IntPtr.Zero) ? null : new WindowsIdentity(tokenHandle); //CreateWindowsIdentity(username, domain, password, tokenHandle);

            _PathMap = new Hashtable(StringComparer.OrdinalIgnoreCase);

#if !FEATURE_PAL // FEATURE_PAL does not have WindowsImpersonationContext, COM objects
            //
            // Send the path arguments to the server for parsing,
            // and retreive the normalized paths and path mapping
            // from config paths to file paths.
            //
            string filePaths;
            try {
                WindowsImpersonationContext wiContext = (_Identity != null) ? _Identity.Impersonate() : null;
                try {
                    IRemoteWebConfigurationHostServer remoteSrv = RemoteWebConfigurationHost.CreateRemoteObject(server, _Username, _Domain, password); //(IRemoteWebConfigurationHostServer) Activator.CreateInstance(type);
                    try {
                        filePaths = remoteSrv.GetFilePaths((int)webLevel, path, site, locationSubPath);
                    } finally {
                        // Release COM objects
                        while (Marshal.ReleaseComObject(remoteSrv) > 0)
                        {
                        }
                    }
                } finally {
                    if (wiContext != null)
                    {
                        wiContext.Undo();
                    }
                }
            }
            catch {
                // Wrap finally clause with a try to avoid exception clauses being run
                // while the thread is impersonated.
                throw;
            }

            if (filePaths == null)
            {
                throw ExceptionUtil.UnexpectedError("RemoteWebConfigurationHost::InitForConfiguration");
            }

            //
            // Format of filePaths:
            //      appPath < appSiteName < appSiteID < configPath < locationConfigPath [< configPath < fileName]+
            //
            string[] parts = filePaths.Split(RemoteWebConfigurationHostServer.FilePathsSeparatorParams);

            if (parts.Length < 7 || (parts.Length - 5) % 2 != 0)
            {
                throw ExceptionUtil.UnexpectedError("RemoteWebConfigurationHost::InitForConfiguration");
            }

            // convert empty strings to nulls
            for (int i = 0; i < parts.Length; i++)
            {
                if (parts[i].Length == 0)
                {
                    parts[i] = null;
                }
            }

            // get config paths
            string appPath     = parts[0];
            string appSiteName = parts[1];
            string appSiteID   = parts[2];
            configPath         = parts[3];
            locationConfigPath = parts[4];
            _ConfigPath        = configPath;

            // Create a WebConfigurationFileMap to be used when we later initialize our delegating WebConfigurationHost
            WebConfigurationFileMap configFileMap      = new WebConfigurationFileMap();
            VirtualPath             appPathVirtualPath = VirtualPath.CreateAbsoluteAllowNull(appPath);

            configFileMap.Site = appSiteID;

            // populate the configpath->physical path mapping
            for (int i = 5; i < parts.Length; i += 2)
            {
                string configPathTemp   = parts[i];
                string physicalFilePath = parts[i + 1];

                _PathMap.Add(configPathTemp, physicalFilePath);

                // Update the WebConfigurationFileMap
                if (WebConfigurationHost.IsMachineConfigPath(configPathTemp))
                {
                    configFileMap.MachineConfigFilename = physicalFilePath;
                }
                else
                {
                    string vPathString;
                    bool   isRootApp;

                    if (WebConfigurationHost.IsRootWebConfigPath(configPathTemp))
                    {
                        vPathString = null;
                        isRootApp   = false;
                    }
                    else
                    {
                        VirtualPath vPath;
                        string      dummy;

                        WebConfigurationHost.GetSiteIDAndVPathFromConfigPath(configPathTemp, out dummy, out vPath);
                        vPathString = VirtualPath.GetVirtualPathString(vPath);
                        isRootApp   = (vPath == appPathVirtualPath);
                    }

                    configFileMap.VirtualDirectories.Add(vPathString,
                                                         new VirtualDirectoryMapping(Path.GetDirectoryName(physicalFilePath), isRootApp));
                }
            }
#else // !FEATURE_PAL: set dummy config path
            string appPath = null;
            _ConfigPath = configPath;
#endif // !FEATURE_PAL

            // Delegate to a WebConfigurationHost for unhandled methods.
            WebConfigurationHost webConfigurationHost = new WebConfigurationHost();
            webConfigurationHost.Init(root, true, new UserMapPath(configFileMap, /*pathsAreLocal*/ false), null, appPath, appSiteName, appSiteID);
            Host = webConfigurationHost;
        }
コード例 #23
0
        /// <summary>
        /// Gets the configuration settings for the installing assembly
        /// </summary>
        /// <returns></returns>
        public static System.Configuration.Configuration GetInstallingConfiguration()
        {
            Assembly assembly = GetEntryInstallingAssembly();

            if (IsWebApplication())
            {
                string websiteRootDirectory = Path.GetDirectoryName(Path.GetDirectoryName(assembly.Location));

                VirtualDirectoryMapping vdm = new VirtualDirectoryMapping(websiteRootDirectory, true);
                WebConfigurationFileMap wcfm = new WebConfigurationFileMap();
                wcfm.VirtualDirectories.Add("/", vdm);

                return WebConfigurationManager.OpenMappedWebConfiguration(wcfm, "/");
            }
            else
            {
                string configFilePath = Path.Combine(
                    Path.GetDirectoryName(assembly.Location),
                    Path.GetFileNameWithoutExtension(assembly.Location));

                return ConfigurationManager.OpenExeConfiguration(configFilePath);
            }
        }
コード例 #24
0
ファイル: WebConfigurationHost.cs プロジェクト: vargaz/mono
		public virtual void InitForConfiguration (ref string locationSubPath, out string configPath,
							  out string locationConfigPath, IInternalConfigRoot root,
							  params object[] hostInitConfigurationParams)
		{
			string fullPath = (string) hostInitConfigurationParams [1];
			map = (WebConfigurationFileMap) hostInitConfigurationParams [0];
			bool inAnotherApp = (bool) hostInitConfigurationParams [7];

			if (inAnotherApp)
				appVirtualPath = fullPath;
			else
				appVirtualPath = HttpRuntime.AppDomainAppVirtualPath;
			
			if (locationSubPath == MachineWebPath) {
				locationSubPath = MachinePath;
				configPath = MachineWebPath;
				locationConfigPath = null;
			} else if (locationSubPath == MachinePath) {
				locationSubPath = null;
				configPath = MachinePath;
				locationConfigPath = null;
			} else {
				int i;
				if (locationSubPath == null) {
					configPath = fullPath;
					if (configPath.Length > 1)
						configPath = VirtualPathUtility.RemoveTrailingSlash (configPath);
				} else
					configPath = locationSubPath;
				
				if (configPath == HttpRuntime.AppDomainAppVirtualPath || configPath == "/")
					i = -1;
				else
					i = configPath.LastIndexOf ("/");

				if (i != -1) {
					locationConfigPath = configPath.Substring (i+1);
					
					if (i == 0)
						locationSubPath = "/";
					else
						locationSubPath = fullPath.Substring (0, i);
				} else {
					locationSubPath = MachineWebPath;
					locationConfigPath = null;
				}
			}
		}
コード例 #25
0
        public override void InitForConfiguration(ref string locationSubPath, out string configPath, out string locationConfigPath, IInternalConfigRoot root, params object[] hostInitConfigurationParams)
        {
            string   str6;
            WebLevel level = (WebLevel)hostInitConfigurationParams[0];
            string   str   = (string)hostInitConfigurationParams[2];
            string   site  = (string)hostInitConfigurationParams[3];

            if (locationSubPath == null)
            {
                locationSubPath = (string)hostInitConfigurationParams[4];
            }
            string str3         = (string)hostInitConfigurationParams[5];
            string fullUserName = (string)hostInitConfigurationParams[6];
            string password     = (string)hostInitConfigurationParams[7];
            IntPtr userToken    = (IntPtr)hostInitConfigurationParams[8];

            configPath         = null;
            locationConfigPath = null;
            this._Server       = str3;
            this._Username     = GetUserNameFromFullName(fullUserName);
            this._Domain       = GetDomainFromFullName(fullUserName);
            this._Password     = password;
            this._Identity     = (userToken == IntPtr.Zero) ? null : new WindowsIdentity(userToken);
            this._PathMap      = new Hashtable(StringComparer.OrdinalIgnoreCase);
            try
            {
                WindowsImpersonationContext context = (this._Identity != null) ? this._Identity.Impersonate() : null;
                try
                {
                    IRemoteWebConfigurationHostServer o = CreateRemoteObject(str3, this._Username, this._Domain, password);
                    try
                    {
                        str6 = o.GetFilePaths((int)level, str, site, locationSubPath);
                    }
                    finally
                    {
                        while (Marshal.ReleaseComObject(o) > 0)
                        {
                        }
                    }
                }
                finally
                {
                    if (context != null)
                    {
                        context.Undo();
                    }
                }
            }
            catch
            {
                throw;
            }
            if (str6 == null)
            {
                throw System.Web.Util.ExceptionUtil.UnexpectedError("RemoteWebConfigurationHost::InitForConfiguration");
            }
            string[] strArray = str6.Split(RemoteWebConfigurationHostServer.FilePathsSeparatorParams);
            if ((strArray.Length < 7) || (((strArray.Length - 5) % 2) != 0))
            {
                throw System.Web.Util.ExceptionUtil.UnexpectedError("RemoteWebConfigurationHost::InitForConfiguration");
            }
            for (int i = 0; i < strArray.Length; i++)
            {
                if (strArray[i].Length == 0)
                {
                    strArray[i] = null;
                }
            }
            string virtualPath = strArray[0];
            string str8        = strArray[1];
            string str9        = strArray[2];

            configPath         = strArray[3];
            locationConfigPath = strArray[4];
            this._ConfigPath   = configPath;
            WebConfigurationFileMap fileMap = new WebConfigurationFileMap();
            VirtualPath             path    = VirtualPath.CreateAbsoluteAllowNull(virtualPath);

            fileMap.Site = str9;
            for (int j = 5; j < strArray.Length; j += 2)
            {
                string key   = strArray[j];
                string str11 = strArray[j + 1];
                this._PathMap.Add(key, str11);
                if (WebConfigurationHost.IsMachineConfigPath(key))
                {
                    fileMap.MachineConfigFilename = str11;
                }
                else
                {
                    string virtualPathString;
                    bool   flag;
                    if (WebConfigurationHost.IsRootWebConfigPath(key))
                    {
                        virtualPathString = null;
                        flag = false;
                    }
                    else
                    {
                        VirtualPath path2;
                        string      str13;
                        WebConfigurationHost.GetSiteIDAndVPathFromConfigPath(key, out str13, out path2);
                        virtualPathString = VirtualPath.GetVirtualPathString(path2);
                        flag = path2 == path;
                    }
                    fileMap.VirtualDirectories.Add(virtualPathString, new VirtualDirectoryMapping(Path.GetDirectoryName(str11), flag));
                }
            }
            WebConfigurationHost host = new WebConfigurationHost();

            object[] hostInitParams = new object[6];
            hostInitParams[0] = true;
            hostInitParams[1] = new UserMapPath(fileMap, false);
            hostInitParams[3] = virtualPath;
            hostInitParams[4] = str8;
            hostInitParams[5] = str9;
            host.Init(root, hostInitParams);
            base.Host = host;
        }
コード例 #26
0
        public virtual void InitForConfiguration(ref string locationSubPath, out string configPath,
                                                 out string locationConfigPath, IInternalConfigRoot root,
                                                 params object[] hostInitConfigurationParams)
        {
            string fullPath = (string)hostInitConfigurationParams [1];

            map = (WebConfigurationFileMap)hostInitConfigurationParams [0];
            bool inAnotherApp = (bool)hostInitConfigurationParams [7];

            if (inAnotherApp)
            {
                appVirtualPath = fullPath;
            }
            else
            {
                appVirtualPath = HttpRuntime.AppDomainAppVirtualPath;
            }

            if (locationSubPath == MachineWebPath)
            {
                locationSubPath    = MachinePath;
                configPath         = MachineWebPath;
                locationConfigPath = null;
            }
            else if (locationSubPath == MachinePath)
            {
                locationSubPath    = null;
                configPath         = MachinePath;
                locationConfigPath = null;
            }
            else
            {
                int i;
                if (locationSubPath == null)
                {
                    configPath = fullPath;
                    if (configPath.Length > 1)
                    {
                        configPath = VirtualPathUtility.RemoveTrailingSlash(configPath);
                    }
                }
                else
                {
                    configPath = locationSubPath;
                }

                if (configPath == HttpRuntime.AppDomainAppVirtualPath || configPath == "/")
                {
                    i = -1;
                }
                else
                {
                    i = configPath.LastIndexOf("/");
                }

                if (i != -1)
                {
                    locationConfigPath = configPath.Substring(i + 1);

                    if (i == 0)
                    {
                        locationSubPath = "/";
                    }
                    else
                    {
                        locationSubPath = fullPath.Substring(0, i);
                    }
                }
                else
                {
                    locationSubPath    = MachineWebPath;
                    locationConfigPath = null;
                }
            }
        }
 public static System.Configuration.Configuration OpenMappedWebConfiguration(WebConfigurationFileMap fileMap, string path)
 {
     return(default(System.Configuration.Configuration));
 }
コード例 #28
0
 public static Configuration OpenWebConfigFile(string configPath)
 {
     var configFile = new FileInfo(configPath);
     var vdm = new VirtualDirectoryMapping(configFile.DirectoryName, true, configFile.Name);
     var wcfm = new WebConfigurationFileMap();
     wcfm.VirtualDirectories.Add("/", vdm);
     return WebConfigurationManager.OpenMappedWebConfiguration(wcfm, "/");
 }
コード例 #29
0
ファイル: DatabaseContext.cs プロジェクト: Jeavon/Umbraco-CMS
        /// <summary>
        /// Saves the connection string as a proper .net ConnectionString and the legacy AppSettings key/value.
        /// </summary>
        /// <remarks>
        /// Saves the ConnectionString in the very nasty 'medium trust'-supportive way.
        /// </remarks>
        /// <param name="connectionString"></param>
        /// <param name="providerName"></param>
        private void SaveConnectionString(string connectionString, string providerName)
        {
            //Set the connection string for the new datalayer
            var connectionStringSettings = string.IsNullOrEmpty(providerName)
                                      ? new ConnectionStringSettings(GlobalSettings.UmbracoConnectionName,
                                                                     connectionString)
                                      : new ConnectionStringSettings(GlobalSettings.UmbracoConnectionName,
                                                                     connectionString, providerName);

            _connectionString = connectionString;
            _providerName = providerName;

            var webConfig = new WebConfigurationFileMap();
            var vDir = GlobalSettings.FullpathToRoot;
            foreach (VirtualDirectoryMapping v in webConfig.VirtualDirectories)
            {
                if (v.IsAppRoot)
                {
                    vDir = v.PhysicalDirectory;
                }
            }

            var fileName = Path.Combine(vDir, "web.config");
            var xml = XDocument.Load(fileName, LoadOptions.PreserveWhitespace);
            var connectionstrings = xml.Root.Descendants("connectionStrings").Single();

            // Update connectionString if it exists, or else create a new appSetting for the given key and value
            var setting = connectionstrings.Descendants("add").FirstOrDefault(s => s.Attribute("name").Value == GlobalSettings.UmbracoConnectionName);
            if (setting == null)
                connectionstrings.Add(new XElement("add",
                    new XAttribute("name", GlobalSettings.UmbracoConnectionName),
                    new XAttribute("connectionString", connectionStringSettings),
                    new XAttribute("providerName", providerName)));
            else
            {
                setting.Attribute("connectionString").Value = connectionString;
                setting.Attribute("providerName").Value = providerName;
            }

            xml.Save(fileName, SaveOptions.DisableFormatting);

            LogHelper.Info<DatabaseContext>("Configured a new ConnectionString using the '" + providerName + "' provider.");
        }
コード例 #30
0
 public static _Configuration OpenMappedWebConfiguration(WebConfigurationFileMap fileMap, string path, string site, string locationSubPath)
 {
     return(ConfigurationFactory.Create(typeof(WebConfigurationHost), fileMap, path, site, locationSubPath));
 }
コード例 #31
0
 private ConfigurationSection GetConfigSectionFile(string configSection, string dirName, out System.Configuration.Configuration config)
 {
     if (dirName == ".")
     {
         dirName = Environment.CurrentDirectory;
     }
     else
     {
         if (!Path.IsPathRooted(dirName))
         {
             dirName = Path.Combine(Environment.CurrentDirectory, dirName);
         }
         if (!Directory.Exists(dirName))
         {
             throw new Exception(System.Web.SR.GetString("Configuration_for_physical_path_not_found", new object[] { dirName }));
         }
     }
     WebConfigurationFileMap fileMap = new WebConfigurationFileMap();
     string virtualDirectory = dirName.Replace('\\', '/');
     if ((virtualDirectory.Length > 2) && (virtualDirectory[1] == ':'))
     {
         virtualDirectory = virtualDirectory.Substring(2);
     }
     else if (virtualDirectory.StartsWith("//", StringComparison.Ordinal))
     {
         virtualDirectory = "/";
     }
     fileMap.VirtualDirectories.Add(virtualDirectory, new VirtualDirectoryMapping(dirName, true));
     try
     {
         config = WebConfigurationManager.OpenMappedWebConfiguration(fileMap, virtualDirectory);
     }
     catch (Exception exception)
     {
         throw new Exception(System.Web.SR.GetString("Configuration_for_physical_path_not_found", new object[] { dirName }), exception);
     }
     return config.GetSection(configSection);
 }
コード例 #32
0
		RazorEngineHost CreateRazorHost (string fileName)
		{
			if (project != null) {
				var projectFile = project.GetProjectFile (fileName);
				if (projectFile != null && projectFile.Generator == "RazorTemplatePreprocessor") {
					return new MonoDevelop.AspNet.Razor.Generator.PreprocessedRazorHost (fileName) {
						DesignTimeMode = true,
						EnableLinePragmas = false,
					};
				}
			}

			string virtualPath = "~/Views/Default.cshtml";
			if (aspProject != null)
				virtualPath = aspProject.LocalToVirtualPath (fileName);

			WebPageRazorHost host = null;

			// Try to create host using web.config file
			var webConfigMap = new WebConfigurationFileMap ();
			if (aspProject != null) {
				var vdm = new VirtualDirectoryMapping (aspProject.BaseDirectory.Combine ("Views"), true, "web.config");
			webConfigMap.VirtualDirectories.Add ("/", vdm);
			}
			Configuration configuration;
			try {
				configuration = WebConfigurationManager.OpenMappedWebConfiguration (webConfigMap, "/");
			} catch {
				configuration = null;
			}
			if (configuration != null) {
				var rws = configuration.GetSectionGroup (RazorWebSectionGroup.GroupName) as RazorWebSectionGroup;
				if (rws != null) {
					host = WebRazorHostFactory.CreateHostFromConfig (rws, virtualPath, fileName);
					host.DesignTimeMode = true;
				}
			}

			if (host == null) {
				host = new MvcWebPageRazorHost (virtualPath, fileName) { DesignTimeMode = true };
				// Add default namespaces from Razor section
				host.NamespaceImports.Add ("System.Web.Mvc");
				host.NamespaceImports.Add ("System.Web.Mvc.Ajax");
				host.NamespaceImports.Add ("System.Web.Mvc.Html");
				host.NamespaceImports.Add ("System.Web.Routing");
			}

			return host;
		}
コード例 #33
0
 public static Configuration OpenMappedWebConfiguration(WebConfigurationFileMap fileMap, string path, string site)
 {
     return(OpenWebConfigurationImpl(WebLevel.Path, fileMap, path, site, null,
                                     null, null, null, IntPtr.Zero));
 }
コード例 #34
0
ファイル: RazorViewCompiler.cs プロジェクト: pleb/Chillow
        /// <summary>
        /// Function that builds the contents of the generated file based on the contents of the input file
        /// </summary>
        /// <param name="inputFileContent">Content of the input file</param>
        /// <returns>Generated file as a byte array</returns>
        protected override byte[] GenerateCode(string inputFileContent)
        {
            var references = GetVSProject().References;

            // Add reference to our buildprovider and virtualpathprovider

            /*
            var buildprovAssembly = typeof(CompiledVirtualPathProvider).Assembly;

            if (references.Find(buildprovAssembly.GetName().Name) == null)
            {
                references.Add(buildprovAssembly.Location);
            }
            */

            // Get the root folder of the project

            var appRoot = Path.GetDirectoryName(GetProject().FullName);

            // Determine the project-relative path

            string projectRelativePath = InputFilePath.Substring(appRoot.Length);

            // Turn it into a virtual path by prepending ~ and fixing it up

            string virtualPath = VirtualPathUtility.ToAppRelative("~" + projectRelativePath);

            var vdm = new VirtualDirectoryMapping(appRoot, true);

            var wcfm = new WebConfigurationFileMap();

            wcfm.VirtualDirectories.Add("/", vdm);

            var config = WebConfigurationManager.OpenMappedWebConfiguration(wcfm, projectRelativePath);

            var sectGroup = new RazorWebSectionGroup
            {
                Host = (HostSection) config.GetSection(HostSection.SectionName) ?? new HostSection {FactoryType = typeof (MvcWebRazorHostFactory).AssemblyQualifiedName}, Pages = (RazorPagesSection) config.GetSection(RazorPagesSection.SectionName)
            };

            // Create the same type of Razor host that's used to process Razor files in App_Code

            var host = IsHelper ? new WebCodeRazorHost(virtualPath, InputFilePath) : WebRazorHostFactory.CreateHostFromConfig(sectGroup, virtualPath, InputFilePath);

            // Set the namespace to be the same as what's used by default for regular .cs files

            host.DefaultNamespace = FileNameSpace;

            host.NamespaceImports.Remove("WebMatrix.Data");
            host.NamespaceImports.Remove("WebMatrix.WebData");

            var systemWebPages = config.GetSection("system.web/pages") as PagesSection;

            if (systemWebPages != null)
            {
                foreach (NamespaceInfo ns in systemWebPages.Namespaces)
                {
                    if (!host.NamespaceImports.Contains(ns.Namespace))
                    {
                        host.NamespaceImports.Add(ns.Namespace);
                    }
                }
            }

            var compilationSection = config.GetSection("system.web/compilation") as CompilationSection;

            if (compilationSection != null)
            {
                foreach (AssemblyInfo assembly in compilationSection.Assemblies)
                {
                    if (assembly.Assembly != "*" && references.Find(assembly.Assembly) == null)
                    {
                        references.Add(assembly.Assembly);
                    }
                }
            }

            // Create a Razor engine and pass it our host

            var engine = new RazorTemplateEngine(host);

            // Generate code

            GeneratorResults results;

            try
            {
                using (TextReader reader = new StringReader(inputFileContent))
                {
                    results = engine.GenerateCode(reader,null,null,InputFilePath);
                }
            }
            catch (Exception e)
            {
                GeneratorError(4, e.ToString(), 1, 1);

                return RazorError;
            }

            // Output errors

            foreach (RazorError error in results.ParserErrors)
            {
                GeneratorError(4, error.Message, (uint)error.Location.LineIndex + 1, (uint)error.Location.CharacterIndex + 1);
            }

            CodeDomProvider provider = GetCodeProvider();

            try
            {
                if (CodeGeneratorProgress != null)
                {
                    // Report that we are 1/2 done

                    CodeGeneratorProgress.Progress(50, 100);
                }

                using (StringWriter writer = new StringWriter(new StringBuilder()))
                {
                    CodeGeneratorOptions options = new CodeGeneratorOptions
                                                       {
                                                           BlankLinesBetweenMembers = false,
                                                           BracingStyle = "C"
                                                       };

                    // Add a GeneratedCode attribute to the generated class

                    CodeCompileUnit generatedCode = results.GeneratedCode;

                    var ns = generatedCode.Namespaces[0];

                    CodeTypeDeclaration generatedType = ns.Types[0];

                    generatedType.CustomAttributes.Add(
                        new CodeAttributeDeclaration(
                            new CodeTypeReference(typeof(GeneratedCodeAttribute)),
                            new CodeAttributeArgument(new CodePrimitiveExpression("RazorViewCompiler")),
                            new CodeAttributeArgument(new CodePrimitiveExpression("1.0"))));

                    if(!IsHelper)
                    {
                        generatedType.CustomAttributes.Add(
                            new CodeAttributeDeclaration(
                                new CodeTypeReference(typeof(PageVirtualPathAttribute)),
                                new CodeAttributeArgument(new CodePrimitiveExpression(virtualPath))));
                    }

                    // Generate the code

                    provider.GenerateCodeFromCompileUnit(generatedCode, writer, options);

                    if (CodeGeneratorProgress != null)
                    {
                        //Report that we are done

                        CodeGeneratorProgress.Progress(100, 100);
                    }

                    writer.Flush();

                    // Save as UTF8

                    Encoding enc = Encoding.UTF8;

                    // Get the preamble (byte-order mark) for our encoding

                    byte[] preamble = enc.GetPreamble();

                    int preambleLength = preamble.Length;

                    // Convert the writer contents to a byte array

                    byte[] body = enc.GetBytes(writer.ToString());

                    // Prepend the preamble to body (store result in resized preamble array)

                    Array.Resize<byte>(ref preamble, preambleLength + body.Length);

                    Array.Copy(body, 0, preamble, preambleLength, body.Length);

                    // Return the combined byte array

                    return preamble;
                }
            }
            catch (Exception e)
            {
                GeneratorError(4, e.ToString(), 1, 1);

                return RazorError;
            }
        }
コード例 #35
0
		RazorEngineHost CreateRazorHost (string fileName)
		{
			string virtualPath = "~/Views/Default.cshtml";
			if (project != null)
				virtualPath = project.LocalToVirtualPath (fileName);

			WebPageRazorHost host = null;

			// Try to create host using web.config file
			var webConfigMap = new WebConfigurationFileMap ();
			var vdm = new VirtualDirectoryMapping (project.BaseDirectory.Combine ("Views"), true, "web.config");
			webConfigMap.VirtualDirectories.Add ("/", vdm);
			Configuration configuration;
			try {
				configuration = WebConfigurationManager.OpenMappedWebConfiguration (webConfigMap, "/");
			} catch {
				configuration = null;
			}
			if (configuration != null) {
				var rws = configuration.GetSectionGroup (RazorWebSectionGroup.GroupName) as RazorWebSectionGroup;
				if (rws != null) {
					host = WebRazorHostFactory.CreateHostFromConfig (rws, virtualPath, fileName);
					host.DesignTimeMode = true;
				}
			}

			if (host == null) {
				host = new MvcWebPageRazorHost (virtualPath, fileName) { DesignTimeMode = true };
				// Add default namespaces from Razor section
				host.NamespaceImports.Add ("System.Web.Mvc");
				host.NamespaceImports.Add ("System.Web.Mvc.Ajax");
				host.NamespaceImports.Add ("System.Web.Mvc.Html");
				host.NamespaceImports.Add ("System.Web.Routing");
			}

			return host;
		}
コード例 #36
0
        /// <summary>
        /// Get the appropriate tool configuration for this service reference.
        /// 
        /// If a reference.config file is present, the configuration object returned 
        /// will be the merged view of:
        /// 
        ///    Machine Config
        ///       ReferenceConfig
        ///       
        /// If not reference.config file is present, the configuration object returned
        /// will be a merged view of:
        ///     
        ///     Machine.config
        ///         web.config in application's physical path...
        ///         
        /// </summary>
        /// <param name="mapFile">SvcMapFile representing the service</param>
        /// <returns></returns>
        private System.Configuration.Configuration GetToolConfig(SvcMapFile mapFile, string mapFilePath)
        {
            string toolConfigFile = null;

            if (mapFile != null && mapFilePath != null)
            {
                foreach (ExtensionFile extensionFile in mapFile.Extensions)
                {
                    if (String.Equals(extensionFile.Name, TOOL_CONFIG_ITEM_NAME, StringComparison.Ordinal))
                    {
                        toolConfigFile = extensionFile.FileName;
                    }
                }
            }

            System.Web.Configuration.WebConfigurationFileMap fileMap;
            fileMap = new System.Web.Configuration.WebConfigurationFileMap();

            System.Web.Configuration.VirtualDirectoryMapping mapping;
            if (toolConfigFile != null)
            {
                //
                // If we've got a specific tool configuration to use, we better load that...
                //
                mapping = new System.Web.Configuration.VirtualDirectoryMapping(System.IO.Path.GetDirectoryName(mapFilePath), true, toolConfigFile);
            }
            else
            {
                //
                // Otherwise we fall back to the default web.config file...
                //
                mapping = new System.Web.Configuration.VirtualDirectoryMapping(HostingEnvironment.ApplicationPhysicalPath, true);
            }
            fileMap.VirtualDirectories.Add("/", mapping);

            return System.Web.Configuration.WebConfigurationManager.OpenMappedWebConfiguration(fileMap, "/", System.Web.Hosting.HostingEnvironment.SiteName);

        }
 private HostingEnvironment CreateAppDomainWithHostingEnvironment(string appId, IApplicationHost appHost, HostingEnvironmentParameters hostingParameters)
 {
     string physicalPath = appHost.GetPhysicalPath();
     if (!System.Web.Util.StringUtil.StringEndsWith(physicalPath, Path.DirectorySeparatorChar))
     {
         physicalPath = physicalPath + Path.DirectorySeparatorChar;
     }
     string domainId = ConstructAppDomainId(appId);
     string appName = System.Web.Util.StringUtil.GetStringHashCode(appId.ToLower(CultureInfo.InvariantCulture) + physicalPath.ToLower(CultureInfo.InvariantCulture)).ToString("x", CultureInfo.InvariantCulture);
     VirtualPath appVPath = VirtualPath.Create(appHost.GetVirtualPath());
     IDictionary dict = new Hashtable(20);
     AppDomainSetup setup = new AppDomainSetup();
     PopulateDomainBindings(domainId, appId, appName, physicalPath, appVPath, setup, dict);
     AppDomain domain = null;
     Exception innerException = null;
     string siteID = appHost.GetSiteID();
     string virtualPathStringNoTrailingSlash = appVPath.VirtualPathStringNoTrailingSlash;
     bool flag = false;
     bool flag2 = false;
     System.Configuration.Configuration configuration = null;
     PolicyLevel policyLevel = null;
     PermissionSet grantSet = null;
     List<StrongName> list = new List<StrongName>();
     string[] strArray = new string[] { "System.Web, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293", "System.Web.Extensions, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9", "System.Web.Abstractions, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9", "System.Web.Routing, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9", "System.ComponentModel.DataAnnotations, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9", "System.Web.DynamicData, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9", "System.Web.DataVisualization, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9", "System.Web.ApplicationServices, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9" };
     Exception appDomainCreationException = null;
     ImpersonationContext context = null;
     IntPtr zero = IntPtr.Zero;
     if ((hostingParameters != null) && ((hostingParameters.HostingFlags & HostingEnvironmentFlags.ClientBuildManager) != HostingEnvironmentFlags.Default))
     {
         flag2 = true;
         setup.LoaderOptimization = LoaderOptimization.MultiDomainHost;
     }
     try
     {
         zero = appHost.GetConfigToken();
         if (zero != IntPtr.Zero)
         {
             context = new ImpersonationContext(zero);
         }
         try
         {
             if (flag2 && (hostingParameters.IISExpressVersion != null))
             {
                 grantSet = new PermissionSet(PermissionState.Unrestricted);
                 setup.PartialTrustVisibleAssemblies = strArray;
             }
             else
             {
                 if (appHost is ISAPIApplicationHost)
                 {
                     string key = "f" + siteID + appVPath.VirtualPathString;
                     MapPathCacheInfo info1 = (MapPathCacheInfo) HttpRuntime.CacheInternal.Remove(key);
                     configuration = WebConfigurationManager.OpenWebConfiguration(virtualPathStringNoTrailingSlash, siteID);
                 }
                 else
                 {
                     WebConfigurationFileMap fileMap = new WebConfigurationFileMap();
                     IConfigMapPath path2 = appHost.GetConfigMapPathFactory().Create(appVPath.VirtualPathString, physicalPath);
                     string directory = null;
                     string baseName = null;
                     string path = "/";
                     path2.GetPathConfigFilename(siteID, path, out directory, out baseName);
                     if (directory != null)
                     {
                         fileMap.VirtualDirectories.Add(path, new VirtualDirectoryMapping(Path.GetFullPath(directory), true));
                     }
                     foreach (string str10 in virtualPathStringNoTrailingSlash.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries))
                     {
                         path = path + str10;
                         path2.GetPathConfigFilename(siteID, path, out directory, out baseName);
                         if (directory != null)
                         {
                             fileMap.VirtualDirectories.Add(path, new VirtualDirectoryMapping(Path.GetFullPath(directory), true));
                         }
                         path = path + "/";
                     }
                     configuration = WebConfigurationManager.OpenMappedWebConfiguration(fileMap, virtualPathStringNoTrailingSlash, siteID);
                 }
                 TrustSection trustSection = (TrustSection) configuration.GetSection("system.web/trust");
                 if ((trustSection == null) || string.IsNullOrEmpty(trustSection.Level))
                 {
                     throw new ConfigurationErrorsException(System.Web.SR.GetString("Config_section_not_present", new object[] { "trust" }));
                 }
                 bool legacyCasModel = trustSection.LegacyCasModel;
                 if (legacyCasModel)
                 {
                     SetNetFx40LegacySecurityPolicy(setup);
                 }
                 if (flag2)
                 {
                     grantSet = new PermissionSet(PermissionState.Unrestricted);
                     setup.PartialTrustVisibleAssemblies = strArray;
                 }
                 else
                 {
                     flag = legacyCasModel;
                     if (!flag)
                     {
                         if (trustSection.Level == "Full")
                         {
                             grantSet = new PermissionSet(PermissionState.Unrestricted);
                             setup.PartialTrustVisibleAssemblies = strArray;
                         }
                         else
                         {
                             SecurityPolicySection section = (SecurityPolicySection) configuration.GetSection("system.web/securityPolicy");
                             CompilationSection compilationSection = (CompilationSection) configuration.GetSection("system.web/compilation");
                             FullTrustAssembliesSection section4 = (FullTrustAssembliesSection) configuration.GetSection("system.web/fullTrustAssemblies");
                             policyLevel = GetPartialTrustPolicyLevel(trustSection, section, compilationSection, physicalPath, appVPath);
                             grantSet = policyLevel.GetNamedPermissionSet(trustSection.PermissionSetName);
                             if (grantSet == null)
                             {
                                 throw new ConfigurationErrorsException(System.Web.SR.GetString("Permission_set_not_found", new object[] { trustSection.PermissionSetName }));
                             }
                             if (section4 != null)
                             {
                                 FullTrustAssemblyCollection fullTrustAssemblies = section4.FullTrustAssemblies;
                                 if (fullTrustAssemblies != null)
                                 {
                                     list.AddRange(from fta in fullTrustAssemblies.Cast<FullTrustAssembly>() select CreateStrongName(fta.AssemblyName, fta.Version, fta.PublicKey));
                                 }
                             }
                             if (list.Contains(_mwiV1StrongName))
                             {
                                 list.AddRange(CreateFutureMicrosoftWebInfrastructureStrongNames());
                             }
                             setup.AppDomainManagerType = typeof(AspNetAppDomainManager).FullName;
                             setup.AppDomainManagerAssembly = typeof(AspNetAppDomainManager).Assembly.FullName;
                         }
                     }
                     if (trustSection.Level != "Full")
                     {
                         PartialTrustVisibleAssembliesSection section5 = (PartialTrustVisibleAssembliesSection) configuration.GetSection("system.web/partialTrustVisibleAssemblies");
                         string[] array = null;
                         if (section5 != null)
                         {
                             PartialTrustVisibleAssemblyCollection partialTrustVisibleAssemblies = section5.PartialTrustVisibleAssemblies;
                             if ((partialTrustVisibleAssemblies != null) && (partialTrustVisibleAssemblies.Count != 0))
                             {
                                 array = new string[partialTrustVisibleAssemblies.Count + strArray.Length];
                                 for (int i = 0; i < partialTrustVisibleAssemblies.Count; i++)
                                 {
                                     array[i] = partialTrustVisibleAssemblies[i].AssemblyName + ", PublicKey=" + NormalizePublicKeyBlob(partialTrustVisibleAssemblies[i].PublicKey);
                                 }
                                 strArray.CopyTo(array, partialTrustVisibleAssemblies.Count);
                             }
                         }
                         if (array == null)
                         {
                             array = strArray;
                         }
                         setup.PartialTrustVisibleAssemblies = array;
                     }
                 }
             }
         }
         catch (Exception exception3)
         {
             appDomainCreationException = exception3;
             grantSet = new PermissionSet(PermissionState.Unrestricted);
         }
         try
         {
             if (flag)
             {
                 domain = AppDomain.CreateDomain(domainId, GetDefaultDomainIdentity(), setup);
             }
             else
             {
                 domain = AppDomain.CreateDomain(domainId, GetDefaultDomainIdentity(), setup, grantSet, list.ToArray());
             }
             foreach (DictionaryEntry entry in dict)
             {
                 domain.SetData((string) entry.Key, (string) entry.Value);
             }
         }
         catch (Exception exception4)
         {
             innerException = exception4;
         }
     }
     finally
     {
         if (context != null)
         {
             context.Undo();
             context = null;
         }
         if (zero != IntPtr.Zero)
         {
             System.Web.UnsafeNativeMethods.CloseHandle(zero);
             zero = IntPtr.Zero;
         }
     }
     if (domain == null)
     {
         throw new SystemException(System.Web.SR.GetString("Cannot_create_AppDomain"), innerException);
     }
     Type type = typeof(HostingEnvironment);
     string fullName = type.Module.Assembly.FullName;
     string typeName = type.FullName;
     ObjectHandle handle = null;
     ImpersonationContext context2 = null;
     IntPtr token = IntPtr.Zero;
     int num2 = 10;
     int num3 = 0;
     while (num3 < num2)
     {
         try
         {
             token = appHost.GetConfigToken();
             break;
         }
         catch (InvalidOperationException)
         {
             num3++;
             Thread.Sleep(250);
             continue;
         }
     }
     if (token != IntPtr.Zero)
     {
         try
         {
             context2 = new ImpersonationContext(token);
         }
         catch
         {
         }
         finally
         {
             System.Web.UnsafeNativeMethods.CloseHandle(token);
         }
     }
     try
     {
         handle = Activator.CreateInstance(domain, fullName, typeName);
     }
     finally
     {
         if (context2 != null)
         {
             context2.Undo();
         }
         if (handle == null)
         {
             AppDomain.Unload(domain);
         }
     }
     HostingEnvironment environment = (handle != null) ? (handle.Unwrap() as HostingEnvironment) : null;
     if (environment == null)
     {
         throw new SystemException(System.Web.SR.GetString("Cannot_create_HostEnv"));
     }
     IConfigMapPathFactory configMapPathFactory = appHost.GetConfigMapPathFactory();
     if (appDomainCreationException == null)
     {
         environment.Initialize(this, appHost, configMapPathFactory, hostingParameters, policyLevel);
         return environment;
     }
     environment.Initialize(this, appHost, configMapPathFactory, hostingParameters, policyLevel, appDomainCreationException);
     return environment;
 }
コード例 #38
0
        private static void ReadConnectionString(MigrationToolSettings settings)
        {
            var vdm = new VirtualDirectoryMapping(_settings.SourceDirectory, true);
            var wcfm = new WebConfigurationFileMap();
            wcfm.VirtualDirectories.Add("/", vdm);
            var config = WebConfigurationManager.OpenMappedWebConfiguration(wcfm, "/");

            var connectionString = config.ConnectionStrings.ConnectionStrings["EPiServerDB"].ConnectionString;
            if (string.IsNullOrWhiteSpace(connectionString))
            {
                throw new ConfigurationErrorsException("Cannot find EPiServer database connection");
            }

            settings.ConnectionString = connectionString;
        }
コード例 #39
0
 public static Configuration OpenMappedWebConfiguration(WebConfigurationFileMap fileMap, string path, string site, string locationSubPath) {
     return OpenWebConfigurationImpl(WebLevel.Path, fileMap, path, site, locationSubPath, 
         null, null, null, IntPtr.Zero);
 }
コード例 #40
0
 public RazorParser(Compilation compilation) : base(compilation)
 {
     _configMap = new WebConfigurationFileMap { VirtualDirectories = { { "/", new VirtualDirectoryMapping(Compilation.CurrentDirectory.FullName, true) } } };
 }
コード例 #41
0
 public static System.Configuration.Configuration OpenMappedWebConfiguration(WebConfigurationFileMap fileMap, string path, string site, string locationSubPath)
 {
     return(OpenWebConfigurationImpl(WebLevel.Path, fileMap, path, site, locationSubPath, null, null, null, IntPtr.Zero));
 }
コード例 #42
0
        private static NameValueCollection GetAppSettings(string path)
        {
            if (path.StartsWith("~/", StringComparison.Ordinal))
            {
                // Path is virtual, assume we're hosted
                return (NameValueCollection)WebConfigurationManager.GetSection("appSettings", path);
            }
            else
            {
                // Path is physical, map it to an application
                WebConfigurationFileMap fileMap = new WebConfigurationFileMap();
                fileMap.VirtualDirectories.Add("/", new VirtualDirectoryMapping(path, true));
                var config = WebConfigurationManager.OpenMappedWebConfiguration(fileMap, "/");

                var appSettingsSection = config.AppSettings;
                var appSettings = new NameValueCollection();

                foreach (KeyValueConfigurationElement element in appSettingsSection.Settings)
                {
                    appSettings.Add(element.Key, element.Value);
                }
                return appSettings;
            }
        }
コード例 #43
0
        internal UserMapPath(ConfigurationFileMap fileMap, bool pathsAreLocal)
        {
            _pathsAreLocal = pathsAreLocal;


            if (!String.IsNullOrEmpty(fileMap.MachineConfigFilename))
            {
                if (_pathsAreLocal)
                {
                    _machineConfigFilename = Path.GetFullPath(fileMap.MachineConfigFilename);
                }
                else
                {
                    _machineConfigFilename = fileMap.MachineConfigFilename;
                }
            }

            if (string.IsNullOrEmpty(_machineConfigFilename))
            {
                // Defaults for machine.config and root web.config if not supplied by user
                _machineConfigFilename = HttpConfigurationSystem.MachineConfigurationFilePath;
                _rootWebConfigFilename = HttpConfigurationSystem.RootWebConfigurationFilePath;
            }
            else
            {
                _rootWebConfigFilename = Path.Combine(Path.GetDirectoryName(_machineConfigFilename), "web.config");
            }

            _webFileMap = fileMap as WebConfigurationFileMap;
            if (_webFileMap != null)
            {
                // Use the site if supplied, otherwise use the default.
                if (!String.IsNullOrEmpty(_webFileMap.Site))
                {
                    _siteName = _webFileMap.Site;
                    _siteID   = _webFileMap.Site;
                }
                else
                {
                    _siteName = WebConfigurationHost.DefaultSiteName;
                    _siteID   = WebConfigurationHost.DefaultSiteID;
                }

                if (_pathsAreLocal)
                {
                    // validate mappings
                    foreach (string virtualDirectory in _webFileMap.VirtualDirectories)
                    {
                        VirtualDirectoryMapping mapping = _webFileMap.VirtualDirectories[virtualDirectory];
                        mapping.Validate();
                    }
                }

                // Get the root web.config path
                VirtualDirectoryMapping rootWebMapping = _webFileMap.VirtualDirectories[null];
                if (rootWebMapping != null)
                {
                    _rootWebConfigFilename = Path.Combine(rootWebMapping.PhysicalDirectory, rootWebMapping.ConfigFileBaseName);
                    _webFileMap.VirtualDirectories.Remove(null);
                }
            }
        }