本文整理汇总了C#中Conventions.IsCommandType方法的典型用法代码示例。如果您正苦于以下问题:C# Conventions.IsCommandType方法的具体用法?C# Conventions.IsCommandType怎么用?C# Conventions.IsCommandType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Conventions
的用法示例。
在下文中一共展示了Conventions.IsCommandType方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AssertIsValidForReply
public static void AssertIsValidForReply(Type messageType, Conventions conventions)
{
if (conventions.IsCommandType(messageType) || conventions.IsEventType(messageType))
{
throw new InvalidOperationException("Reply is neither supported for Commands nor Events. Commands should be sent to their logical owner using bus.Send and bus. Events should be Published with bus.Publish.");
}
}
示例2: IsCommandType_should_return_false_for_NServiceBus_types
public void IsCommandType_should_return_false_for_NServiceBus_types()
{
var conventions = new Conventions
{
IsCommandTypeAction = t => t.Assembly == typeof(Conventions).Assembly
};
Assert.IsFalse(conventions.IsCommandType(typeof(Conventions)));
}
示例3: Should_cache_the_message_convention
public void Should_cache_the_message_convention()
{
var timesCalled = 0;
conventions = new Conventions
{
IsCommandTypeAction = t =>
{
timesCalled++;
return false;
}
};
conventions.IsCommandType(GetType());
Assert.AreEqual(1, timesCalled);
conventions.IsCommandType(GetType());
Assert.AreEqual(1, timesCalled);
}
示例4: GetMessageTypesHandledByThisEndpoint
static List<Type> GetMessageTypesHandledByThisEndpoint(MessageHandlerRegistry handlerRegistry, Conventions conventions, SubscribeSettings settings)
{
var messageTypesHandled = handlerRegistry.GetMessageTypes() //get all potential messages
.Where(t => !conventions.IsInSystemConventionList(t)) //never auto-subscribe system messages
.Where(t => !conventions.IsCommandType(t)) //commands should never be subscribed to
.Where(conventions.IsEventType) //only events unless the user asked for all messages
.Where(t => settings.AutoSubscribeSagas || handlerRegistry.GetHandlersFor(t).Any(handler => !typeof(Saga).IsAssignableFrom(handler.HandlerType))) //get messages with other handlers than sagas if needed
.ToList();
return messageTypesHandled;
}
示例5: AssertIsValidForPubSub
public static void AssertIsValidForPubSub(Type messageType, Conventions conventions)
{
if (conventions.IsCommandType(messageType))
{
throw new InvalidOperationException("Pub/Sub is not supported for Commands. They should be be sent direct to their logical owner.");
}
if (!conventions.IsEventType(messageType))
{
Log.Info("You are using a basic message to do pub/sub, consider implementing the more specific ICommand and IEvent interfaces to help NServiceBus to enforce messaging best practices for you.");
}
}
示例6: IsCommandType_should_return_true_for_matching_type
public void IsCommandType_should_return_true_for_matching_type()
{
var conventions = new Conventions
{
IsCommandTypeAction = t => t.Assembly == typeof(Conventions).Assembly ||
t == typeof(MyConventionCommand)
};
Assert.IsTrue(conventions.IsCommandType(typeof(MyConventionCommand)));
}