public bool Handle(ActionListenerContext context)
        {
            var comparer = new TypeIsOfBaseComparer();

            IEnumerable<MethodDescriptor> filtered = GetDescriptors()
                .Where(x => x.Name == context.CallInfo.MethodName
                            && x.ParameterTypes.SequenceEqual(context.CallInfo.UnnamedArguments.ToTypes(), comparer))
                .ToList();

            var returnType = context.CallInfo.ReturnType;
            if (returnType != null)
            {
                var funcDescriptor = filtered.OfType<FuncDescriptor>().Where(f => f.ReturnType == returnType).FirstOrDefault();
                if (funcDescriptor == null)
                    throw new MissingMethodException("Method not found");
                var instance = GetInstanceFromMethodDescriptor(funcDescriptor);
                context.Result = funcDescriptor.Func(instance, context.CallInfo.UnnamedArguments.ToArray());
            }
            else
            {
                var actionDescriptor = filtered.OfType<ActionDescriptor>().FirstOrDefault();
                if(actionDescriptor == null)
                    throw new MissingMethodException("Method not found");
                var instance = GetInstanceFromMethodDescriptor(actionDescriptor);
                actionDescriptor.Action(instance, context.CallInfo.UnnamedArguments.ToArray());
            }
            return true;
        }
 public object ExecuteListeners(ActionCallInfo callInfo)
 {
     object[] actionListeners = _resolvingService.ResolveAll(typeof (IActionListener));
     IEnumerable<IActionListener> handlers = actionListeners.Cast<IActionListener>().Where(h => h.CanHandle(callInfo));
     var context = new ActionListenerContext(callInfo);
     bool wasHandled = handlers.Any(actionListener => actionListener.Handle(context));
     if (!wasHandled)
         throw new InvalidOperationException("No handler for call");
     return context.Result;
 }
 public bool Handle(ActionListenerContext context)
 {
     var unnamed = context.CallInfo.UnnamedArguments;
     for (int i =0; i < unnamed.Count; i++)
     {
         var val = unnamed[i] as string;
         if (val != null)
             unnamed[i] = val.Trim();
     }
     return false;
 }
 public bool Handle(ActionListenerContext context)
 {
     var arg = context.CallInfo.NamedArguments.FirstOrDefault(x => x.Item1.Equals("log", StringComparison.OrdinalIgnoreCase));
     if (arg == null || !(arg.Item2 is bool) || !(bool)arg.Item2)
         return false;
     var unnamed = context.CallInfo.UnnamedArguments;
     Console.Write("Calling {0}({1}) with Args: ", context.CallInfo.MethodName, context.CallInfo.ReturnType);
     for (int i = 0; i < unnamed.Count; i++)
     {
         var val = unnamed[i];
         Console.Write("input{0}: {1} ", i, val);
     }
     Console.WriteLine();
     return false;
 }