// 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; }
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 }); }