コード例 #1
0
        public static void InstantiateProviders(ProviderSettingsCollection configProviders, ProviderCollection providers, Type providerType)
        {
            if (!typeof(ProviderBase).IsAssignableFrom(providerType))
            {
                throw new ConfigurationErrorsException(String.Format("type '{0}' must subclass from ProviderBase", providerType));
            }

            foreach (ProviderSettings settings in configProviders)
            {
                providers.Add(InstantiateProvider(settings, providerType));
            }
        }
コード例 #2
0
        private static void GetProviderSettings()
        {
            // Get the application configuration file.
            System.Configuration.Configuration config =
                ConfigurationManager.OpenExeConfiguration(
                    ConfigurationUserLevel.None);

            ProtectedConfigurationSection pSection =
                config.GetSection("configProtectedData")
                as ProtectedConfigurationSection;

            ProviderSettingsCollection providerSettings =
                pSection.Providers;

            foreach (ProviderSettings pSettings in
                     providerSettings)
            {
                // <Snippet2>

                Console.WriteLine(
                    "Provider settings name: {0}",
                    pSettings.Name);

                // </Snippet2>

                // <Snippet3>
                Console.WriteLine(
                    "Provider settings type: {0}",
                    pSettings.Type);
                // </Snippet3>

                // <Snippet4>
                NameValueCollection parameters =
                    pSettings.Parameters;

                IEnumerator pEnum =
                    parameters.GetEnumerator();

                int i = 0;
                while (pEnum.MoveNext())
                {
                    string pLength =
                        parameters[i].Length.ToString();
                    Console.WriteLine(
                        "Provider ssettings: {0} has {1} parameters",
                        pSettings.Name, pLength);
                }
                // </Snippet4>
            }
        }
コード例 #3
0
        internal OutputCacheProviderCollection CreateProviderCollection()
        {
            ProviderSettingsCollection configProviders = this.Providers;

            if ((configProviders == null) || (configProviders.Count == 0))
            {
                return(null);
            }
            OutputCacheProviderCollection providers = new OutputCacheProviderCollection();

            ProvidersHelper.InstantiateProviders(configProviders, providers, typeof(OutputCacheProvider));
            providers.SetReadOnly();
            return(providers);
        }
コード例 #4
0
        public void InstantiateProviders()
        {
            ProviderSettingsCollection providerSettingsCollection = new ProviderSettingsCollection();

            providerSettingsCollection.Add(new ProviderSettings("Custom", "Remotion.UnitTests::Configuration.FakeProvider"));
            ProviderCollection providerCollection = new ProviderCollection();

            _providerHelper.InstantiateProviders(providerSettingsCollection, providerCollection, typeof(FakeProviderBase), typeof(IFakeProvider));

            Assert.That(providerCollection.Count, Is.EqualTo(1));
            ProviderBase providerBase = providerCollection["Custom"];

            Assert.IsInstanceOf(typeof(FakeProvider), providerBase);
            Assert.That(providerBase.Name, Is.EqualTo("Custom"));
        }
コード例 #5
0
        internal OutputCacheProviderCollection CreateProviderCollection()
        {
            // if there are no providers defined, we'll default to the v2.0 OutputCache
            ProviderSettingsCollection providers = Providers;

            if (providers == null || providers.Count == 0)
            {
                return(null);
            }
            OutputCacheProviderCollection collection = new OutputCacheProviderCollection();

            ProvidersHelper.InstantiateProviders(providers, collection, typeof(OutputCacheProvider));
            collection.SetReadOnly();
            return(collection);
        }
コード例 #6
0
        public void TestInitialize()
        {
            base.Initialize();

            HttpContext.Current = (new MockHttpContext(false)).Context;
            HttpContext.Current.Session["org"] = "sugarcreek";

            _provider = new LiftMembershipProvider();

            MembershipSection          section          = (MembershipSection)ConfigurationManager.GetSection("system.web/membership");
            ProviderSettingsCollection settings         = section.Providers;
            NameValueCollection        membershipParams = settings[section.DefaultProvider].Parameters;

            _provider.Initialize(section.DefaultProvider, membershipParams);
        }
