public IInternalConfigRecord CreateConfigRecord(IInternalConfigRecord originalRecord) { //TODO: Consider caching like IInternalConfigRecord -> NConfigRecord.(Threadsafe) INConfiguration recordConfiguration = factory.CreateConfigRecordConfiguration(originalRecord, fileNames); return(new NConfigRecordReplacement(originalRecord, recordConfiguration)); }
/// <summary> /// Enables NConfig files inheritance: /// for instance, "Prod.Basisprod.Basic.config" file will inherite values from "Basisprod.Basic.config" /// and file "Basisprod.Basic.config" - from "Basic.config" an so on. /// </summary> /// <param name="configuration">The INConfiguration instance.</param> /// <returns></returns> public static INConfiguration EnableFilesInheritance(this INConfiguration configuration) { IList <string> fileNames = configuration.FileNames; for (int i = 0; i < fileNames.Count; i++) { string[] parentFileNames = GetParentFileNames(fileNames[i]); foreach (string item in parentFileNames) { if (fileNames.IndexOf(item) == -1) { fileNames.Insert(++i, item); } } } return(configuration); }
public NConfigRecordReplacement(IInternalConfigRecord originalRecord, INConfiguration configuration) { this.originalRecord = originalRecord; this.configuration = configuration; }
/// <summary> /// Retrieves configuration section with a name that corresponds to <typeparamref name="T"/> short type name. /// </summary> /// <typeparam name="T">Configuration section Type that inherits <see cref="System.Configuration.ConfigurationSection"/>.</typeparam> /// <returns> /// The specified ConfigurationSection object of type <typeparamref name="T"/>, /// or null if the section does not exist. /// </returns> public static T GetSection <T>(this INConfiguration configuration) where T : ConfigurationSection { return(configuration.GetSection <T>(typeof(T).Name)); }
/// <summary> /// Sets this configuration as the NConfigurator default and System wide default configuration. /// Thus you can use <see cref="System.Configuration.ConfigurationManager"/> to access this configuration. /// </summary> public static INConfiguration SetAsSystemDefault(this INConfiguration config) { NConfigurator.SubstituteSystemConfiguration(config); return(config); }
/// <summary> /// Sets this configuration as the NConfigurator default configuration. /// </summary> public static INConfiguration SetAsDefault(this INConfiguration config) { NConfigurator.SetDefaultConfiguration(config); return(config); }
/// <summary> /// Gets the specified Configuration Section Group object of type <typeparamref name="T"/>. /// </summary> /// <typeparam name="T">Configuration section group Type that inherits <see cref="System.Configuration.ConfigurationSectionGroup"/>.</typeparam> /// <param name="configuration"></param> /// <param name="groupName">The path name of the <see cref="System.Configuration.ConfigurationSectionGroup"/> to return.</param> /// <returns>The section group specified.</returns> public static T GetSectionGroup <T>(this INConfiguration configuration, string groupName) where T : ConfigurationSectionGroup { return(configuration.GetSectionGroup(groupName) as T); }
/// <summary> /// Retrieves a specified configuration section of type <typeparamref name="T"/> for the /// current configuration file set. /// </summary> /// <typeparam name="T">Configuration section Type that inherits <see cref="System.Configuration.ConfigurationSection"/>.</typeparam> /// <param name="configuration"></param> /// <param name="sectionName">The configuration section path and name.</param> /// <returns> /// The specified ConfigurationSection object of type <typeparamref name="T"/>, /// or null if the section does not exist. /// </returns> public static T GetSection <T>(this INConfiguration configuration, string sectionName) where T : ConfigurationSection { return(configuration.GetSection(sectionName) as T); }
internal static void SubstituteSystemConfiguration(INConfiguration config) { SetDefaultConfiguration(config); SystemConfigurator.SubstituteSystemConfiguration(NConfigurator.ConfigurationFactory, config.FileNames); }
internal static void SetDefaultConfiguration(INConfiguration config) { Default = config; }