12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- using System;
- using System.Collections.Generic;
- using System.Runtime.Serialization;
- namespace WingServerCommon.Config.Parameters
- { /// <summary>
- /// Enum parameter base type
- /// </summary>
- /// <typeparam name="T"></typeparam>
- [DataContract]
- public abstract class EnumParameterBase<T> : IParameter
- {
- private T _initialValue;
- private T _value;
- /// <summary>
- /// parameter value
- /// </summary>
- [DataMember]
- public IList<T> Source { get; set; }
-
- public T InitialValue => _initialValue;
- /// <summary>
- /// parameter value
- /// </summary>
- [DataMember]
- public T Value
- {
- get => _value;
- set
- {
- if (!Equals(_value, value))
- {
- _value = value;
- OnValueChanged();
- }
- }
- }
- /// <summary>
- /// parameter name
- /// </summary>
- public string Name { get; set; }
- /// <summary>
- /// parameter section
- /// </summary>
- public string Section { get; set; }
- /// <summary>
- /// parameter value changed state
- /// </summary>
- public bool IsChanged => !Equals(_initialValue, Value);
- /// <summary>
- /// value changed event
- /// </summary>
- public event EventHandler ValueChanged;
- /// <summary>
- /// notify value changed
- /// </summary>
- private void OnValueChanged()
- {
- ValueChanged?.Invoke(this, EventArgs.Empty);
- }
- /// <summary>
- /// change initial value
- /// </summary>
- public void ChangeInitialValue()
- {
- _initialValue = Value;
- }
-
- /// <summary>
- /// Set user value;
- /// </summary>
- /// <param name="value">User setting value.</param>
- public abstract void ChangeParameterValue(object value);
- }
- }
|