コード例 #7
0
        public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)
        {
            if (config == null)
            {
                string                     configPath      = "~/web.config";
                Configuration              newConfig       = WebConfigurationManager.OpenWebConfiguration(configPath);
                MembershipSection          mbershipSection = (MembershipSection)newConfig.GetSection("system.web/membership");
                ProviderSettingsCollection setting         = mbershipSection.Providers;
                NameValueCollection        mbershipParams  = setting[mbershipSection.DefaultProvider].Parameters;
                config = mbershipParams;
            }
            if (string.IsNullOrEmpty(name))
            {
                name = "CustomMembershipProvider";
            }

            base.Initialize(name, config);
        }
コード例 #8
0
        static void Main(string[] args)
        {
            ServiceJobSection          jobSection    = (ServiceJobSection)ConfigurationManager.GetSection("ServiceJobSection");
            ServiceJobInfoCollection   JobCollection = jobSection.JobCollection;
            ProviderSettingsCollection jobProviders  = (ProviderSettingsCollection)jobSection.JobProviders;

            for (int i = 0; i < JobCollection.Count; i++)
            {
                ProviderSettings   providerSetting = jobProviders[JobCollection[i].Provider];
                ServiceJobProvider provider        = (ServiceJobProvider)ProvidersHelper.InstantiateProvider(providerSetting, typeof(ServiceJobProvider));

                if (!JobProviders.Contains(JobCollection[i].JobName))
                {
                    provider.JobInfo = JobCollection[i];
                    JobProviders.Add(JobCollection[i].JobName, provider);
                }
            }
            JobDetect();
        }
コード例 #9
0
        /// <summary>
        ///     Initializes a new instance of the
        ///     <see cref="GridDefaults" /> class.
        /// </summary>
        /// TODO Edit XML Comment Template for #ctor
        public GridDefaults()
        {
            PreloadData           = true;
            QueryOnPageLoad       = true;
            Paging                = false;
            ItemsPerPage          = 20;
            Sorting               = false;
            DefaultSortColumn     = null;
            DefaultSortDirection  = SortDirection.Unspecified;
            NoResultsMessage      = "No results.";
            NextButtonCaption     = "Next";
            PreviousButtonCaption = "Previous";
            SummaryMessage        = "Showing {0} to {1} of {2} entries";
            ProcessingMessage     = "Processing";
            ClientSideLoadingMessageFunctionName  = null;
            ClientSideLoadingCompleteFunctionName = null;
            Filtering          = false;
            TemplatingEngine   = typeof(SimpleTemplatingEngine);
            AdditionalSettings = new Dictionary <string, object>();
            RenderingMode      = RenderingMode.RenderingEngine;
            ViewPath           = "~/Views/MVCGrid/_Grid.cshtml";
            ContainerViewPath  = null;
            ErrorMessageHtml   =
                @"<div class=""alert alert-warning"" role=""alert"">There was a problem loading the grid.</div>";
            AdditionalQueryOptionNames = new HashSet <string>();
            PageParameterNames         = new HashSet <string>();
            AllowChangingPageSize      = false;
            MaxItemsPerPage            = null;
            AuthorizationType          = AuthorizationType.AllowAnonymous;

            RenderingEngines = new ProviderSettingsCollection
            {
                new ProviderSettings(
                    "BootstrapRenderingEngine",
                    "MichaelBrandonMorris.MvcGrid.Rendering.BootstrapRenderingEngine, MichaelBrandonMorris.MvcGrid"),
                new ProviderSettings(
                    "Export",
                    "MichaelBrandonMorris.MvcGrid.Rendering.CsvRenderingEngine, MichaelBrandonMorris.MvcGrid")
            };

            DefaultRenderingEngineName = "BootstrapRenderingEngine";
        }
コード例 #10
0
        // intentionally hide base implmentation
        public static void InstantiateProviders(ProviderSettingsCollection pProviderSettings, ProviderCollection pProviders, Type pType)
        {
            myLogger.Debug("InstantiateProviders - entry");
            try
            {
                foreach (ProviderSettings settings in pProviderSettings)
                {
                    myLogger.Debug("Adding - adding provider");
                    pProviders.Add(ADSProviderManager.InstantiateProvider(settings, pType));
                    myLogger.Debug("InstantiateProviders - added provider");
                }
            }
            catch (Exception ex)
            {
                myLogger.Debug("InstantiateProviders caught exception - " + ex.Message);
                throw;
            }

            myLogger.Debug("InstantiateProviders - exit");
        }
