soundvision/UnityProject/Assets/Scripts/DataModel/Parameter.cs

37 lines
741 B
C#
Raw Normal View History

2019-09-28 18:17:39 +00:00
using System;
namespace cylvester
{
interface IParameter<T> where T : IComparable<T>
{
T Value { set; get; }
event Action ValueChanged;
}
public class Parameter<T> : IParameter<T> where T : IComparable<T>
{
public Parameter(T initial)
{
Value = initial;
}
private T value_;
public T Value
{
get => value_;
set
{
if (value.CompareTo(value_) == 0)
return;
value_ = value;
ValueChanged.Invoke();
}
}
public event Action ValueChanged = () => { };
}
}