Example #1
0
        /// <summary>
        /// Initializes a new <see cref="IConfigurationProvider"/>
        /// </summary>
        /// <param name="builder">The builder for <see cref="IRecurringJobBuilder"/>.</param>
        /// <param name="configFile">The source settings file.</param>
        /// <param name="reloadOnChange">Whether the <see cref="RecurringJob"/> should be reloaded if the file changes.</param>
        public FileConfigurationProvider(IRecurringJobBuilder builder, string configFile, bool reloadOnChange = true)
        {
            _builder = builder;

            ConfigFile = configFile;

            if (!File.Exists(configFile))
            {
                throw new FileNotFoundException($"The json file {configFile} does not exist.");
            }

            _fileWatcher = new FileSystemWatcher(Path.GetDirectoryName(configFile), Path.GetFileName(configFile));

            _fileWatcher.EnableRaisingEvents = reloadOnChange;
            _fileWatcher.Changed            += OnChanged;
            _fileWatcher.Error += OnError;
        }
Example #2
0
 /// <summary>
 /// Initializes a new <see cref="JsonConfigurationProvider"/>.
 /// </summary>
 /// <param name="builder">The builder for <see cref="IRecurringJobBuilder"/>.</param>
 /// <param name="configFile">The source settings file.</param>
 /// <param name="reloadOnChange">Whether the <see cref="RecurringJob"/> should be reloaded if the file changes.</param>
 public JsonConfigurationProvider(IRecurringJobBuilder builder, string configFile, bool reloadOnChange = true)
     : base(builder, configFile, reloadOnChange)
 {
 }