コード例 #11
0
    /// <summary>
    // validate the provider section
    /// </summary>
    public override void Validate(object value)
    {
        ProviderSettingsCollection providerCollection = value as ProviderSettingsCollection;

        if (providerCollection != null)
        {
            foreach (ProviderSettings _provider in providerCollection)
            {
                if (String.IsNullOrEmpty(_provider.Type))
                {
                    throw new ConfigurationErrorsException("Type was not defined in the provider");
                }

                Type dataAccessType = Type.GetType(_provider.Type);
                if (dataAccessType == null)
                {
                    throw (new InvalidOperationException("Provider's Type could not be found"));
                }
            }
        }
    }
コード例 #12
0
        void ProcessRemove(MembershipSection section, SettingsMappingWhatContents how)
        {
            string name, type;

            if (!GetCommonAttributes(how, out name, out type))
            {
                return;
            }

            ProviderSettingsCollection providers = section.Providers;
            ProviderSettings           provider  = providers [name];

            if (provider != null)
            {
                if (provider.Type != type)
                {
                    return;
                }
                providers.Remove(name);
            }
        }
コード例 #13
0
        public GridDefaults()
        {
            PreloadData          = true;
            QueryOnPageLoad      = true;
            Paging               = false;
            ItemsPerPage         = 20;
            Sorting              = false;
            DefaultSortColumn    = null;
            DefaultSortDirection = SortDirection.Unspecified;
            NoResultsMessage     = "No results.";
            ClientSideLoadingMessageFunctionName  = null;
            ClientSideLoadingCompleteFunctionName = null;
            Filtering = false;
            //RenderingEngine = typeof(MVCGrid.Rendering.BootstrapRenderingEngine);
            TemplatingEngine                = typeof(MVCGrid.Templating.SimpleTemplatingEngine);
            AdditionalSettings              = new Dictionary <string, object>();
            RenderingMode                   = Models.RenderingMode.RenderingEngine;
            ViewPath                        = "~/Views/MVCGrid/_Grid.cshtml";
            ContainerViewPath               = null;
            ErrorMessageHtml                = @"<div class=""alert alert-warning"" role=""alert"">There was a problem loading the grid.</div>";
            AdditionalQueryOptionNames      = new HashSet <string>();
            PageParameterNames              = new HashSet <string>();
            AllowChangingPageSize           = false;
            MaxItemsPerPage                 = null;
            AuthorizationType               = Models.AuthorizationType.AllowAnonymous;
            BrowserNavigationMode           = Models.BrowserNavigationMode.PreserveAllGridActions;
            PersistLastState                = false;
            SpinnerEnabled                  = true;
            SpinnerRadius                   = 15;
            EnableRowSelect                 = false;
            ClientSideRowSelectFunctionName = null;
            ClientSideRowSelectProperties   = new List <string>();

            RenderingEngines = new ProviderSettingsCollection();
            RenderingEngines.Add(new ProviderSettings("BootstrapRenderingEngine", "MVCGrid.Rendering.BootstrapRenderingEngine, MVCGrid"));
            RenderingEngines.Add(new ProviderSettings("BootstrapVerticalRenderingEngine", "MVCGrid.Rendering.BootstrapVerticalRenderingEngine, MVCGrid"));
            RenderingEngines.Add(new ProviderSettings("Export", "MVCGrid.Rendering.CsvRenderingEngine, MVCGrid"));
            DefaultRenderingEngineName = "BootstrapRenderingEngine";
        }
コード例 #14
0
        /// <summary>
        /// Reads the configuration related to the set of configured
        /// providers and sets the default and collection of providers and settings.
        /// </summary>
        private static void Initialize()
        {
            DataAccessProviderConfiguration configSection = (DataAccessProviderConfiguration)ConfigurationManager.GetSection("DataAccessProviders");

            if (configSection == null)
            {
                throw new ConfigurationErrorsException("Data provider section is not set.");
            }

            _providerCollection = new DataAccessProviderCollection();
            ProvidersHelper.InstantiateProviders(configSection.Providers, _providerCollection, typeof(DataAccessProvider));

            _providerSettings = configSection.Providers;

            if (_providerCollection[configSection.DefaultProviderName] == null)
            {
                throw new ConfigurationErrorsException("Default data provider is not set.");
            }

            _default = _providerCollection[configSection.DefaultProviderName];
            var defaultSettings = _providerSettings[configSection.DefaultProviderName];

            _default.SetParameters(defaultSettings.Parameters);

            // set other providers's parameters
            for (int i = 0; i < _providerSettings.Count; ++i)
            {
                var providerName = _providerSettings[i].Name;

                if (providerName != configSection.DefaultProviderName)
                {
                    var curProvider         = _providerCollection[providerName];
                    var curProviderSettings = _providerSettings[i];

                    curProvider.SetParameters(curProviderSettings.Parameters);
                }
            }
        }
