本文整理汇总了C#中ConfigurationManager类的典型用法代码示例。如果您正苦于以下问题:C# ConfigurationManager类的具体用法?C# ConfigurationManager怎么用?C# ConfigurationManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConfigurationManager类属于命名空间,在下文中一共展示了ConfigurationManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Manager
private Manager()
{
ConfigurationManager = new ConfigurationManager();
InstanceManager = new InstanceManager();
VersionManager = new VersionManager();
DownloadManager = new DownloadManager();
}
示例2: OpenIdConnectCachingSecurityTokenProvider
public OpenIdConnectCachingSecurityTokenProvider(string metadataEndpoint)
{
_metadataEndpoint = metadataEndpoint;
_configManager = new ConfigurationManager<OpenIdConnectConfiguration>(metadataEndpoint);
RetrieveMetadata();
}
示例3: btnCreate_Click
private void btnCreate_Click(object sender, RoutedEventArgs e)
{
if (txtAppId.Text.IsNullOrEmpty())
{
MessageBox.Show("Application Id не может быть пустым");
return;
}
using (ConfigurationManager man = new ConfigurationManager())
{
UserData data = new UserData();
data.UserName = txtUserName.Text;
data.Password = txtUserPassword.Text;
data.Email = txtEmail.Text;
data.AppId = long.Parse(txtAppId.Text);
data.AccessKey = txtAccessKey.Text;
if (man.CreateUser(data))
MessageBox.Show("Пользователь успешено создан", "Информация", MessageBoxButton.OK,
MessageBoxImage.Information);
else
MessageBox.Show("Ошибка создания пользователя", "Информация", MessageBoxButton.OK,
MessageBoxImage.Error);
}
Refresh();
}
示例4: XrmUriEditor
internal XrmUriEditor(ConfigurationManager configManager)
{
InitializeComponent();
this.configManager = configManager;
XrmUri = new XrmUri();
}
示例5: 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;
}
}
示例6: LoadOpenIdConnectConfigurationAsync
private async Task LoadOpenIdConnectConfigurationAsync()
{
var discoAddress = _settings.Authority + "/.well-known/openid-configuration";
var manager = new ConfigurationManager<OpenIdConnectConfiguration>(discoAddress);
_config = await manager.GetConfigurationAsync();
}
示例7: Main
public static int Main(string [] args)
{
var configurationManager = new ConfigurationManager ();
if (!configurationManager.LoadCommandLineArgs (args))
return 1;
// Show the help and exit.
if (configurationManager.Help) {
configurationManager.PrintHelp ();
#if DEBUG
Console.WriteLine ("Press any key...");
Console.ReadKey ();
#endif
return 0;
}
// Show the version and exit.
if (configurationManager.Version) {
Version.Show ();
return 0;
}
if (!configurationManager.LoadConfigFile ())
return 1;
configurationManager.SetupLogger ();
#if DEBUG
// Log everything while debugging
Logger.Level = LogLevel.All;
#endif
Logger.Write (LogLevel.Debug, Assembly.GetExecutingAssembly ().GetName ().Name);
string configDir = configurationManager.ConfigDir;
if (String.IsNullOrEmpty (configDir)) {
Logger.Write (LogLevel.Error, "You MUST provide a configuration directory with the --config-dir parameter");
return 1;
}
var configDirInfo = new DirectoryInfo (configDir);
if (!configDirInfo.Exists) {
Logger.Write (LogLevel.Error, "The configuration directory \"{0}\" does not exist!", configDir);
return 1;
}
Logger.Write (LogLevel.Debug, "Configuration directory exists, loading configuration files");
ChildrenManager.StartChildren (configDirInfo.GetFiles("*.xml"), configurationManager);
if (!configurationManager.Stoppable)
return 0;
Console.WriteLine ("Hit Return to stop the server.");
Console.ReadLine ();
ChildrenManager.TermChildren();
ChildrenManager.KillChildren();
return 0;
}
示例8: 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.PortalServiceExe);
serviceManager = new ServiceManager(HostMetadata.PortalServiceName, exePath);
configuration = new ConfigurationManager(HostMetadata.PortalApp, Environment.SpecialFolder.CommonApplicationData);
container.RegisterInstance(configuration);
settings = configuration.GetSection<PortalSettings>(PortalSettings.SectionKey);
container.RegisterInstance(settings);
portalSettingsBindingSource.DataSource = settings;
loginSettings = configuration.GetSection<LoginSettings>(LoginSettings.SectionKey);
container.RegisterInstance(loginSettings);
loginSettingsControl.Settings = loginSettings;
portalServiceSettings = configuration.GetSection<PortalServiceSettings>(PortalServiceSettings.SectionKey);
container.RegisterInstance(portalServiceSettings);
portalServiceSettingsBindingSource.DataSource = portalServiceSettings;
loginSettingsControl.UserRole = UserRole.Administrator;
}
示例9: AlwaysSerialize_WithUnchangedProperty_SerializesPropertyAnyway
public void AlwaysSerialize_WithUnchangedProperty_SerializesPropertyAnyway()
{
// Arrange
var secondary = new Config
{
Age = 12,
Name = "Timothy"
};
var primary = new Config();
var expected = new Config
{
Name = "Timothy"
};
var configManager = new ConfigurationManager<Config>(
new DummyConfigurationSource<Config>(secondary),
new DummyConfigurationSource<Config>(primary));
configManager.AlwaysSerialize(t => t.Name);
var actualManager = new DummyConfigurationSource<Config>(new Config());
configManager.SaveChanges(actualManager);
Assert.IsTrue(new ConfigComparer().Equals(
expected, actualManager.SavedObject));
}
示例10: 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;
}
}
示例11: Analyze_EmptyFile_ThrowsException
public void Analyze_EmptyFile_ThrowsException()
{
LoggingFacility.Logger = Substitute.For<ILogger>();
ConfigurationManager cm = new ConfigurationManager();
bool configured = cm.IsConfigured("something");
//rest of test
}
示例12: Init
public void Init()
{
InitCache();
_confMan = ConfigurationManager.Instance;
Isolate.WhenCalled(() => _confMan.AddInMemorySqLiteEnvironment<TestMapping>("Test")).CallOriginal();
RepositoryFixture.CreateInMemorySqLiteRepository<TestMapping>("Test");
}
开发者ID:rdvanbuuren,项目名称:NhRepository,代码行数:8,代码来源:TheFactoryMethodCreateInMemoryEntityRepositoryShould.cs
示例13: ClearTheFakeObject
public void ClearTheFakeObject()
{
_fackProjObj = null;
_fakeActiveConfiguration = null;
_fakeConfigurationManager = null;
_fakeCollection = null;
_fakeVcConfiguration = null;
}
示例14: Analyze_EmptyFile_ThrowsException
public void Analyze_EmptyFile_ThrowsException()
{
FakeTheLogger();
ConfigurationManager cm = new ConfigurationManager();
bool configured = cm.IsConfigured("something");
//rest of test
}
示例15: DoProjectConfigurations
private static void DoProjectConfigurations(
ConfigurationManager configurationManager
)
{
foreach (Configuration configuration in configurationManager)
{
DoProjectConfiguration(configuration);
}
}