コード例 #1
0
 private void ProcessAttributeHandlers(ObjectToRoute p)
 {
     foreach (var handler in attributeHandlers)
     {
         handler.Validate(p);
     }
 }
コード例 #2
0
        private object[] ProvideMethodArguments(ObjectToRoute objectToRoute)
        {
            var methodParameters = objectToRoute.RouteRecord.SelectedMethod.GetParameters();

            var resultList = new List <object>(methodParameters.Length);

            foreach (var parameter in methodParameters)
            {
                if (parameter.ParameterType.IsInstanceOfType(objectToRoute.Context))
                {
                    resultList.Add(objectToRoute.Context);
                }

                if (parameter.ParameterType.IsInstanceOfType(objectToRoute.Payload))
                {
                    resultList.Add(objectToRoute.Payload);
                }

                if (parameter.ParameterType.IsInstanceOfType(this))
                {
                    resultList.Add(this);
                }
            }

            return(resultList.ToArray());
        }
コード例 #3
0
        public async Task RouteObjectAsync(object context, object routedObject)
        {
            var routingTable = GetSuitableRoutingRecords(context, routedObject);

            foreach (var record in routingTable)
            {
                var p = new ObjectToRoute(context, routedObject, record);
                await CallMethod(p);
            }
        }
コード例 #4
0
        private async Task CallMethod(ObjectToRoute objectToRoute)
        {
            ProcessAttributeHandlers(objectToRoute);
            var routeRecord     = objectToRoute.RouteRecord;
            var methodArguments = ProvideMethodArguments(objectToRoute);


            var result = routeRecord.SelectedMethod?.Invoke(routeRecord.Processor, methodArguments);

            if (result is Task t)
            {
                await t;
            }
        }
コード例 #5
0
        private async Task CallMethod(ObjectToRoute objectToRoute)
        {
            ProcessAttributeHandlers(objectToRoute);
            var routeRecord     = objectToRoute.RouteRecord;
            var methodArguments = ProvideMethodArguments(objectToRoute);

            try
            {
                var result = routeRecord.SelectedMethod?.Invoke(routeRecord.Processor, methodArguments);
                if (result is Task t)
                {
                    await t.ConfigureAwait(false);
                }
            }
            catch (TargetInvocationException tie)
            {
                if (tie.InnerException != null)
                {
                    throw tie.InnerException;
                }
            }
        }