コード例 #15
0
        void ProcessAdd(MembershipSection section, SettingsMappingWhatContents how)
        {
            string name, type;

            if (!GetCommonAttributes(how, out name, out type))
            {
                return;
            }

            ProviderSettingsCollection providers = section.Providers;
            ProviderSettings           provider  = providers [name];

            if (provider != null)
            {
                return;
            }

            ProviderSettings prov = new ProviderSettings(name, type);

            SetProviderProperties(how, prov);

            providers.Add(prov);
        }
コード例 #16
0
ファイル: Service.cs プロジェクト: sanlonezhang/ql
        protected override void OnStart(string[] args)
        {
            ServiceJobSection          jobSection    = (ServiceJobSection)ConfigurationManager.GetSection("ServiceJobSection");
            ServiceJobInfoCollection   JobCollection = jobSection.JobCollection;
            ProviderSettingsCollection jobProviders  = (ProviderSettingsCollection)jobSection.JobProviders;

            for (int i = 0; i < JobCollection.Count; i++)
            {
                ProviderSettings   providerSetting = jobProviders[JobCollection[i].Provider];
                ServiceJobProvider provider        = (ServiceJobProvider)ProvidersHelper.InstantiateProvider(providerSetting, typeof(ServiceJobProvider));

                if (!JobProviders.Contains(JobCollection[i].JobName))
                {
                    provider.JobInfo = JobCollection[i];
                    JobProviders.Add(JobCollection[i].JobName, provider);
                }
            }

            Thread threadJobDetect = new Thread(new ThreadStart(this.JobDetect));

            threadJobDetect.Start();

            Log.WriteLog(Resources.ServiceStarted, "Log\\ServiceInfo.txt", true);
        }
コード例 #17
0
        private static void InstantiateProviders(ProviderSettingsCollection configProviders, ProviderCollection providers, Type providerType)
        {
            foreach (ProviderSettings configProvider in configProviders)
            {
                Type type = Type.GetType(configProvider.Type, true, true);
                if (!typeof(Resources.ResourceProvider).IsAssignableFrom(type))
                {
                    throw new ArgumentException(String.Format(CultureInfo.CurrentCulture,
                                                              Hasseware.Properties.Resources.Provider_must_implement_type, typeof(Resources.ResourceProvider)));
                }

                var resourceProvider = (Resources.ResourceProvider)Activator.CreateInstance(type);

                NameValueCollection parameters          = configProvider.Parameters;
                NameValueCollection nameValueCollection = new NameValueCollection(parameters.Count, StringComparer.Ordinal);

                foreach (string parameter in parameters)
                {
                    nameValueCollection[parameter] = parameters[parameter];
                }
                resourceProvider.Initialize(configProvider.Name, nameValueCollection);
                providers.Add(resourceProvider);
            }
        }
コード例 #18
0
        private static void EnsureProviders()
        {
            if (!initialized)
            {
                VerificationCodeSection section = (VerificationCodeSection)WebConfigurationManager.GetSection("spbVerificationCode/autoInputProtection");
                bool hasSection = section != null;

                if (!hasSection)
                {
                    section = new VerificationCodeSection();
                }

                //userMode = section.UserMode;
                PersistenceMode = section.PersistenceMode;

                InitializeTextProviders(hasSection, section);
                InitializeImageProviders(hasSection, section);

                ProviderSettingsCollection pc = new ProviderSettingsCollection();
                pc.Add(new ProviderSettings("filters", "Spacebuilder.Common.CrosshatchVerificationCodeFilterProvider,Spacebuilder.Common"));
                ProvidersHelper.InstantiateProviders(pc, filterProviders, typeof(VerificationCodeFilterProvider));
                initialized = true;
            }
        }
コード例 #19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:PaymentServiceSettings"/> class.
 /// </summary>
 public PaymentServiceSettings()
 {
     _providerSettingsCollection = new ProviderSettingsCollection();
 }
コード例 #20
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:TaxServiceSettings"/> class.
 /// </summary>
 public TaxServiceSettings()
 {
     _providerSettingsCollection = new ProviderSettingsCollection();
 }
