internal bool IsEquivalentType(IInternalConfigHost host, string typeName) { try { if (FactoryTypeName == typeName) { return(true); } Type t1, t2; if (host != null) { t1 = TypeUtil.GetType(host, typeName, false); t2 = TypeUtil.GetType(host, FactoryTypeName, false); } else { t1 = TypeUtil.GetType(typeName, false); t2 = TypeUtil.GetType(FactoryTypeName, false); } return((t1 != null) && (t1 == t2)); } catch { } return(false); }
// Ask the host to get the type specified by typeString. If it fails, try to retrieve it // as a type from System.dll. If that fails, return null or throw the original // exception as indicated by throwOnError. internal static Type GetType(IInternalConfigHost host, string typeString, bool throwOnError) { Type type = null; Exception originalException = null; try { type = host.GetConfigType(typeString, throwOnError); } catch (Exception e) { originalException = e; } if (type == null) { type = GetImplicitType(typeString); if ((type == null) && (originalException != null)) { throw originalException; } } return(type); }
public void Init (Type typeConfigHost, params object[] hostInitParams) { this.hostInitParams = hostInitParams; host = (IInternalConfigHost) Activator.CreateInstance (typeConfigHost); root = new InternalConfigurationRoot (); root.Init (host, false); }
public LuxConfigHost(IInternalConfigHost internalConfigHost) { FileSystem = new FileSystem(); if (ConfigSystemProxy.FileSystem != null) FileSystem = ConfigSystemProxy.FileSystem; Host = internalConfigHost; }
void IConfigSystem.Init(Type typeConfigHost, params object[] hostInitParams) { _configRoot = new InternalConfigRoot(); _configHost = (IInternalConfigHost) TypeUtil.CreateInstanceWithReflectionPermission(typeConfigHost); _configRoot.Init(_configHost, false); _configHost.Init(_configRoot, hostInitParams); }
public void Init(Type typeConfigHost, params object[] hostInitParams) { this.hostInitParams = hostInitParams; host = (IInternalConfigHost)Activator.CreateInstance(typeConfigHost); root = new InternalConfigurationRoot(); root.Init(host, false); }
void IConfigSystem.Init(Type typeConfigHost, params object[] hostInitParams) { this._configRoot = new InternalConfigRoot(); this._configHost = (IInternalConfigHost)System.Configuration.TypeUtil.CreateInstanceWithReflectionPermission(typeConfigHost); this._configRoot.Init(this._configHost, false); this._configHost.Init(this._configRoot, hostInitParams); }
void IConfigSystem.Init(Type typeConfigHost, params object[] hostInitParams) { _configRoot = new InternalConfigRoot(); _configHost = (IInternalConfigHost)TypeUtil.CreateInstance(typeConfigHost); _configRoot.Init(_configHost, false); _configHost.Init(_configRoot, hostInitParams); }
internal bool IsEquivalentSectionGroupFactory(IInternalConfigHost host, string typeName) { if ((typeName != null) && (this._factoryTypeName != null)) { return(this.IsEquivalentType(host, typeName)); } return(true); }
internal bool IsEquivalentSectionGroupFactory(IInternalConfigHost host, string typeName) { if (typeName == null || _factoryTypeName == null) { return(true); } return(IsEquivalentType(host, typeName)); }
internal Configuration(string locationSubPath, Type typeConfigHost, params object[] hostInitConfigurationParams) { _typeConfigHost = typeConfigHost; _hostInitConfigurationParams = hostInitConfigurationParams; IInternalConfigHost configHost = (IInternalConfigHost)TypeUtil.CreateInstance(typeConfigHost); // Wrap the host with the UpdateConfigHost to support SaveAs. UpdateConfigHost updateConfigHost = new UpdateConfigHost(configHost); // Now wrap in ImplicitMachineConfigHost so we can stub in a simple machine.config if needed. IInternalConfigHost implicitMachineConfigHost = new ImplicitMachineConfigHost(updateConfigHost); InternalConfigRoot configRoot = new InternalConfigRoot(this, updateConfigHost); ((IInternalConfigRoot)configRoot).Init(implicitMachineConfigHost, isDesignTime: true); // Set the configuration paths for this Configuration. // // We do this in a separate step so that the WebConfigurationHost // can use this object's _configRoot to get the <sites> section, // which is used in it's MapPath implementation. string configPath, locationConfigPath; implicitMachineConfigHost.InitForConfiguration( ref locationSubPath, out configPath, out locationConfigPath, configRoot, hostInitConfigurationParams); if (!string.IsNullOrEmpty(locationSubPath) && !implicitMachineConfigHost.SupportsLocation) { throw ExceptionUtil.UnexpectedError("Configuration::ctor"); } if (string.IsNullOrEmpty(locationSubPath) != string.IsNullOrEmpty(locationConfigPath)) { throw ExceptionUtil.UnexpectedError("Configuration::ctor"); } // Get the configuration record for this config file. _configRecord = (MgmtConfigurationRecord)configRoot.GetConfigRecord(configPath); // Create another MgmtConfigurationRecord for the location that is a child of the above record. // Note that this does not match the resolution hiearchy that is used at runtime. if (!string.IsNullOrEmpty(locationSubPath)) { _configRecord = MgmtConfigurationRecord.Create( configRoot, _configRecord, locationConfigPath, locationSubPath); } // Throw if the config record we created contains global errors. _configRecord.ThrowIfInitErrors(); }
private ContextInformation _evalContext; // evaluation context internal Configuration(string locationSubPath, Type typeConfigHost, params object[] hostInitConfigurationParams) { _typeConfigHost = typeConfigHost; _hostInitConfigurationParams = hostInitConfigurationParams; _configRoot = new InternalConfigRoot(); IInternalConfigHost configHost = (IInternalConfigHost)TypeUtil.CreateInstanceWithReflectionPermission(typeConfigHost); // Wrap the host with the UpdateConfigHost to support SaveAs. IInternalConfigHost updateConfigHost = new UpdateConfigHost(configHost); _configRoot.Init(updateConfigHost, true); // // Set the configuration paths for this Configuration. // We do this in a separate step so that the WebConfigurationHost // can use this object's _configRoot to get the <sites> section, // which is used in it's MapPath implementation. // string configPath, locationConfigPath; configHost.InitForConfiguration(ref locationSubPath, out configPath, out locationConfigPath, _configRoot, hostInitConfigurationParams); if (!String.IsNullOrEmpty(locationSubPath) && !updateConfigHost.SupportsLocation) { throw ExceptionUtil.UnexpectedError("Configuration::ctor"); } if (String.IsNullOrEmpty(locationSubPath) != String.IsNullOrEmpty(locationConfigPath)) { throw ExceptionUtil.UnexpectedError("Configuration::ctor"); } // Get the configuration record for this config file. _configRecord = (MgmtConfigurationRecord)_configRoot.GetConfigRecord(configPath); // // Create another MgmtConfigurationRecord for the location that is a child of the above record. // Note that this does not match the resolution hiearchy that is used at runtime. // if (!String.IsNullOrEmpty(locationSubPath)) { _configRecord = MgmtConfigurationRecord.Create( _configRoot, _configRecord, locationConfigPath, locationSubPath); } // // Throw if the config record we created contains global errors. // _configRecord.ThrowIfInitErrors(); }
void IConfigSystem.Init(Type typeConfigHost, params object[] hostInitParams) { _configRoot = new InternalConfigRoot(); // Create the requested host and wrap in ImplicitMachineConfigHost so we can // stub in a simple machine.config if needed. IInternalConfigHost host = (IInternalConfigHost)TypeUtil.CreateInstance(typeConfigHost); _configHost = new ImplicitMachineConfigHost(host); _configRoot.Init(_configHost, isDesignTime: false); _configHost.Init(_configRoot, hostInitParams); }
void IInternalConfigRoot.Init(IInternalConfigHost host, bool isDesignTime) { _host = host; _isDesignTime = isDesignTime; _hierarchyLock = new ReaderWriterLock(); // Dummy record to hold _children for root if (_isDesignTime) { _rootConfigRecord = MgmtConfigurationRecord.Create(this, null, string.Empty, null); } else { _rootConfigRecord = (BaseConfigurationRecord) RuntimeConfigurationRecord.Create(this, null, string.Empty); } }
internal ClientConfigurationSystem() { IConfigSystem configSystem = new ConfigSystem(); configSystem.Init(typeof(ClientConfigurationHost), null, null); _configHost = configSystem.Host; _configRoot = configSystem.Root; _configRoot.ConfigRemoved += OnConfigRemoved; _isAppConfigHttp = ((IInternalConfigHostPaths)_configHost).IsAppConfigHttp; }
void IInternalConfigRoot.Init(IInternalConfigHost host, bool isDesignTime) { this._host = host; this._isDesignTime = isDesignTime; this._hierarchyLock = new ReaderWriterLock(); if (this._isDesignTime) { this._rootConfigRecord = MgmtConfigurationRecord.Create(this, null, string.Empty, null); } else { this._rootConfigRecord = (BaseConfigurationRecord)RuntimeConfigurationRecord.Create(this, null, string.Empty); } }
void IInternalConfigRoot.Init(IInternalConfigHost host, bool isDesignTime) { _host = host; _isDesignTime = isDesignTime; _hierarchyLock = new ReaderWriterLock(); // Dummy record to hold _children for root if (_isDesignTime) { _rootConfigRecord = MgmtConfigurationRecord.Create(this, null, string.Empty, null); } else { _rootConfigRecord = (BaseConfigurationRecord)RuntimeConfigurationRecord.Create(this, null, string.Empty); } }
// Ask the host to get the type specified by typeString. If it fails, try to retrieve it // as a type from System.dll. If that fails, return null or throw the original // exception as indicated by throwOnError. internal static Type GetType(IInternalConfigHost host, string typeString, bool throwOnError) { Type type; try { type = host.GetConfigType(typeString, throwOnError); } catch { type = GetImplicitType(typeString); if (type == null) { throw; } } return(type ?? GetImplicitType(typeString)); }
internal bool IsEquivalentSectionFactory( IInternalConfigHost host, string typeName, bool allowLocation, ConfigurationAllowDefinition allowDefinition, ConfigurationAllowExeDefinition allowExeDefinition, bool restartOnExternalChanges, bool requirePermission) { if ((allowLocation != AllowLocation) || (allowDefinition != AllowDefinition) || (allowExeDefinition != AllowExeDefinition) || (restartOnExternalChanges != RestartOnExternalChanges) || (requirePermission != RequirePermission)) { return(false); } return(IsEquivalentType(host, typeName)); }
internal bool IsEquivalentSectionFactory( IInternalConfigHost host, string typeName, bool allowLocation, ConfigurationAllowDefinition allowDefinition, ConfigurationAllowExeDefinition allowExeDefinition, bool restartOnExternalChanges, bool requirePermission) { if ( allowLocation != this.AllowLocation || allowDefinition != this.AllowDefinition || allowExeDefinition != this.AllowExeDefinition || restartOnExternalChanges != this.RestartOnExternalChanges || requirePermission != this.RequirePermission) { return false; } return IsEquivalentType(host, typeName); }
static internal Type GetTypeWithReflectionPermission(IInternalConfigHost host, string typeString, bool throwOnError) { Type type = null; Exception originalException = null; try { type = host.GetConfigType(typeString, throwOnError); } catch (Exception e) { originalException = e; } if (type == null) { type = GetLegacyType(typeString); if (type == null && originalException != null) { throw originalException; } } return type; }
/// <summary> /// Re-initializes the ConfigurationManager, allowing us to merge in the settings from Core.Config /// </summary> public static void Activate() { FieldInfo[] fiStateValues = null; Type tInitState = typeof(System.Configuration.ConfigurationManager).GetNestedType("InitState", BindingFlags.NonPublic); if (tInitState != null) { fiStateValues = tInitState.GetFields(); } FieldInfo fiInit = typeof(System.Configuration.ConfigurationManager).GetField("s_initState", BindingFlags.NonPublic | BindingFlags.Static); FieldInfo fiSystem = typeof(System.Configuration.ConfigurationManager).GetField("s_configSystem", BindingFlags.NonPublic | BindingFlags.Static); if (fiInit != null && fiSystem != null && fiStateValues != null) { var state = fiStateValues[1].GetValue(null); fiInit.SetValue(null, state); fiSystem.SetValue(null, null); } ConfigSystemProxy confSys = new ConfigSystemProxy(); Type configFactoryType = Type.GetType("System.Configuration.Internal.InternalConfigSettingsFactory, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", true); IInternalConfigSettingsFactory configSettingsFactory = (IInternalConfigSettingsFactory)Activator.CreateInstance(configFactoryType, true); configSettingsFactory.SetConfigurationSystem(confSys, false); Type clientConfigSystemType = Type.GetType("System.Configuration.ClientConfigurationSystem, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", true); _clientConfigSystem = (IInternalConfigSystem)Activator.CreateInstance(clientConfigSystemType, true); // Fetch configHost FieldInfo fiClientHost = clientConfigSystemType.GetField("_configHost", BindingFlags.NonPublic | BindingFlags.Instance); _internalConfigClientHost = (IInternalConfigClientHost) fiClientHost?.GetValue(_clientConfigSystem); FieldInfo fiConfigHost = typeof(DelegatingConfigHost).GetField("_host", BindingFlags.NonPublic | BindingFlags.Instance); _internalConfigHost = (IInternalConfigHost)fiConfigHost?.GetValue(_internalConfigClientHost); // Set custom configHost var configHost = new LuxConfigHost(_internalConfigHost); fiConfigHost.SetValue(_internalConfigClientHost, configHost); }
internal bool IsEquivalentType(IInternalConfigHost host, string typeName) { try { if (_factoryTypeName == typeName) return true; Type t1, t2; if (host != null) { t1 = TypeUtil.GetTypeWithReflectionPermission(host, typeName, false); t2 = TypeUtil.GetTypeWithReflectionPermission(host, _factoryTypeName, false); } else { t1 = TypeUtil.GetTypeWithReflectionPermission(typeName, false); t2 = TypeUtil.GetTypeWithReflectionPermission(_factoryTypeName, false); } return (t1 != null) && (t1 == t2); } catch { } return false; }
internal static Type GetTypeWithReflectionPermission(IInternalConfigHost host, string typeString, bool throwOnError) { Type configType = null; Exception exception = null; try { configType = host.GetConfigType(typeString, throwOnError); } catch (Exception exception2) { exception = exception2; } if (configType == null) { configType = GetLegacyType(typeString); if ((configType == null) && (exception != null)) { throw exception; } } return(configType); }
// // Ask the host to get the type specified by typeString. If it fails, try to retrieve it // as a type from System.dll. If that fails, return null or throw the original // exception as indicated by throwOnError. // static internal Type GetTypeWithReflectionPermission(IInternalConfigHost host, string typeString, bool throwOnError) { Type type = null; Exception originalException = null; try { type = host.GetConfigType(typeString, throwOnError); } catch (Exception e) { originalException = e; } if (type == null) { type = GetLegacyType(typeString); if (type == null && originalException != null) { throw originalException; } } return(type); }
internal bool IsEquivalentType(IInternalConfigHost host, string typeName) { try { Type typeWithReflectionPermission; Type type2; if (this._factoryTypeName == typeName) { return true; } if (host != null) { typeWithReflectionPermission = System.Configuration.TypeUtil.GetTypeWithReflectionPermission(host, typeName, false); type2 = System.Configuration.TypeUtil.GetTypeWithReflectionPermission(host, this._factoryTypeName, false); } else { typeWithReflectionPermission = System.Configuration.TypeUtil.GetTypeWithReflectionPermission(typeName, false); type2 = System.Configuration.TypeUtil.GetTypeWithReflectionPermission(this._factoryTypeName, false); } return ((typeWithReflectionPermission != null) && (typeWithReflectionPermission == type2)); } catch { } return false; }
internal ImplicitMachineConfigHost(IInternalConfigHost host) { // Delegate to the host provided. Host = host; }
internal bool IsEquivalentSectionFactory(IInternalConfigHost host, string typeName, bool allowLocation, ConfigurationAllowDefinition allowDefinition, ConfigurationAllowExeDefinition allowExeDefinition, bool restartOnExternalChanges, bool requirePermission) { return((((allowLocation == this.AllowLocation) && (allowDefinition == this.AllowDefinition)) && (((allowExeDefinition == this.AllowExeDefinition) && (restartOnExternalChanges == this.RestartOnExternalChanges)) && (requirePermission == this.RequirePermission))) && this.IsEquivalentType(host, typeName)); }
internal bool IsEquivalentSectionFactory(IInternalConfigHost host, string typeName, bool allowLocation, ConfigurationAllowDefinition allowDefinition, ConfigurationAllowExeDefinition allowExeDefinition, bool restartOnExternalChanges, bool requirePermission) { return ((((allowLocation == this.AllowLocation) && (allowDefinition == this.AllowDefinition)) && (((allowExeDefinition == this.AllowExeDefinition) && (restartOnExternalChanges == this.RestartOnExternalChanges)) && (requirePermission == this.RequirePermission))) && this.IsEquivalentType(host, typeName)); }
public void Init(IInternalConfigHost host, bool isDesignTime) { this.host = host; this.isDesignTime = isDesignTime; }
public void Init(IInternalConfigHost host, bool isDesignTime) { originalRoot.Init(host, isDesignTime); }
private HybridDictionary _streams; // oldStreamname -> StreamUpdate internal UpdateConfigHost(IInternalConfigHost host) { // Delegate to the host provided. Host = host; }
internal UpdateConfigHost(IInternalConfigHost host) { base.Host = host; }
internal bool IsEquivalentSectionGroupFactory(IInternalConfigHost host, string typeName) { if ((typeName != null) && (this._factoryTypeName != null)) { return this.IsEquivalentType(host, typeName); } return true; }
internal bool IsEquivalentSectionGroupFactory(IInternalConfigHost host, string typeName) { if (typeName == null || _factoryTypeName == null) return true; return IsEquivalentType(host, typeName); }
public void Init (IInternalConfigHost host, bool isDesignTime) { this.host = host; this.isDesignTime = isDesignTime; }