当前位置: 首页>>代码示例>>C#>>正文


C# ConfigurationManager.GetSection方法代码示例

本文整理汇总了C#中ConfigurationManager.GetSection方法的典型用法代码示例。如果您正苦于以下问题:C# ConfigurationManager.GetSection方法的具体用法?C# ConfigurationManager.GetSection怎么用?C# ConfigurationManager.GetSection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ConfigurationManager的用法示例。


在下文中一共展示了ConfigurationManager.GetSection方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        private static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            container = new UnityContainer();
            container.RegisterInstance(container);
            ServiceLocator.SetLocatorProvider(() => new UnityServiceLocator(container));

            configuration = new ConfigurationManager(Product.Database.AppName, SpecialFolder.ApplicationData);
            container.RegisterInstance(configuration);

            profiles = configuration.GetSection<DatabaseSettingsProfiles>(DatabaseSettingsProfiles.SectionKey);
            container.RegisterInstance(profiles);

            Application.Run(new MainForm());
        }
开发者ID:breslavsky,项目名称:queue,代码行数:17,代码来源:Program.cs

示例2: OnStart

        protected override void OnStart(string[] args)
        {
            logger.Info("Starting service...");

            try
            {
                container = new UnityContainer();
                container.RegisterInstance(container);
                ServiceLocator.SetLocatorProvider(() => new UnityServiceLocator(container));

                configuration = new ConfigurationManager(HostMetadata.PortalApp, SpecialFolder.CommonApplicationData);
                container.RegisterInstance(configuration);

                settings = configuration.GetSection<PortalSettings>(PortalSettings.SectionKey);
                container.RegisterInstance(settings);

                loginSettings = configuration.GetSection<LoginSettings>(LoginSettings.SectionKey);
                container.RegisterInstance(loginSettings);

                portalServiceSettings = configuration.GetSection<PortalServiceSettings>(PortalServiceSettings.SectionKey);
                container.RegisterInstance(portalServiceSettings);

                portal = new PortalInstance(settings, loginSettings);
                portal.Start();

                logger.Info("Service started");
            }
            catch (Exception e)
            {
                logger.Error(e);
                throw;
            }
        }
开发者ID:breslavsky,项目名称:queue,代码行数:33,代码来源:PortalService.cs

示例3: MainForm

        public MainForm()
        {
            InitializeComponent();

            var container = new UnityContainer();
            container.RegisterInstance(container);
            ServiceLocator.SetLocatorProvider(() => new UnityServiceLocator(container));

            string exePath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), HostMetadata.ServerServiceExe);
            serviceManager = new ServiceManager(HostMetadata.ServerServiceName, exePath);

            configuration = new ConfigurationManager(HostMetadata.ServerApp, Environment.SpecialFolder.CommonApplicationData);
            container.RegisterInstance(configuration);

            var commonApplicationData = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
            logger.Info(commonApplicationData);

            templateServiceSettings = configuration.GetSection<TemplateServiceSettings>(TemplateServiceSettings.SectionKey);
            container.RegisterInstance(templateServiceSettings);

            settings = configuration.GetSection<ServerSettings>(ServerSettings.SectionKey);
            container.RegisterInstance(settings);

            editDatabaseSettingsControl.Settings = settings.Database;
            languageControl.Initialize<Language>();
            languageControl.Select<Language>(settings.Language);
            licenseTypeControl.Initialize<ProductLicenceType>();
        }
开发者ID:breslavsky,项目名称:queue,代码行数:28,代码来源:MainForm.cs

示例4: OnStart

        protected override void OnStart(string[] args)
        {
            logger.Info("Starting service...");

            try
            {
                container = new UnityContainer();
                container.RegisterInstance(container);
                ServiceLocator.SetLocatorProvider(() => new UnityServiceLocator(container));

                configuration = new ConfigurationManager(HostMetadata.ServerApp, SpecialFolder.CommonApplicationData);
                container.RegisterInstance(configuration);

                settings = configuration.GetSection<ServerSettings>(ServerSettings.SectionKey);
                container.RegisterInstance(settings);

                templateServiceSettings = configuration.GetSection<TemplateServiceSettings>(TemplateServiceSettings.SectionKey);
                container.RegisterInstance(templateServiceSettings);

                var culture = settings.Language.GetCulture();
                Thread.CurrentThread.CurrentCulture = culture;
                CultureInfo.DefaultThreadCurrentCulture = culture;

                server = new ServerInstance(settings);
                server.Start();

                logger.Info("Service started");
            }
            catch (Exception e)
            {
                logger.Error(e);
                throw;
            }
        }
开发者ID:breslavsky,项目名称:queue,代码行数:34,代码来源:ServerService.cs

示例5: OnStart

        protected override void OnStart(string[] args)
        {
            logger.Info("Starting service...");

            try
            {
                var configuration = new ConfigurationManager(HostMetadata.MetricApp, Environment.SpecialFolder.CommonApplicationData);
                var settings = configuration.GetSection<MetricSettings>(MetricSettings.SectionKey);

                metric = new MetricInstance(settings);
                metric.Start();

                logger.Info("Service started");
            }
            catch (Exception e)
            {
                logger.Error(e);
                throw;
            }
        }
开发者ID:breslavsky,项目名称:queue,代码行数:20,代码来源:MetricService.cs

示例6: LoadConfiguration

 private void LoadConfiguration()
 {
     configuration = new ConfigurationManager(HostMetadata.MetricApp, Environment.SpecialFolder.CommonApplicationData);
     settings = configuration.GetSection<MetricSettings>(MetricSettings.SectionKey);
 }
开发者ID:breslavsky,项目名称:queue,代码行数:5,代码来源:MainForm.cs


注:本文中的ConfigurationManager.GetSection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。