コード例 #21
0
 public ResourceProviderSection()
 {
     base[ProvidersElementName] = new ProviderSettingsCollection();
 }
 public ProtectedConfigurationSection(ConfigurationSection section)
 {
     DefaultProvider = (string)section["defaultProvider"];
     Providers       = new ProviderSettingsCollection(section.GetCollection("providers"));
 }
コード例 #23
0
        public override void Initialize(string name, NameValueCollection config)
        {
            if (config == null)
            {
                string                     configPath       = "~/web.config";
                Configuration              NexConfig        = WebConfigurationManager.OpenWebConfiguration(configPath);
                MembershipSection          section          = (MembershipSection)NexConfig.GetSection("system.web/membership");
                ProviderSettingsCollection settings         = section.Providers;
                NameValueCollection        membershipParams = settings[section.DefaultProvider].Parameters;
                config = membershipParams;
            }

            if (name == null || name.Length == 0)
            {
                name = "CadeMeuMedicoMembershipProvider";
            }

            if (String.IsNullOrEmpty(config["description"]))
            {
                config.Remove("description");
                config.Add("description", "Cadê Meu Médico Membership Provider");
            }

            base.Initialize(name, config);
            applicationName                      = GetConfigValue(config["applicationName"], System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath);
            maxInvalidPasswordAttempts           = Convert.ToInt32(GetConfigValue(config["maxInvalidPasswordAttempts"], "5"));
            passwordAttemptWindow                = Convert.ToInt32(GetConfigValue(config["passwordAttemptWindow"], "10"));
            minRequiredNonAlphanumericCharacters = Convert.ToInt32(GetConfigValue(config["minRequiredAlphaNumericCharacters"], "1"));
            minRequiredPasswordLength            = Convert.ToInt32(GetConfigValue(config["minRequiredPasswordLength"], "7"));
            passwordStrengthRegularExpression    = Convert.ToString(GetConfigValue(config["passwordStrengthRegularExpression"], String.Empty));
            enablePasswordReset                  = Convert.ToBoolean(GetConfigValue(config["enablePasswordReset"], "true"));
            enablePasswordRetrieval              = Convert.ToBoolean(GetConfigValue(config["enablePasswordRetrieval"], "true"));
            requiresQuestionAndAnswer            = Convert.ToBoolean(GetConfigValue(config["requiresQuestionAndAnswer"], "false"));
            requiresUniqueEmail                  = Convert.ToBoolean(GetConfigValue(config["requiresUniqueEmail"], "true"));

            string temp_format = config["passwordFormat"];

            if (temp_format == null)
            {
                temp_format = "Hashed";
            }

            switch (temp_format)
            {
            case "Hashed":
                passwordFormat = MembershipPasswordFormat.Hashed;
                break;

            case "Encrypted":
                passwordFormat = MembershipPasswordFormat.Encrypted;
                break;

            case "Clear":
                passwordFormat = MembershipPasswordFormat.Clear;
                break;

            default:
                throw new ProviderException("Formato de senha não suportado.");
            }
            ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings[config["connectionStringName"]];

            if ((connectionStringSettings == null) || (connectionStringSettings.ConnectionString.Trim() == String.Empty))
            {
                throw new ProviderException("Connection String não pode estar vázia");
            }

            connectionString = connectionStringSettings.ConnectionString;
            System.Configuration.Configuration cfg = WebConfigurationManager.OpenWebConfiguration(System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath);
            machineKey = cfg.GetSection("system.web/machineKey") as MachineKeySection;

            if (machineKey.ValidationKey.Contains("AutoGenerate"))
            {
                if (PasswordFormat != MembershipPasswordFormat.Clear)
                {
                    throw new ProviderException("Senhas Hashed ou Encrypted não são suportadas com chaves auto geradas.");
                }
            }
        }
