示例#1
0
        private bool Invoke(
            HandleMethod handleMethod, object target, IHandler composer)
        {
            var arguments = handleMethod.Arguments;
            var filters   = composer.GetOrderedFilters(
                typeof(HandleMethod), typeof(object),
                FilterAttribute.GetFilters(target.GetType(), true),
                FilterAttribute.GetFilters(Dispatcher.Method))
                            .ToArray();

            bool   handled;
            object returnValue;

            if (filters.Length == 0)
            {
                returnValue = Dispatcher.Invoke(target, arguments);
                handled     = !Unhandled;
            }
            else
            {
                handled = Pipeline.Invoke(
                    this, target, handleMethod, comp =>
                {
                    if (comp != null && !ReferenceEquals(composer, comp))
                    {
                        Composer = comp;
                    }
                    return(Dispatcher.Invoke(target, arguments));
                },
                    composer, filters, out returnValue) && !Unhandled;
            }

            handleMethod.ReturnValue = handled
                   ? returnValue
                   : RuntimeHelper.GetDefault(handleMethod.ResultType);
            return(handled);
        }
示例#2
0
 public ResolveMethod(object key, bool many, HandleMethod handleMethod)
     : base(key, many)
 {
     _handleMethod = handleMethod;
 }