本文整理汇总了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());
}
示例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;
}
}
示例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>();
}
示例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;
}
}
示例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;
}
}
示例6: LoadConfiguration
private void LoadConfiguration()
{
configuration = new ConfigurationManager(HostMetadata.MetricApp, Environment.SpecialFolder.CommonApplicationData);
settings = configuration.GetSection<MetricSettings>(MetricSettings.SectionKey);
}