示例#1
0
 public Bootstrapper(CommitContext commitContext, CommitSynchroniserContext commitSynchroniserContext, ServerContext serverContext, EventHandlerContext eventHandlerContext)
 {
     this.commitContext             = commitContext;
     this.commitSynchroniserContext = commitSynchroniserContext;
     this.serverContext             = serverContext;
     this.eventHandlerContext       = eventHandlerContext;
 }
示例#2
0
            public ActionInvoker(EventHandlerContext context, CancellationToken cancellationToken, ServicesContainer services)
            {
                Contract.Requires(services != null);

                this.context           = context;
                this.cancellationToken = cancellationToken;
                this.services          = services;
            }
示例#3
0
        public EventHandlerResult OnEvent(EventHandlerContext context)
        {
            dynamic state = new ExpandoObject();

            state.id      = context.State.id;
            state.owner   = context.Event.owner;
            state.balance = 0.0;
            return(new EventHandlerResult(state, AccountStates.Open));
        }
示例#4
0
        public EventHandlerResult OnEvent(EventHandlerContext context)
        {
            dynamic state = new ExpandoObject();

            state.id      = context.State.id;
            state.owner   = context.Event.owner;
            state.balance = context.State.balance - context.Event.amount;

            return(new EventHandlerResult(state, context.StateName));
        }
 private void SubscribeToAllEventsOnObject(string name, object target)
 {
     foreach (EventInfo eventInfo in target.GetType().GetEvents())
     {
         EventHandlerContext context    = new EventHandlerContext(this, name + eventInfo.Name);
         MethodInfo          methodInfo = context.GetType().GetMethod("HandleEvent");
         Delegate            handler    = Delegate.CreateDelegate(eventInfo.EventHandlerType, context, methodInfo);
         eventInfo.AddEventHandler(target, handler);
     }
 }
示例#6
0
        public EventHandlerFilterResult(EventHandlerContext context, ServicesContainer services, IEventHandlerFilter[] filters)
        {
            Contract.Requires(context != null);
            Contract.Requires(services != null);
            Contract.Requires(filters != null);

            this.context  = context;
            this.services = services;
            this.filters  = filters;
        }
示例#7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="EventHandlerOccurredContext"/> class.
        /// </summary>
        /// <param name="handlerContext">Then handler context.</param>
        /// <param name="exceptionInfo">The <see cref="ExceptionDispatchInfo"/>. Optionnal.</param>
        public EventHandlerOccurredContext(EventHandlerContext handlerContext, ExceptionDispatchInfo exceptionInfo)
        {
            if (handlerContext == null)
            {
                throw Error.ArgumentNull("handlerContext");
            }

            this.handlerContext = handlerContext;
            this.ExceptionInfo  = exceptionInfo;
        }
        public string Post([FromBody] Command command)
        {
            var                 json                = command.ToString();
            EventHandler        eventHandler        = new EventHandler();
            IContext            context             = new EpidemyContext(json);
            EventHandlerContext eventHandlerContext = new EventHandlerContext();

            eventHandlerContext.contextHandler   = context;
            eventHandlerContext.command          = EventHandlerFunctions.EpidemyAlertModule;
            eventHandlerContext.subModuleCommand = SubModuleFunctions.EpidemyCheckForAreas;
            eventHandler.InvokeCommand(eventHandlerContext);
            return(context.json);
        }
