Esempio n. 1
0
        private ProtectedConfigurationProvider CreateAndInitializeProviderWithAssert(Type t, ProviderSettings pn)
        {
            ProtectedConfigurationProvider provider   = (ProtectedConfigurationProvider)System.Configuration.TypeUtil.CreateInstanceWithReflectionPermission(t);
            NameValueCollection            parameters = pn.Parameters;
            NameValueCollection            config     = new NameValueCollection(parameters.Count);

            foreach (string str in parameters)
            {
                config[str] = parameters[str];
            }
            provider.Initialize(pn.Name, config);
            return(provider);
        }
        ProtectedConfigurationProvider InstantiateProvider(ProviderSettings ps)
        {
            Type t = Type.GetType(ps.Type, true);
            ProtectedConfigurationProvider prov = Activator.CreateInstance(t) as ProtectedConfigurationProvider;

            if (prov == null)
            {
                throw new Exception("The type specified does not extend ProtectedConfigurationProvider class.");
            }

            prov.Initialize(ps.Name, ps.Parameters);

            return(prov);
        }
        private ProtectedConfigurationProvider CreateAndInitializeProviderWithAssert(Type t, ProviderSettings pn)
        {
            ProtectedConfigurationProvider provider =
                (ProtectedConfigurationProvider)TypeUtil.CreateInstance(t);
            NameValueCollection pars        = pn.Parameters;
            NameValueCollection cloneParams = new NameValueCollection(pars.Count);

            foreach (string key in pars)
            {
                cloneParams[key] = pars[key];
            }

            provider.Initialize(pn.Name, cloneParams);
            return(provider);
        }