/// <summary> /// <para>Returns the <see cref="DateTime"/> of the last change of the information watched</para> /// <para>The information is retrieved using the watched file modification timestamp</para> /// </summary> /// <returns>The <see cref="DateTime"/> of the last modificaiton, or <code>DateTime.MinValue</code> if the information can't be retrieved</returns> protected override DateTime GetCurrentLastWriteTime() { lock (_padLock) { DateTime lastWriteTime; DateTime createdTime; ChoConfigurationChangeAction configurationChangeAction = ChoConfigurationChangeAction.Changed; if (File.Exists(_configFilePath)) { lastWriteTime = File.GetLastWriteTime(_configFilePath); createdTime = File.GetCreationTime(_configFilePath); } else { lastWriteTime = DateTime.MinValue; createdTime = DateTime.MinValue; } try { if (lastWriteTime == DateTime.MinValue) { if (_lastWriteTime == DateTime.MinValue) { } else { configurationChangeAction = ChoConfigurationChangeAction.Deleted; } } else { if (_lastWriteTime == DateTime.MinValue) { configurationChangeAction = ChoConfigurationChangeAction.Created; } else { if (_lastWriteTime != lastWriteTime) { configurationChangeAction = ChoConfigurationChangeAction.Changed; } } } } finally { if (_configurationChangeAction != configurationChangeAction) { _configurationChangeAction = configurationChangeAction; _configurationFileChangedEventArgs = new ChoConfigurationFileChangedEventArgs(this.SectionName, ChoPath.GetFullPath(_configFilePath), _configurationChangeAction, _lastWriteTime); } _lastWriteTime = lastWriteTime; _createdTime = createdTime; } return(_lastWriteTime); } }
/// <summary> /// <para>Initialize a new instance of the <see cref="ConfigurationChangingEventArgs"/> class with the configuration file, the section name, the old value, and the new value of the changes.</para> /// </summary> /// <param name="configurationFile"><para>The configuration file where the change occured.</para></param> /// <param name="sectionName"><para>The section name of the changes.</para></param> public ChoConfigurationFileChangedEventArgs(string sectionName, string configurationFile, ChoConfigurationChangeAction configurationChangeAction, DateTime lastUpdatedTimeStamp) : base(sectionName, lastUpdatedTimeStamp) { _configurationFile = configurationFile; _configurationChangeAction = configurationChangeAction; }