当前位置: 首页>>代码示例>>C#>>正文


C# Conventions.IsCommandType方法代码示例

本文整理汇总了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.");
     }
 }
开发者ID:xqfgbc,项目名称:NServiceBus,代码行数:7,代码来源:MessagingBestPractices.cs

示例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)));
 }
开发者ID:Particular,项目名称:NServiceBus,代码行数:8,代码来源:ConventionsTests.cs

示例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);
        }
开发者ID:Particular,项目名称:NServiceBus,代码行数:18,代码来源:MessageConventionSpecs.cs

示例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;
        }
开发者ID:Particular,项目名称:NServiceBus,代码行数:11,代码来源:AutoSubscribe.cs

示例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.");
            }
        }
开发者ID:xqfgbc,项目名称:NServiceBus,代码行数:12,代码来源:MessagingBestPractices.cs

示例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)));
 }
开发者ID:Particular,项目名称:NServiceBus,代码行数:9,代码来源:ConventionsTests.cs


注:本文中的Conventions.IsCommandType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。