//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); }
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); }
public IEnumerable <Type> AllMessageTypes() { AssertInit(); foreach (var handlerType in handlerList.Keys) { foreach (var typeHandled in handlerList[handlerType]) { if (messageTypeConventions.IsMessageType(typeHandled)) { yield return(typeHandled); } } } }
public bool IsMessageType(Type type) { return(messageTypeCoventions.IsMessageType(type)); }