本文整理汇总了C#中Conventions.IsEventType方法的典型用法代码示例。如果您正苦于以下问题:C# Conventions.IsEventType方法的具体用法?C# Conventions.IsEventType怎么用?C# Conventions.IsEventType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Conventions
的用法示例。
在下文中一共展示了Conventions.IsEventType方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AssertIsValidForSend
public static void AssertIsValidForSend(Type messageType, Conventions conventions)
{
if (conventions.IsEventType(messageType))
{
throw new InvalidOperationException("Events can have multiple recipient so they should be published");
}
}
示例2: 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.");
}
}
示例3: Should_cache_the_message_convention
public void Should_cache_the_message_convention()
{
var timesCalled = 0;
conventions = new Conventions
{
IsEventTypeAction = t =>
{
timesCalled++;
return false;
}
};
conventions.IsEventType(GetType());
Assert.AreEqual(1, timesCalled);
conventions.IsEventType(GetType());
Assert.AreEqual(1, timesCalled);
}
示例4: 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.");
}
}
示例5: IsEventType_should_return_false_for_NServiceBus_types
public void IsEventType_should_return_false_for_NServiceBus_types()
{
var conventions = new Conventions
{
IsEventTypeAction = t => t.Assembly == typeof(Conventions).Assembly
};
Assert.IsFalse(conventions.IsEventType(typeof(Conventions)));
}
示例6: IsEventType_should_return_true_for_matching_type
public void IsEventType_should_return_true_for_matching_type()
{
var conventions = new Conventions
{
IsEventTypeAction = t => t.Assembly == typeof(Conventions).Assembly ||
t == typeof(MyConventionEvent)
};
Assert.IsTrue(conventions.IsEventType(typeof(MyConventionEvent)));
}