public bool IsMessageType(Type t)
            {
                try
                {
                    return(MessagesConventionCache.ApplyConvention(t,
                                                                   typeHandle =>
                    {
                        var type = Type.GetTypeFromHandle(typeHandle);

                        if (IsInSystemConventionList(type))
                        {
                            return true;
                        }
                        if (type.IsFromParticularAssembly())
                        {
                            return false;
                        }
                        return IsMessageTypeAction(type) ||
                        IsCommandTypeAction(type) ||
                        IsEventTypeAction(type);
                    }));
                }
                catch (Exception ex)
                {
                    throw new Exception("Failed to evaluate Message convention. See inner exception for details.", ex);
                }
            }
예제 #2
0
        /// <summary>
        /// Returns true if the given type is a message type.
        /// </summary>
        public bool IsMessageType(Type t)
        {
            Guard.AgainstNull(nameof(t), t);
            try
            {
                return(MessagesConventionCache.ApplyConvention(t,
                                                               typeHandle =>
                {
                    var type = Type.GetTypeFromHandle(typeHandle);

                    if (IsInSystemConventionList(type))
                    {
                        return true;
                    }
                    if (type.IsFromParticularAssembly())
                    {
                        return false;
                    }

                    foreach (var convention in conventions)
                    {
                        if (convention.IsMessageType(type))
                        {
                            if (logger.IsDebugEnabled)
                            {
                                logger.Debug($"{type.FullName} identified as message type by {convention.Name} convention.");
                            }
                            return true;
                        }

                        if (convention.IsCommandType(type))
                        {
                            if (logger.IsDebugEnabled)
                            {
                                logger.Debug($"{type.FullName} identified as command type by {convention.Name} but does not match message type convention. Treating as a message.");
                            }
                            return true;
                        }

                        if (convention.IsEventType(type))
                        {
                            if (logger.IsDebugEnabled)
                            {
                                logger.Debug($"{type.FullName} identified as event type by {convention.Name} but does not match message type convention. Treating as a message.");
                            }
                            return true;
                        }
                    }
                    return false;
                }));
            }
            catch (Exception ex)
            {
                throw new Exception("Failed to evaluate Message convention. See inner exception for details.", ex);
            }
        }
 /// <summary>
 /// Returns true if the given type is a message type.
 /// </summary>
 /// <param name="t"></param>
 /// <returns></returns>
 public static bool IsMessageType(this Type t)
 {
     try
     {
         return(MessagesConventionCache.ApplyConvention(t,
                                                        type =>
                                                        IsMessageTypeAction(type) || IsCommandTypeAction(type) ||
                                                        IsEventTypeAction(type) || (IsInSystemConventionList(type))));
     }
     catch (Exception ex)
     {
         Logger.Error("Failed to evaluate Message convention: " + ex);
         throw;
     }
 }
예제 #4
0
 /// <summary>
 /// Returns true if the given type is a message type.
 /// </summary>
 public static bool IsMessageType(Type t)
 {
     try
     {
         return(MessagesConventionCache.ApplyConvention(t,
                                                        type => IsMessageTypeAction(type) ||
                                                        IsCommandTypeAction(type) ||
                                                        IsEventTypeAction(type) ||
                                                        IsInSystemConventionList(type)));
     }
     catch (Exception ex)
     {
         throw new MessageConventionException("Failed to evaluate Message convention. See inner exception for details.", ex);
     }
 }
예제 #5
0
 /// <summary>
 /// Returns true if the given type is a message type.
 /// </summary>
 /// <param name="t"></param>
 /// <returns></returns>
 public static bool IsMessageType(this Type t)
 {
     return(MessagesConventionCache.ApplyConvention(t, type => IsMessageTypeAction(type) || IsCommandTypeAction(type) || IsEventTypeAction(type)));
 }