示例#1
0
        public static IConfigurationBuilder AddMappedJsonFile(this IConfigurationBuilder builder, string filePath, TimeSpan reloadTime, Func <string, string> mapFunc, bool optional = false)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            if (string.IsNullOrEmpty(filePath))
            {
                throw new ArgumentException("Invalid File Path", nameof(filePath));
            }

            var source = new MappedJsonConfigurationSource(reloadTime, mapFunc)
            {
                Path           = filePath,
                Optional       = optional,
                ReloadOnChange = false,
            };

            builder.Add(source);
            return(builder);
        }
 public MappedJsonConfigurationProvider(MappedJsonConfigurationSource source, TimeSpan reloadTime, Func <string, string> mapFunc) : base(source)
 {
     _mapFunc = mapFunc;
     _timer   = new Timer(Reload, null, reloadTime, reloadTime);
 }