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