using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Runtime.CompilerServices; using System.Text; using System.Threading.Tasks; namespace EasyDevCore.Configuration { /// /// /// public interface IEasyConfigOptions { /// /// Gets or sets the type of the configuration. /// /// /// The type of the configuration. /// EasyConfigFileType ConfigType { get; } /// /// Gets or sets the encrypt password. /// /// /// The encrypt password. /// string EncryptPassword { get; } /// /// Gets the automatic save delay. /// /// /// The automatic save delay. /// int AutoSaveDelay { get; } /// /// Gets a value indicating whether [automatic save]. /// /// /// true if [automatic save]; otherwise, false. /// bool AutoSave { get; } /// /// Gets or sets the name of the file. /// /// /// The name of the file. /// string FileName { get; } } /// /// /// /// /// /// public class EasyConfigOptions : IEasyConfigOptions, INotifyPropertyChanged { /// /// Gets or sets the type of the configuration. /// /// /// The type of the configuration. /// public EasyConfigFileType ConfigType { get; internal set; } = EasyConfigFileType.Auto; /// /// Gets or sets the encrypt password. /// /// /// The encrypt password. /// public string EncryptPassword { get; set; } private int _AutoSaveDelay = 10; /// /// Gets the automatic save delay. /// /// /// The automatic save delay. /// public int AutoSaveDelay { get => _AutoSaveDelay; set { _AutoSaveDelay = value; NotifyPropertyChanged(); } } private bool _AutoSave = false; /// /// Gets a value indicating whether [automatic save]. /// /// /// true if [automatic save]; otherwise, false. /// public bool AutoSave { get => _AutoSave; set { _AutoSave = value; NotifyPropertyChanged(); } } /// /// Gets or sets the name of the file. /// /// /// The name of the file. /// public string FileName { get; set; } /// /// Occurs when a property value changes. /// public event PropertyChangedEventHandler PropertyChanged; // This method is called by the Set accessor of each property. // The CallerMemberName attribute that is applied to the optional propertyName // parameter causes the property name of the caller to be substituted as an argument. private void NotifyPropertyChanged([CallerMemberName] string propertyName = null) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } } }