Initial Commit ...
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using xCommons.Configurations;
|
||||
using xCommons.Constants;
|
||||
|
||||
namespace xCommons.Extensions {
|
||||
public static partial class IConfigurationExtensions {
|
||||
/// <summary>
|
||||
/// Retrieve AppConfiguration from Configurations
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <returns></returns>
|
||||
public static XAppConfiguration GetXAppConfiguration (this IConfiguration source) {
|
||||
//
|
||||
var xMessageResourceTitlesConfigSection = source
|
||||
.GetSection (ConfigurationNodeNames.MESSAGE_RESOURCE_TITLES_NODE);
|
||||
|
||||
//
|
||||
var result = new XAppConfiguration {
|
||||
Name = source[nameof (XAppConfiguration.Name)],
|
||||
Version = source[nameof (XAppConfiguration.Version)],
|
||||
XPoweredValue = source[nameof (XAppConfiguration.XPoweredValue)],
|
||||
WelcomeMessage = source[nameof (XAppConfiguration.WelcomeMessage)],
|
||||
AllowedOrigins = source
|
||||
.GetSection (nameof (XAppConfiguration.AllowedOrigins))
|
||||
.Get<IEnumerable<string>> (),
|
||||
DefaultLanguage = source[nameof (XAppConfiguration.DefaultLanguage)],
|
||||
MessageResourceTitles = xMessageResourceTitlesConfigSection
|
||||
.Get<XMessageResourceTitles> ()
|
||||
};
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve Swagger Configurations
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <returns></returns>
|
||||
public static XSwaggerConfiguration GetXSwaggerConfiguration (this IConfiguration source) {
|
||||
//
|
||||
var xSwaggerConfigSection = source
|
||||
.GetSection (ConfigurationNodeNames.SWAGGER_NODE);
|
||||
return xSwaggerConfigSection.Get<XSwaggerConfiguration> ();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user