NServiceBus.Conventions.IsCommandType C# (CSharp) Метод

IsCommandType() публичный Метод

Returns true if the given type is a command type.
public IsCommandType ( Type t ) : bool
t System.Type
Результат bool
        public bool IsCommandType(Type t)
        {
            Guard.AgainstNull(nameof(t), t);
            try
            {
                return CommandsConventionCache.ApplyConvention(t, typeHandle =>
                {
                    var type = Type.GetTypeFromHandle(typeHandle);
                    if (type.IsFromParticularAssembly())
                    {
                        return false;
                    }
                    return IsCommandTypeAction(type);
                });
            }
            catch (Exception ex)
            {
                throw new Exception("Failed to evaluate Command convention. See inner exception for details.", ex);
            }
        }

Usage Example

Пример #1
0
 public IEnumerable <PublisherTableEntry> GenerateWithoutBestPracticeEnforcement(Conventions conventions)
 {
     if (!conventions.IsMessageType(messageType))
     {
         throw new Exception($"Cannot configure publisher for type '{messageType.FullName}' because it is not considered a message. Message types have to either implement NServiceBus.IMessage interface or match a defined message convention.");
     }
     if (conventions.IsCommandType(messageType))
     {
         throw new Exception($"Cannot configure publisher for type '{messageType.FullName}' because it is a command.");
     }
     yield return(new PublisherTableEntry(messageType, address));
 }
All Usage Examples Of NServiceBus.Conventions::IsCommandType