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