/// <summary> /// It has been required by modules which are designed to handle generic type of IEvent and need access to set IModuleEvent.Output when the generic /// type definition of IEvent{} may be unknown at runtime and strict casting is unavailable. We must expose a method to set Output object via the /// non-generic IEvent interface. /// </summary> public void SetEventOutput(IEventOutput output) { if (output is GetSettingEventOutput o) { Output = o; } }
/// <summary> /// It has been required by modules which are designed to handle generic type of IEvent and need access to set IModuleEvent.Output when the generic /// type definition of IEvent{} may be unknown at runtime and strict casting is unavailable. We must expose a method to set Output object via the /// non-generic IEvent interface. /// </summary> public void SetEventOutput(IEventOutput output) { if (output is EmptyEventOutput o) { Output = o; } }
/// <summary> /// It has been required by modules which are designed to handle generic type of IEvent and need access to set IModuleEvent.Output when the generic /// type definition of IEvent{} may be unknown at runtime and strict casting is unavailable. We must expose a method to set Output object via the /// non-generic IEvent interface. /// </summary> public void SetEventOutput(IEventOutput output) { if (output is ChatModuleEventOutput o) { Output = o; } }
protected void OnEventInvoke(IAnyCompletionSource e, IEventInput input, IEventOutput output) { ProxyOutputWork resultWork = new ProxyOutputWork { CompletionSource = e, EventCenter = EventCenter, Input = input, Output = output, EventDispatchProxy = this }; EventCenter.OutputNextQueue.Enqueue(resultWork, EventCenter.NextQueueWaits); }
public override bool Executing(EventCenter center, EventActionHandler handler, IEventInput input, IEventOutput output) { string token = null; input.Properties?.TryGetValue("token", out token); var user = JWTHelper.Default.GetUserInfo(token); if (user != null) { return(base.Executing(center, handler, input, output)); } else { output.EventError = EventError.InnerError; output.Data = new object[] { "操作错误,无权操作相关资源!" }; return(false); } }
public virtual void Executed(EventCenter center, EventActionHandler handler, IEventInput input, IEventOutput output) { }
public virtual bool Executing(EventCenter center, EventActionHandler handler, IEventInput input, IEventOutput output) { return(true); }
public override bool Executing(EventCenter center, EventActionHandler handler, IEventInput input, IEventOutput output) { output.EventError = EventError.NotFound; output.Data = new object[] { $"{input.EventPath} not found!" }; return(false); }
public override void Executed(EventCenter center, EventActionHandler handler, IEventInput input, IEventOutput output) { base.Executed(center, handler, input, output); Console.WriteLine($"{input.EventPath} executed"); }
public override bool Executing(EventCenter center, EventActionHandler handler, IEventInput input, IEventOutput output) { Console.WriteLine($"{input.EventPath} executing"); return(base.Executing(center, handler, input, output)); }
public void Completed(IEventOutput data) { DispatchProxy.OnEventInvoke(CompletionSource, Input, data); }
public void Completed(IEventOutput data) { mTaskCompletionSource.TrySetResult(data); }
public override bool Executing(EventCenter center, EventActionHandler handler, IEventInput input, IEventOutput output) { input.Properties.TryGetValue("token", out string token); if (token == "admin") { return(base.Executing(center, handler, input, output)); } else { output.EventError = EventError.InnerError; output.Data = new object[] { "操作用户无效!" }; return(false); } }