Example #1
0
 /************************ Construction ***********************************/
 /*----------------------- WritableXmlConfigurationSource ----------------*/
 /// <summary>
 ///
 /// </summary>
 /// <param name="writer"></param>
 /// <param name="fileStreamProvider"></param>
 public WritableXmlConfigurationSource(
     IXmlConfigurationWriter writer,
     IFileStreamProvider fileStreamProvider)
 {
     Writer         = writer ?? throw new ArgumentNullException(nameof(writer));
     StreamProvider = fileStreamProvider ??
                      throw new ArgumentNullException(nameof(fileStreamProvider));
     return;
 } /* End of Function - WritableXmlConfigurationSource */
Example #2
0
        } /* End of Function - AddWritableXml */

        /*----------------------- AddWritableXml --------------------------------*/
        /// <summary>
        /// Adds a writable XML configuration source, using defaults.
        /// </summary>
        /// <param name="builder">Builder to add source to.</param>
        /// <param name="fileProvider">File provider to use.</param>
        /// <param name="path">Path of the XML file.</param>
        /// <param name="optional">Determines if loading the file is optional.</param>
        /// <param name="reloadOnChange">
        /// Determines if data should reload on file change.
        /// </param>
        /// <param name="writer">
        /// Service used to write the data to a stream.
        /// </param>
        /// <returns>
        /// The configuration builder.
        /// </returns>
        public static IConfigurationBuilder AddWritableXml(
            this IConfigurationBuilder builder,
            IFileProvider fileProvider,
            string path,
            bool optional,
            bool reloadOnChange,
            IFileStreamProvider fileStreamProvider,
            IXmlConfigurationWriter writer)
        {
            // Build our source
            var source = new WritableXmlConfigurationSource(writer, fileStreamProvider)
            {
                FileProvider   = fileProvider,
                Path           = path,
                Optional       = optional,
                ReloadOnChange = reloadOnChange
            };

            // Resolve the file provider
            source.ResolveFileProvider();

            // And finally add it back to the configuration builder.
            return(builder.Add(source));
        } /* End of Function - AddWritableXml */