コード例 #1
0
ファイル: Semaphore.cs プロジェクト: k10czar/K10
    public static void BlockOn(this ISemaphoreInterection semaphore, IBoolStateObserver source, IEventValidator eventValidation)
    {
        Action releaseAction = () => semaphore.Release(source);

        source.RegisterOnTrue(new ConditionalEventListener(() => semaphore.Block(source), eventValidation.CurrentValidationCheck));
        source.RegisterOnFalse(new ConditionalEventListener(releaseAction, eventValidation.CurrentValidationCheck));

        eventValidation.OnVoid.Register(new CallOnce(releaseAction));
    }
コード例 #2
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));
 }
コード例 #3
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);
                                     } });
 }
コード例 #4
0
ファイル: Semaphore.cs プロジェクト: k10czar/K10
    public static void ReleaseOn(this ISemaphoreInterection semaphore, UnityEngine.GameObject go, IBoolStateObserver additionalCondition = null)
    {
        var  goEvents = go.EventRelay();
        bool isValid  = true;
        var  name     = go.HierarchyNameOrNull();
        IBoolStateObserver condition = new BoolStateOperations.Not(goEvents.IsActive);

        if (additionalCondition != null)
        {
            condition = new BoolStateOperations.And(condition, additionalCondition);
        }
        Func <bool> eventValidation = () => isValid;

        condition.RegisterOnTrue(new ConditionalEventListener(() => semaphore.Release(condition), eventValidation));
        condition.RegisterOnFalse(new ConditionalEventListener(() => semaphore.Block(condition), eventValidation));
        goEvents.OnDestroy.Register(() => { isValid = false; semaphore.Release(condition); });
    }
コード例 #5
0
ファイル: Semaphore.cs プロジェクト: k10czar/K10
 public static void BlockOn(this ISemaphoreInterection semaphore, IBoolStateObserver source, Func <bool> eventValidation)
 {
     source.RegisterOnTrue(new ConditionalEventListener(() => semaphore.Block(source), eventValidation));
     source.RegisterOnFalse(new ConditionalEventListener(() => semaphore.Release(source), eventValidation));
 }
コード例 #6
0
ファイル: Semaphore.cs プロジェクト: k10czar/K10
 public static void BlockOn(this ISemaphoreInterection semaphore, IBoolStateObserver source)
 {
     source.RegisterOnTrue(() => semaphore.Block(source));
     source.RegisterOnFalse(() => semaphore.Release(source));
 }