示例#1
0
 public static void Synchronize <T>(this IValueStateObserver <T> state, IEventTrigger <T> evnt) where T : struct
 {
     state.OnChange.Register(evnt); if (evnt.IsValid)
     {
         evnt.Trigger(state.Value);
     }
 }
示例#2
0
文件: Semaphore.cs 项目: k10czar/K10
 public static void ReleaseOn(this ISemaphoreInterection semaphore, IValueStateObserver <bool> source)
 {
     source.Synchronize((value) => { if (value)
                                     {
                                         semaphore.Release(source);
                                     }
                                     else
                                     {
                                         semaphore.Block(source);
                                     } });
 }
示例#3
0
文件: Semaphore.cs 项目: k10czar/K10
 public static void ReleaseOn(this ISemaphoreInterection semaphore, IValueStateObserver <bool> source, Func <bool> eventValidation)
 {
     source.Synchronize(new ConditionalEventListener <bool>((value) => { if (value)
                                                                         {
                                                                             semaphore.Release(source);
                                                                         }
                                                                         else
                                                                         {
                                                                             semaphore.Block(source);
                                                                         } }, eventValidation));
 }
示例#4
0
 public static void Synchronize <T>(this IValueStateObserver <T> state, IEventTrigger <T> evnt, System.Func <bool> validation) where T : struct
 {
     Synchronize <T>(state, new ConditionalEventListener <T>(evnt, () => validation() && evnt.IsValid));
 }
示例#5
0
    public static void Synchronize <T>(this IValueStateObserver <T> state, IEventTrigger <T> evnt, params IEventValidator[] validators) where T : struct
    {
        var vals = validators.GetCurrentValidators();

        Synchronize(state, new ConditionalEventListener <T>(evnt, () => vals.And() && evnt.IsValid));
    }
示例#6
0
 public static void Synchronize <T>(this IValueStateObserver <T> state, IEventTrigger <T> evnt, IEventValidator validation) where T : struct
 {
     Synchronize <T>(state, validation.Validated <T>(evnt));
 }
示例#7
0
 public static void Synchronize <T>(this IValueStateObserver <T> source, IValueStateSetter <T> valueState, IEventValidator validation) where T : struct
 {
     Synchronize <T>(source, valueState.Setter, validation);
 }
示例#8
0
 public Diff(IValueStateObserver <float> variableA, IValueStateObserver <float> variableB) : base(variableA, variableB)
 {
     variableA.Synchronize((v) => _operation.Setter(!Mathf.Approximately(v, variableB.Value)), _events);
     variableB.Synchronize((v) => _operation.Setter(!Mathf.Approximately(v, variableA.Value)), _events);
 }
示例#9
0
 public static void Synchronize <T>(this IValueStateObserver <T> source, IValueStateSetter <T> valueState) where T : struct
 {
     Synchronize <T>(source, valueState.Setter);
 }
示例#10
0
 public static void Synchronize <T>(this IValueStateObserver <T> state, System.Action evnt, System.Func <bool> validation) where T : struct
 {
     Synchronize(state, new ConditionalEventListener(evnt, validation));
 }
示例#11
0
 public Diff(IValueStateObserver <float> variable, float constant) : base(variable, constant)
 {
     variable.Synchronize((v) => _operation.Setter(!Mathf.Approximately(v, constant)), _events);
 }
示例#12
0
 public Less(IValueStateObserver <int> variableA, IValueStateObserver <int> variableB) : base(variableA, variableB)
 {
     variableA.Synchronize((v) => _operation.Setter(v < variableB.Value), _events);
     variableB.Synchronize((v) => _operation.Setter(v > variableA.Value), _events);
 }
示例#13
0
 public static void Synchronize <T>(this IValueStateObserver <T> state, System.Action evnt) where T : struct
 {
     Synchronize(state, new ActionEventCapsule(evnt));
 }
示例#14
0
 public Less(IValueStateObserver <float> variable, float constant) : base(variable, constant)
 {
     variable.Synchronize((v) => _operation.Setter(v < constant), _events);
 }
示例#15
0
 public GreaterThanZero(IValueStateObserver <float> variable) : base(variable, 0)
 {
 }
示例#16
0
 public LessThanZero(IValueStateObserver <int> variable) : base(variable, 0)
 {
 }
示例#17
0
 public NotZero(IValueStateObserver <float> variable) : base(variable, 0)
 {
 }
示例#18
0
 public IsZero(IValueStateObserver <int> variable) : base(variable, 0)
 {
 }
示例#19
0
 public static void Synchronize <T>(this IValueStateObserver <T> state, System.Action evnt, IEventValidator validation) where T : struct
 {
     Synchronize(state, validation.Validated(evnt));
 }
示例#20
0
 public static void Synchronize <T>(this IValueStateObserver <T> state, System.Action <T> evnt, params IEventValidator[] validators) where T : struct
 {
     Synchronize(state, new ActionEventCapsule <T>(evnt), validators);
 }
示例#21
0
 public static void Semaphore(IValueStateObserver <bool> s, string name)
 {
     Semaphore(s != null ? s.Value : false, name);
 }
示例#22
0
 public Diff(IValueStateObserver <int> variable, int constant) : base(variable, constant)
 {
     variable.Synchronize((v) => _operation.Setter(v != constant), _events);
 }