private void Init(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord) { // Get the type of the factory Type type = TypeUtil.GetType(configRecord.Host, factoryRecord.FactoryTypeName, true); // If the type is a ConfigurationSection, that's the type. if (typeof(ConfigurationSection).IsAssignableFrom(type)) { _sectionCtor = TypeUtil.GetConstructor(type, typeof(ConfigurationSection), true); } else { // Note: in v1, IConfigurationSectionHandler is in effect a factory that has a Create method // that creates the real section object. // throws if type does not implement IConfigurationSectionHandler TypeUtil.VerifyAssignableType(typeof(IConfigurationSectionHandler), type, true); // Create an instance of the handler _sectionHandler = (IConfigurationSectionHandler)TypeUtil.CreateInstance(type); } }
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); }
public override object ConvertFrom(ITypeDescriptorContext ctx, CultureInfo ci, object data) { Type result = TypeUtil.GetType((string)data, false); if (result == null) { throw new ArgumentException(string.Format(SR.Type_cannot_be_resolved, (string)data)); } return(result); }
private ProtectedConfigurationProvider InstantiateProvider(ProviderSettings pn) { Type t = TypeUtil.GetType(pn.Type, true); if (!typeof(ProtectedConfigurationProvider).IsAssignableFrom(t)) { throw new Exception(SR.WrongType_of_Protected_provider); } return(CreateAndInitializeProviderWithAssert(t, pn)); }