示例#9
0
 Task IEventHandlerFilter.ExecuteHandlerFilterAsync(EventHandlerContext handlerContext, CancellationToken cancellationToken, Func <Task> continuation)
 {
     return(this.TraceWriter.TraceBeginEndAsync(
                handlerContext.Request,
                TraceCategories.FiltersCategory,
                TraceLevel.Info,
                this.InnerActionFilter.GetType().Name,
                ExecuteActionFilterAsyncMethodName,
                beginTrace: null,
                execute: () => this.InnerActionFilter.ExecuteHandlerFilterAsync(handlerContext, cancellationToken, continuation),
                endTrace: null,
                errorTrace: null));
 }
        public String Post([FromBody] String disease)
        {
            EventHandler   eventHandler = new EventHandler();
            EpidemyContext context      = new EpidemyContext();

            context.specificSearch = disease;
            EventHandlerContext eventHandlerContext = new EventHandlerContext();

            eventHandlerContext.contextHandler   = context;
            eventHandlerContext.command          = EventHandlerFunctions.EpidemyAlertModule;
            eventHandlerContext.subModuleCommand = SubModuleFunctions.EpidemyCheckForAlert;
            eventHandler.InvokeCommand(eventHandlerContext);
            return(context.json);
        }
        public string Post([FromForm] Symptomes symptomeList)
        {
            var                 json                = symptomeList.ToString();
            IContext            context             = new IContext(json);
            EventHandlerContext eventHandlerContext = new EventHandlerContext();

            eventHandlerContext.contextHandler   = context;
            eventHandlerContext.command          = EventHandlerFunctions.SymptomLearningModule;
            eventHandlerContext.subModuleCommand = SubModuleFunctions.MachineLearningStoreResults;
            EventHandler eventHandler = new EventHandler();

            eventHandler.InvokeCommand(eventHandlerContext);
            return("succes");
        }
        public String Post([FromBody] JObject data)
        {
            int id = data["id"].ToObject <int>();

            byte[]              idBytes             = BitConverter.GetBytes(id);
            IContext            context             = new SymptomContext(id, 0);
            EventHandlerContext eventHandlerContext = new EventHandlerContext(idBytes, idBytes.Length);

            eventHandlerContext.command          = EventHandlerFunctions.SymptomBasedDetectionModule;
            eventHandlerContext.subModuleCommand = SubModuleFunctions.GetQuestion;
            eventHandlerContext.contextHandler   = context;
            EventHandler eventHandler = EventHandler.GetInstance();

            eventHandler.InvokeCommand(eventHandlerContext);
            return((context as SymptomContext).response);
        }
示例#13
0
        public static Func <Task> InvokeHandlerWithHandlerFiltersAsync(EventHandlerContext context, CancellationToken cancellationToken, IEventHandlerFilter[] filters, Func <Task> innerAction)
        {
            Contract.Requires(context != null);
            Contract.Requires(filters != null);
            Contract.Requires(innerAction != null);

            Func <Task> result = innerAction;

            for (int i = filters.Length - 1; i >= 0; i--)
            {
                IEventHandlerFilter commandFilter = filters[i];
                Func <Func <Task>, IEventHandlerFilter, Func <Task> > chainContinuation = (continuation, innerFilter) => () => innerFilter.ExecuteHandlerFilterAsync(context, cancellationToken, continuation);

                result = chainContinuation(result, commandFilter);
            }

            return(result);
        }
示例#14
0
 protected override Task Handle(EventHandlerContext context, Event @event)
 {
     Assert.NotNull(context.ServiceBus);
     Assert.NotNull(context.User);
     return(TaskCache.CompletedTask);
 }
示例#15
0
 private static Func <Task> InvokeActionWithActionFilters(EventHandlerContext context, CancellationToken cancellationToken, IEventHandlerFilter[] filters, Func <ActionInvoker, Task> innerAction, ActionInvoker state)
 {
     return(InvokeHandlerWithHandlerFiltersAsync(context, cancellationToken, filters, () => innerAction(state)));
 }
示例#16
0
 public Task Handle(EventHandlerContext context, IEvent @event)
 {
     throw new NotImplementedException();
 }
示例#17
0
        public static Task ProcessAsync(this EventHandlerContext context, ICommand command)
        {
            var processor = context.Configuration.Services.GetProcessor();

            return(processor.ProcessAsync(command));
        }
示例#18
0
            public Task HandleEventAsync(EventHandlerContext <ISimpleEvent> context, CancellationToken cancellationToken = default)
            {
                context.Event.Counter++;

                return(Task.CompletedTask);
            }
示例#19
0
 Bootstrapper(EventSessionContext eventSessionContext, SynchronisableCommitContext synchronisableCommitContext, EventHandlerContext eventHandlerContext)
 {
     this.eventSessionContext         = eventSessionContext;
     this.synchronisableCommitContext = synchronisableCommitContext;
     this.eventHandlerContext         = eventHandlerContext;
 }