#pragma warning disable 4014 async Task _AsyncTest2(Action result) { //値ありのawait var ret = await Trigger.Time(1f); Assert.IsTrue(ret); var trigger = new Trigger(); ITriggerAction action = trigger.Action; Trigger.Time(1f).Add(x => trigger.Fire()); var tmp = Time.time; //値なしのITriggerActionでもawait出来る await action; Assert.IsTrue(tmp + 0.9f < Time.time); //発火済みでも正常に動作する tmp = Time.time; ret = false; ret = await Trigger.Successed; Assert.AreEqual(tmp, Time.time); Assert.IsTrue(ret); result(); }
public static ITriggerAction <T> Then <T>(this ITriggerAction <ITriggerAction <T> > self) { Trigger <T> trigger = new Trigger <T>(oneShot: self.OneShot); self.Add((item1, ex1) => { if (ex1 != null) { trigger.Error(ex1); } else { item1.Add((item2, ex2) => { if (ex2 != null) { trigger.Error(ex2); } else { trigger.Fire(item2); } }); } }); return(trigger.Action); }
public static ITriggerAction <T[]> Combine <T>(params ITriggerAction <T>[] actions) { Trigger <T[]> trigger = new Trigger <T[]>(); T[] ret = new T[actions.Length]; if (actions == null || actions.Length == 0) { trigger.Fire(ret); return(trigger.Action); } int count = 0; for (int i = 0; i < actions.Length; i++) { int index = i; ITriggerAction <T> action = actions[i]; action.Add((x) => { ret[index] = x; count++; if (count == ret.Length) { trigger.Fire(ret); } }); action.OnFail += trigger.Error; } return(trigger.Action); }
public static ITriggerAction <T> Select <T>(this ITriggerAction self, Func <T> func, bool oneShot = true) { Trigger <T> trigger = new Trigger <T>(oneShot: self.OneShot); self.OnFail += trigger.Error; self.Add(() => trigger.Fire(func())); return(trigger.Action); }
public bool IsActionOverlaps(ITriggerAction action) { if (Property == null) { throw new Granular.Exception("Setter.Property cannot be null"); } return(action is Setter && this.TargetName == ((Setter)action).TargetName && this.Property.Equals(((Setter)action).Property)); }
public bool IsActionOverlaps(ITriggerAction action) { if (Property == null) { throw new Granular.Exception("Setter.Property cannot be null"); } return action is Setter && this.TargetName == ((Setter)action).TargetName && this.Property.Equals(((Setter)action).Property); }
public static ITriggerAction <bool> Any <T>(this ITriggerAction <T> self) { Trigger <bool> trigger = new Trigger <bool>(true); self.Add((item, ex) => { if (ex != null) { trigger.Fire(true); } }); return(trigger.Action); }
public async Task Handle(HookEvent @event, ITriggerAction action) { var gitlabEvent = @event.Headers["X-Gitlab-Event"].FirstOrDefault(); if (string.IsNullOrWhiteSpace(gitlabEvent)) { Console.WriteLine($"[GitLab] Unhandled hook {gitlabEvent}"); return; } if (gitlabEvent == "Merge Request Hook") { await HandleMergeRequest(ReadData(@event), action); } }
private async Task HandleMergeRequest(JObject @event, ITriggerAction trigger) { var projectId = @event.Property("project").Value.Value <JObject>().Property("id").Value.Value <int>(); var reviewId = @event.Property("object_attributes").Value.Value <JObject>().Property("iid").Value.Value <int>(); var action = @event.Property("object_attributes").Value.Value <JObject>().Property("action").Value.Value <string>(); if (action == "update") { await trigger.MergeRequestChanged(projectId, reviewId); } else if (action == "open") { await trigger.NewMergeRequest(projectId, reviewId); } }
public static ITriggerAction <T> Timeout <T>(this ITriggerAction <T> self, float time, bool realtime = false) { Trigger <T> trigger = new Trigger <T>(oneShot: self.OneShot); self.Add(trigger); var timeout = realtime ? TriggerBehaviour.Realtime(time) : TriggerBehaviour.Time(time); timeout.Add(ret => { if (!trigger.Action.Fired) { trigger.Error(new TimeoutException("trigger timeout")); } }); return(trigger.Action); }
public static ITriggerAction <T> Where <T>(this ITriggerAction <T> self, Func <T, bool> func) { Trigger <T> trigger = new Trigger <T>(oneShot: false); self.Add((item, ex) => { if (ex != null) { trigger.Error(ex); } else if (func(item)) { trigger.Fire(item); } }); return(trigger.Action); }
public static ITriggerAction <U> Select <T, U>(this ITriggerAction <T> self, Func <T, U> func, bool oneShot = true) { Trigger <U> trigger = new Trigger <U>(oneShot: self.OneShot); self.Add((item, ex) => { if (ex != null) { trigger.Error(ex); } else { trigger.Fire(func(item)); } }); return(trigger.Action); }
public static ITriggerAction Then(this ITriggerAction <ITriggerAction> self) { Trigger trigger = new Trigger(oneShot: self.OneShot); self.Add((item1, ex1) => { if (ex1 != null) { trigger.Error(ex1); } else { item1.Add(trigger.Fire); item1.OnFail += trigger.Error; } }); return(trigger.Action); }
public static ITriggerAction <T> Realtime <T>(this ITriggerAction <T> self, float time) { Trigger <T> trigger = new Trigger <T>(oneShot: self.OneShot); self.Add((item, ex) => { if (ex != null) { trigger.Error(ex); } else { TriggerBehaviour.Realtime(time) .Add(x => trigger.Fire(item)) .AddFail(trigger.Error); } }); return(trigger.Action); }
public void Clear() { m_Owner = null; m_Action = null; m_List = null; }
public TriggerActionAwaiter(IHasTriggerAction <T> trigger) { m_Action = trigger.Action; }
public ActionHolder(ITriggerAction owner) { m_Owner = owner; }
public bool IsActionOverlaps(ITriggerAction action) { return action is EventSetter && this.Event == ((EventSetter)action).Event; }
public TriggerActionAwaiter(ITriggerAction <T> action) { m_Action = action; }
public bool IsActionOverlaps(ITriggerAction action) { return(action is EventSetter && this.Event == ((EventSetter)action).Event); }
public bool IsActionOverlaps(ITriggerAction action) { return false; }
public static TriggerActionAwaiter GetAwaiter(this ITriggerAction self) { return(new TriggerActionAwaiter(self)); }
public bool IsActionOverlaps(ITriggerAction action) { return(false); }
public static TriggerActionAwaiter <T> GetAwaiter <T>(this ITriggerAction <T> self, CancellationToken cancellation) { cancellation.Register(() => { self.Cancel(); }); return(self.GetAwaiter()); }
public static ITriggerAction <T> Add <T>(this ITriggerAction <T> self, Trigger <T> trigger) { self.Add(trigger.Fire); self.AddFail(trigger.Error); return(self); }
public static ITriggerAction Then <T>(this ITriggerAction <T> self, Func <T, ITriggerAction> func, bool oneShot = true) { return(self.Select(func, oneShot: oneShot).Then()); }
public bool IsActionOverlaps(ITriggerAction action) { return this.Key == ((TestTriggerAction)action).Key; }
internal void AddAction(ITriggerAction triggerAction) => ActionExpressions.Add(triggerAction);
public bool IsActionOverlaps(ITriggerAction action) { return(this.Key == ((TestTriggerAction)action).Key); }
public SplitAxisAction(ITriggerAction positive, ITriggerAction negative) { _positive = positive; _negative = negative; }