/// <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;
     }
 }
Exemple #2
0
 /// <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;
     }
 }
Exemple #3
0
 /// <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);
        }
Exemple #5
0
        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);
 }
Exemple #8
0
 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);
 }
Exemple #9
0
 public override void Executed(EventCenter center, EventActionHandler handler, IEventInput input, IEventOutput output)
 {
     base.Executed(center, handler, input, output);
     Console.WriteLine($"{input.EventPath} executed");
 }
Exemple #10
0
 public override bool Executing(EventCenter center, EventActionHandler handler, IEventInput input, IEventOutput output)
 {
     Console.WriteLine($"{input.EventPath} executing");
     return(base.Executing(center, handler, input, output));
 }
Exemple #11
0
 public void Completed(IEventOutput data)
 {
     DispatchProxy.OnEventInvoke(CompletionSource, Input, data);
 }
Exemple #12
0
 public void Completed(IEventOutput data)
 {
     mTaskCompletionSource.TrySetResult(data);
 }
Exemple #13
0
 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);
     }
 }