コード例 #24
0
ファイル: main.cs プロジェクト: staherianYMCA/test
        static void Main(string[] args)
        {
            string tmpString;

            tmpString = ConfigurationManager.AppSettings["AppSettings1"]; // "AppSettings1Value"
            tmpString = ConfigurationManager.AppSettings["AppSettings2"]; // "AppSettings2Value"
            tmpString = ConfigurationManager.AppSettings["AppSettings3"]; // null

            FileExtension fileExtensionsSection;

            if ((fileExtensionsSection = ConfigurationManager.GetSection(FileExtension.SectionName) as FileExtension) != null)
            {
                foreach (ItemElement item in fileExtensionsSection.Items)
                {
                    Console.WriteLine("{{value=\"{0}\"}}", item.Value);
                }
            }

            var querySection = ConfigurationManager.GetSection(QuerySection.SectionName) as QuerySection;

            if (querySection != null)
            {
                Console.WriteLine("statement=\"{0}\", attributeBool=\"{1}\"", querySection.Query.Statement, querySection.Query.AttributeBool);

                foreach (ClauseElement clause in querySection.Clauses)
                {
                    Console.WriteLine($"{{ name=\"{clause.Name}\", condition=\"{clause.Condition}\", type=\"{clause.Type}\", operator=\"{clause.Operator}\", boolRequired={clause.BoolRequired}, BoolOptionalTrue={clause.BoolOptionalTrue}, BoolOptionalFalse={clause.BoolOptionalFalse}}}");
                }

                ClauseElement
                    clauseName1 = querySection.Clauses.OfType <ClauseElement>().FirstOrDefault(item => item.Name == "name1") /*,
                                                                                                                              * clauseName2 = querySection.Clauses.Item["Name2"]*/;
            }

            const string
                connectionStringKey = "chicago";

            string
                connectionString = string.Empty;

            if (ConfigurationManager.ConnectionStrings.OfType <ConnectionStringSettings>().Any(cs => cs.Name == connectionStringKey))
            {
                connectionString = ConfigurationManager.ConnectionStrings[connectionStringKey].ConnectionString;
            }
            Console.WriteLine(connectionString);

            MyConfigurationSection
                siteWebSection = (MyConfigurationSection)System.Configuration.ConfigurationManager.GetSection(MyConfigurationSection.SectionName);

            Console.WriteLine(siteWebSection.Url);

            MyConfigurationElementGroupsContainerSection
                unityContainerSection = (MyConfigurationElementGroupsContainerSection)System.Configuration.ConfigurationManager.GetSection(MyConfigurationElementGroupsContainerSection.SectionName);

            MyConfigurationElementCollection
                unityContainerKnownGroupElementCollection = unityContainerSection.KnownGroups;

            foreach (MyConfigurationElement e in unityContainerKnownGroupElementCollection)
            {
                Console.WriteLine(e.Name);
            }

            MyConfigurationSectionWithProviders
                extensionSection = (MyConfigurationSectionWithProviders)System.Configuration.ConfigurationManager.GetSection(MyConfigurationSectionWithProviders.SectionName);

            ProviderSettingsCollection
                providerSettingsCollection = extensionSection.Providers;

            foreach (ProviderSettings ps in providerSettingsCollection)
            {
                Console.WriteLine(ps.Name);
            }

            Console.ReadLine();
        }
コード例 #25
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:PaymentServiceSettings"/> class.
 /// </summary>
 public PaymentServiceSettings()
 {
     _providerSettingsCollection = new ProviderSettingsCollection();
 }
コード例 #26
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:ShippingServiceSettings"/> class.
 /// </summary>
 public ShippingServiceSettings()
 {
     _providerSettingsCollection = new ProviderSettingsCollection();
 }
コード例 #27
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:TaxServiceSettings"/> class.
 /// </summary>
 public TaxServiceSettings()
 {
     _providerSettingsCollection = new ProviderSettingsCollection();
 }
 public ProtectedConfigurationSection(ConfigurationSection section)
 {
     DefaultProvider = (string)section["defaultProvider"];
     Providers = new ProviderSettingsCollection(section.GetCollection("providers"));
 }
コード例 #29
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:ShippingServiceSettings"/> class.
 /// </summary>
 public ShippingServiceSettings()
 {
     _providerSettingsCollection = new ProviderSettingsCollection();
 }
