示例#1
0
        //private static ILog Logger = LogManager.GetLogger(typeof(MessageMapper).Namespace);

        public List <Type> GetMessageTypeHierarchy(Type type)
        {
            // TODO cache this operation
            var types = new List <Type>()
            {
                type
            };

            foreach (var t in type.GetInterfaces())
            {
                if (messageTypeCoventions.IsMessageType(t))
                {
                    if (!types.Contains(t))
                    {
                        types.Add(t);
                    }
                }
            }
            var baseType = type.BaseType;

            while (baseType != null && baseType != typeof(object))
            {
                if (messageTypeCoventions.IsMessageType(baseType))
                {
                    if (!types.Contains(baseType))
                    {
                        types.Add(baseType);
                    }
                }
                baseType = baseType.BaseType;
            }
            return(types);
        }
示例#2
0
        private Type FindMessageTypeFromMethodParameters(MethodInfo method)
        {
            var parameter = method.GetParameters().SingleOrDefault(p => messageTypeConventions.IsMessageType(p.ParameterType));

            if (parameter == null)
            {
                throw new InvalidOperationException(string.Format("Method {0} is marked with [MessageHandlerAttribute] does not have a single parameter which matches a message type convention", method));
            }
            return(parameter.ParameterType);
        }
示例#3
0
 public IEnumerable <Type> AllMessageTypes()
 {
     AssertInit();
     foreach (var handlerType in handlerList.Keys)
     {
         foreach (var typeHandled in handlerList[handlerType])
         {
             if (messageTypeConventions.IsMessageType(typeHandled))
             {
                 yield return(typeHandled);
             }
         }
     }
 }
示例#4
0
 public bool IsMessageType(Type type)
 {
     return(messageTypeCoventions.IsMessageType(type));
 }