Example #1
0
        public IInternalConfigRecord CreateConfigRecord(IInternalConfigRecord originalRecord)
        {
            //TODO: Consider caching like IInternalConfigRecord -> NConfigRecord.(Threadsafe)
            INConfiguration recordConfiguration = factory.CreateConfigRecordConfiguration(originalRecord, fileNames);

            return(new NConfigRecordReplacement(originalRecord, recordConfiguration));
        }
Example #2
0
        /// <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;
 }
Example #4
0
 /// <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));
 }
Example #5
0
 /// <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);
 }
Example #6
0
 /// <summary>
 /// Sets this configuration as the NConfigurator default configuration.
 /// </summary>
 public static INConfiguration SetAsDefault(this INConfiguration config)
 {
     NConfigurator.SetDefaultConfiguration(config);
     return(config);
 }
Example #7
0
 /// <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);
 }
Example #8
0
 /// <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);
 }
 public NConfigRecordReplacement(IInternalConfigRecord originalRecord, INConfiguration configuration)
 {
     this.originalRecord = originalRecord;
     this.configuration  = configuration;
 }
Example #10
0
 internal static void SubstituteSystemConfiguration(INConfiguration config)
 {
     SetDefaultConfiguration(config);
     SystemConfigurator.SubstituteSystemConfiguration(NConfigurator.ConfigurationFactory, config.FileNames);
 }
Example #11
0
 internal static void SetDefaultConfiguration(INConfiguration config)
 {
     Default = config;
 }