コード例 #30
0
        public override void ProjectFinishedGenerating(Project project)
        {
            if (project != null)
            {
                VSProject vsProj = project.Object as VSProject;
                var       tables = new List <string>();

                Settings.Default.MVCWizardConnection = WizardForm.ServerExplorerConnectionSelected;
                Settings.Default.Save();

                if (_generalPane != null)
                {
                    _generalPane.Activate();
                }

                SendToGeneralOutputWindow("Starting project generation...");

                //Updating project references
                try
                {
                    vsProj.References.Add("MySql.Data");
                }
                catch
                {
                    var infoResult = InfoDialog.ShowDialog(
                        InfoDialogProperties.GetOkCancelDialogProperties(
                            InfoDialog.InfoType.Warning,
                            Resources.MySqlDataProviderPackage_ConnectorNetNotFoundError,
                            @"To use it you must download and install the MySQL Connector/Net package from http://dev.mysql.com/downloads/connector/net/",
                            Resources.MySqlDataProviderPackage_ClickOkOrCancel));
                    if (infoResult.DialogResult == DialogResult.OK)
                    {
                        ProcessStartInfo browserInfo = new ProcessStartInfo("http://dev.mysql.com/downloads/connector/net/");
                        System.Diagnostics.Process.Start(browserInfo);
                    }
                }

                double version = double.Parse(WizardForm.Wizard.GetVisualStudioVersion());
                if (version >= 12.0)
                {
                    References refs = vsProj.References;
                    foreach (Reference item in refs)
                    {
                        switch (item.Name)
                        {
                        case "System.Web.Razor":
                            if (item.Version.Equals("1.0.0.0"))
                            {
                                vsProj.References.Find("System.Web.Razor").Remove();
                            }
                            break;

                        case "System.Web.WebPages":
                            vsProj.References.Find("System.Web.WebPages").Remove();
                            break;

                        case "System.Web.Mvc":
                            vsProj.References.Find("System.Web.Mvc").Remove();
                            break;

                        case "System.Web.Helpers":
                            vsProj.References.Find("System.Web.Helpers").Remove();
                            break;
                        }
                    }

                    vsProj.References.Add("System.Web.WebPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL");
                    vsProj.References.Add("System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL");
                    vsProj.References.Add("System.Web.Helpers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL");
                    vsProj.References.Add("System.Web.Razor");

#if NET_40_OR_GREATER
                    vsProj.Project.Save();
#endif
                }
                AddNugetPackage(vsProj, JQUERY_PKG_NAME, JQUERY_VERSION, false);
                var packagesPath = Path.Combine(Path.GetDirectoryName(ProjectPath), @"Packages\jQuery." + JQUERY_VERSION + @"\Content\Scripts");
                CopyPackageToProject(vsProj, ProjectPath, packagesPath, "Scripts");

                if (WizardForm.SelectedTables != null && WizardForm.DEVersion != DataEntityVersion.None)
                {
                    WizardForm.SelectedTables.ForEach(t => tables.Add(t.Name));

                    SendToGeneralOutputWindow("Generating Entity Framework model...");
                    if (tables.Count > 0)
                    {
                        if (WizardForm.DEVersion == DataEntityVersion.EntityFramework5)
                        {
                            CurrentEntityFrameworkVersion = ENTITY_FRAMEWORK_VERSION_5;
                        }
                        else if (WizardForm.DEVersion == DataEntityVersion.EntityFramework6)
                        {
                            CurrentEntityFrameworkVersion = ENTITY_FRAMEWORK_VERSION_6;
                        }

                        AddNugetPackage(vsProj, ENTITY_FRAMEWORK_PCK_NAME, CurrentEntityFrameworkVersion, true);
                        string modelPath = Path.Combine(ProjectPath, "Models");
                        GenerateEntityFrameworkModel(project, vsProj, new MySqlConnection(WizardForm.ConnectionStringForModel), WizardForm.ModelName, tables, modelPath);
                        GenerateMVCItems(vsProj);

                        if (WizardForm.DEVersion == DataEntityVersion.EntityFramework6)
                        {
                            project.DTE.SuppressUI = true;
                            project.Properties.Item("TargetFrameworkMoniker").Value = ".NETFramework,Version=v4.5";
                        }
                    }
                }

                else
                {
                    string indexPath = Language == LanguageGenerator.CSharp ? (string)(FindProjectItem(FindProjectItem(FindProjectItem(vsProj.Project.ProjectItems, "Views").ProjectItems,
                                                                                                                       "Home").ProjectItems, "Index.cshtml").Properties.Item("FullPath").Value) :
                                       (string)(FindProjectItem(FindProjectItem(FindProjectItem(vsProj.Project.ProjectItems, "Views").ProjectItems,
                                                                                "Home").ProjectItems, "Index.vbhtml").Properties.Item("FullPath").Value);

                    string contents = File.ReadAllText(indexPath);
                    contents = contents.Replace("$catalogList$", String.Empty);
                    File.WriteAllText(indexPath, contents);
                }

                var webConfig = new MySql.Data.VisualStudio.WebConfig.WebConfig(ProjectPath + @"\web.config");
                SendToGeneralOutputWindow("Starting provider configuration...");
                try
                {
                    try
                    {
                        string configPath = ProjectPath + @"\web.config";

                        if (WizardForm.CreateAdministratorUser)
                        {
                            SendToGeneralOutputWindow("Creating administrator user...");
                            using (AppConfig.Load(configPath))
                            {
                                var configFile = new FileInfo(configPath);
                                var vdm        = new VirtualDirectoryMapping(configFile.DirectoryName, true, configFile.Name);
                                var wcfm       = new WebConfigurationFileMap();
                                wcfm.VirtualDirectories.Add("/", vdm);
                                System.Configuration.Configuration config = WebConfigurationManager.OpenMappedWebConfiguration(wcfm, "/");
                                try
                                {
                                    if (!WizardForm.IncludeSensitiveInformation)
                                    {
                                        ConnectionStringsSection connectionStringsection = config.GetSection("connectionStrings") as ConnectionStringsSection;
                                        if (connectionStringsection != null)
                                        {
                                            connectionStringsection.ConnectionStrings[WizardForm.ConnectionStringNameForAspNetTables].ConnectionString = _fullconnectionstring;
                                            config.Save();
                                        }
                                    }
                                }
                                catch
                                { }

                                MembershipSection          section          = (MembershipSection)config.GetSection("system.web/membership");
                                ProviderSettingsCollection settings         = section.Providers;
                                NameValueCollection        membershipParams = settings[section.DefaultProvider].Parameters;
                                var provider = new MySQLMembershipProvider();

                                provider.Initialize(section.DefaultProvider, membershipParams);

                                //create the user
                                MembershipCreateStatus status;
                                if (!WizardForm.RequireQuestionAndAnswer)
                                {
                                    provider.CreateUser(WizardForm.AdminName, WizardForm.AdminPassword, "*****@*****.**", null, null, true, null, out status);
                                }
                                else
                                {
                                    provider.CreateUser(WizardForm.AdminName, WizardForm.AdminPassword, "*****@*****.**", WizardForm.UserQuestion, WizardForm.UserAnswer, true, null, out status);
                                }
                            }
                        }

                        // add creation of providers tables
                        if (WizardForm.IncludeProfilesProvider)
                        {
                            var profileConfig = new ProfileConfig();
                            profileConfig.Initialize(webConfig);
                            profileConfig.Enabled         = true;
                            profileConfig.DefaultProvider = "MySQLProfileProvider";

                            var options = new Options();
                            options.AppName               = @"\";
                            options.AutoGenSchema         = true;
                            options.ConnectionStringName  = WizardForm.ConnectionStringNameForAspNetTables;
                            options.ConnectionString      = WizardForm.ConnectionStringForAspNetTables;
                            options.EnableExpireCallback  = false;
                            options.ProviderName          = "MySQLProfileProvider";
                            options.WriteExceptionToLog   = WizardForm.WriteExceptionsToLog;
                            profileConfig.GenericOptions  = options;
                            profileConfig.DefaultProvider = "MySQLProfileProvider";
                            profileConfig.Save(webConfig);
                        }

                        if (WizardForm.IncludeRoleProvider)
                        {
                            var roleConfig = new RoleConfig();
                            roleConfig.Initialize(webConfig);
                            roleConfig.Enabled         = true;
                            roleConfig.DefaultProvider = "MySQLRoleProvider";

                            var options = new Options();
                            options.AppName              = @"\";
                            options.AutoGenSchema        = true;
                            options.ConnectionStringName = WizardForm.ConnectionStringNameForAspNetTables;
                            options.ConnectionString     = WizardForm.ConnectionStringForAspNetTables;
                            options.EnableExpireCallback = false;
                            options.ProviderName         = "MySQLRoleProvider";
                            options.WriteExceptionToLog  = WizardForm.WriteExceptionsToLog;
                            roleConfig.GenericOptions    = options;
                            roleConfig.DefaultProvider   = "MySQLRoleProvider";
                            roleConfig.Save(webConfig);
                        }
                        webConfig.Save();
                    }
                    catch (Exception ex)
                    {
                        MySqlSourceTrace.WriteAppErrorToLog(ex, null, Resources.WebWizard_UserCreationError, true);
                    }
                }
                catch (Exception ex)
                {
                    MySqlSourceTrace.WriteAppErrorToLog(ex, true);
                }
            }

            SendToGeneralOutputWindow("Finished project generation.");
            WizardForm.Dispose();
        }