Example #1
0
        private static void InvokeMethodOn(Object state, Object message)
        {
            var methodDescriptor = new MethodDescriptor(state.GetType(), message.GetType());
            MethodInfo methodInfo = null;
            if (!_methodCache.TryGetValue(methodDescriptor, out methodInfo))
                _methodCache[methodDescriptor] = methodInfo = state.GetType()
                    .GetMethod("On", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance, null,
                        new[] { message.GetType() }, null);

            if (methodInfo == null)
                return;

            methodInfo.Invoke(state, new[] { message });
        }
Example #2
0
 public bool Equals(MethodDescriptor descriptor)
 {
     return descriptor.HandlerType == HandlerType && descriptor.MessageType == MessageType;
 }
Example #3
0
        public void InvokeByReflection(Object handler, Object message)
        {
            var methodDescriptor = new MethodDescriptor(handler.GetType(), message.GetType());
            MethodInfo methodInfo = null;
            if (!_methodCache.TryGetValue(methodDescriptor, out methodInfo))
                _methodCache[methodDescriptor] = methodInfo = handler.GetType().GetMethod("Handle", new[] { message.GetType() });

            if (methodInfo == null)
                return;

            methodInfo.Invoke(handler, new[] { message });
        }