本文整理汇总了C#中Microsoft.Framework.ConfigurationModel.Configuration.AddIniFile方法的典型用法代码示例。如果您正苦于以下问题:C# Configuration.AddIniFile方法的具体用法?C# Configuration.AddIniFile怎么用?C# Configuration.AddIniFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Framework.ConfigurationModel.Configuration
的用法示例。
在下文中一共展示了Configuration.AddIniFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
public void Main(string[] args)
{
var config = new Configuration();
if (File.Exists(HostingIniFile))
{
config.AddIniFile(HostingIniFile);
}
config.AddEnvironmentVariables();
config.AddCommandLine(args);
var context = new HostingContext()
{
Configuration = config,
ServerFactoryLocation = config.Get("server"),
ApplicationName = config.Get("app")
};
var engine = new HostingEngine(_serviceProvider);
var serverShutdown = engine.Start(context);
var loggerFactory = context.ApplicationServices.GetRequiredService<ILoggerFactory>();
var appShutdownService = context.ApplicationServices.GetRequiredService<IApplicationShutdown>();
var shutdownHandle = new ManualResetEvent(false);
appShutdownService.ShutdownRequested.Register(() =>
{
try
{
serverShutdown.Dispose();
}
catch (Exception ex)
{
var logger = loggerFactory.CreateLogger<Program>();
logger.LogError("Dispose threw an exception.", ex);
}
shutdownHandle.Set();
});
var ignored = Task.Run(() =>
{
Console.WriteLine("Started");
Console.ReadLine();
appShutdownService.RequestShutdown();
});
shutdownHandle.WaitOne();
}
示例2: Configure
public void Configure(IApplicationBuilder app)
{
// For more information on how to configure your application,
// visit http://go.microsoft.com/fwlink/?LinkID=398940
// Setup configuration sources
Configuration configuration = new Configuration();
configuration.AddJsonFile("config.json");
configuration.AddIniFile("config.ini");
// this cannot be accessed if XML fomratters were removed
configuration.AddXmlFile("config.xml");
configuration.AddEnvironmentVariables();
string url_home = configuration.Get<string>("UrlLogo");
app.UseMvc();
app.UseWelcomePage();
return;
}