123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- 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
- {
- /// <summary>
- ///
- /// </summary>
- public interface IEasyConfigOptions
- {
- /// <summary>
- /// Gets or sets the type of the configuration.
- /// </summary>
- /// <value>
- /// The type of the configuration.
- /// </value>
- EasyConfigFileType ConfigType { get; }
- /// <summary>
- /// Gets or sets the encrypt password.
- /// </summary>
- /// <value>
- /// The encrypt password.
- /// </value>
- string EncryptPassword { get; }
- /// <summary>
- /// Gets the automatic save delay.
- /// </summary>
- /// <value>
- /// The automatic save delay.
- /// </value>
- int AutoSaveDelay { get; }
- /// <summary>
- /// Gets a value indicating whether [automatic save].
- /// </summary>
- /// <value>
- /// <c>true</c> if [automatic save]; otherwise, <c>false</c>.
- /// </value>
- bool AutoSave { get; }
- /// <summary>
- /// Gets or sets the name of the file.
- /// </summary>
- /// <value>
- /// The name of the file.
- /// </value>
- string FileName { get; }
- }
- /// <summary>
- ///
- /// </summary>
- /// <seealso cref="EasyDevCore.Configuration.IEasyConfigOptions" />
- /// <seealso cref="System.ComponentModel.INotifyPropertyChanged" />
- /// <seealso cref="INotifyPropertyChanged" />
- public class EasyConfigOptions : IEasyConfigOptions, INotifyPropertyChanged
- {
- /// <summary>
- /// Gets or sets the type of the configuration.
- /// </summary>
- /// <value>
- /// The type of the configuration.
- /// </value>
- public EasyConfigFileType ConfigType { get; internal set; } = EasyConfigFileType.Auto;
- /// <summary>
- /// Gets or sets the encrypt password.
- /// </summary>
- /// <value>
- /// The encrypt password.
- /// </value>
- public string EncryptPassword { get; set; }
- private int _AutoSaveDelay = 10;
- /// <summary>
- /// Gets the automatic save delay.
- /// </summary>
- /// <value>
- /// The automatic save delay.
- /// </value>
- public int AutoSaveDelay
- {
- get => _AutoSaveDelay;
- set
- {
- _AutoSaveDelay = value;
- NotifyPropertyChanged();
- }
- }
- private bool _AutoSave = false;
- /// <summary>
- /// Gets a value indicating whether [automatic save].
- /// </summary>
- /// <value>
- /// <c>true</c> if [automatic save]; otherwise, <c>false</c>.
- /// </value>
- public bool AutoSave
- {
- get => _AutoSave;
- set
- {
- _AutoSave = value;
- NotifyPropertyChanged();
- }
- }
- /// <summary>
- /// Gets or sets the name of the file.
- /// </summary>
- /// <value>
- /// The name of the file.
- /// </value>
- public string FileName { get; set; }
- /// <summary>
- /// Occurs when a property value changes.
- /// </summary>
- 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));
- }
- }
- }
|