数据变更事件
namespace Feng.FramWorkDesign
{
public class BindableProperty<T> where T: IEquatable<T>
{
private T mValue = default(T);
public T Value
{
get
{
return mValue;
}
set
{
if (!value.Equals(mValue))
{
mValue = value;
onValueChanged?.Invoke(mValue);
}
}
}
public Action<T> onValueChanged;
}
}
--------------------------------------------------------------------------------
泛型
namespace Feng.FramWorkDesign标签:体会,void,Action,mValue,static,泛型,mUnPaseEvent,public,变更 From: https://www.cnblogs.com/TriggerF/p/17654084.html
{
public class Event<T> where T :Event<T>
{
private static Action mUnPaseEvent;
public static void Register(Action onEnven)
{
mUnPaseEvent += onEnven;
}
public static void UnRegister(Action unEvent)
{
mUnPaseEvent -= unEvent;
}
public static void Trigger()
{
mUnPaseEvent?.Invoke();
}
}
}
-------------------------------------
相互衬托,思考其中的作用,MVC设计 在交互逻辑当中去触发表现逻辑