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


C# Conventions类代码示例

本文整理汇总了C#中Conventions的典型用法代码示例。如果您正苦于以下问题:C# Conventions类的具体用法?C# Conventions怎么用?C# Conventions使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Conventions类属于命名空间,在下文中一共展示了Conventions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateBus

        public static IBus CreateBus()
        {
            var connectionFactory = new InMemoryConnectionFactory();

            var serializer = new JsonSerializer();
            var logger = new ConsoleLogger();
            var conventions = new Conventions();
            var consumerErrorStrategy = new DefaultConsumerErrorStrategy(connectionFactory, serializer, logger, conventions);

            var advancedBus = new RabbitAdvancedBus(
                new ConnectionConfiguration(),
                connectionFactory,
                TypeNameSerializer.Serialize,
                serializer,
                new QueueingConsumerFactory(logger, consumerErrorStrategy),
                logger,
                CorrelationIdGenerator.GetCorrelationId,
                conventions);

            return new RabbitBus(
                TypeNameSerializer.Serialize,
                logger,
                conventions,
                advancedBus);
        }
开发者ID:richard-green,项目名称:EasyNetQ,代码行数:25,代码来源:InMemoryRabbitHutch.cs

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

示例3: SetUp

        public void SetUp()
        {
            var connectionFactory = new ConnectionFactoryWrapper(new ConnectionFactory
            {
                HostName = "localhost",
                VirtualHost = "/",
                UserName = "guest",
                Password = "guest"
            });

            var serializer = new JsonSerializer();
            var logger = new ConsoleLogger();
            var consumerErrorStrategy = new DefaultConsumerErrorStrategy(connectionFactory, serializer, logger);
            var conventions = new Conventions();

            advancedBus = new RabbitAdvancedBus(
                connectionFactory,
                TypeNameSerializer.Serialize,
                serializer,
                new QueueingConsumerFactory(logger, consumerErrorStrategy),
                logger,
                CorrelationIdGenerator.GetCorrelationId,
                conventions);

            while (!advancedBus.IsConnected)
            {
                Thread.Sleep(10);
            }
        }
开发者ID:negy,项目名称:EasyNetQ,代码行数:29,代码来源:RabbitAdvancedBusTests.cs

示例4: 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

示例5: SetUp

        public void SetUp()
        {
            var mockModel = new MockModel
                            {
                                ExchangeDeclareAction = (exchangeName, type, durable, autoDelete, arguments) => createdExchangeName = exchangeName,
                                BasicPublishAction = (exchangeName, topic, properties, messageBody) =>
                                                     	{
                                                     		publishedToExchangeName = exchangeName;
                                                     		publishedToTopic = topic;
                                                     	}
                            };

            var customConventions = new Conventions
                              	{
                              		ExchangeNamingConvention = x => "CustomExchangeNamingConvention",
                              		QueueNamingConvention = (x, y) => "CustomQueueNamingConvention",
                              		TopicNamingConvention = x => "CustomTopicNamingConvention"
                              	};

            CreateBus(customConventions, mockModel);
            using (var publishChannel = bus.OpenPublishChannel())
            {
                publishChannel.Publish(new TestMessage());
            }
        }
开发者ID:adform,项目名称:EasyNetQ,代码行数:25,代码来源:ConventionsTests.cs

示例6: 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

示例7: AdvancedConfiguration

        internal AdvancedConfiguration()
        {
            Conventions = new Conventions
            {
                new FindByPolicyNameConvention(),
                new FindDefaultPolicyViolationHandlerByNameConvention()
            };

            SetDefaultResultsCacheLifecycle(Cache.DoNotCache);
        }
开发者ID:protechdm,项目名称:CloudCompare,代码行数:10,代码来源:AdvancedConfiguration.cs

示例8: 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

示例9: CreateBus

 private void CreateBus(Conventions conventions, IModel model)
 {
     bus = new RabbitBus(
         x => TypeNameSerializer.Serialize(x.GetType()),
         new JsonSerializer(),
         new MockConsumerFactory(),
         new MockConnectionFactory(new MockConnection(model)),
         new MockLogger(),
         CorrelationIdGenerator.GetCorrelationId,
         conventions
         );
 }
开发者ID:Hibame,项目名称:EasyNetQ,代码行数:12,代码来源:ConventionsTests.cs

示例10: 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

示例11: Apply

 public void Apply(UnicastRoutingTable unicastRoutingTable, Conventions conventions)
 {
     var entries = new Dictionary<Type, RouteTableEntry>();
     foreach (var source in routeSources.OrderBy(x => x.Priority)) //Higher priority routes sources override lower priority.
     {
         foreach (var route in source.GenerateRoutes(conventions))
         {
             entries[route.MessageType] = route;
         }
     }
     unicastRoutingTable.AddOrReplaceRoutes("EndpointConfiguration", entries.Values.ToList());
 }
开发者ID:Particular,项目名称:NServiceBus,代码行数:12,代码来源:ConfiguredUnicastRoutes.cs

示例12: Should_add_convention_for_predicate_to_instance

        public void Should_add_convention_for_predicate_to_instance()
        {
            // Arrange
            Func<PolicyResult, bool> expectedPredicate = x => true;
            var conventions = new Conventions();
            var expression = new ViolationHandlerExpression(new ViolationConfigurationExpression(conventions), expectedPredicate);

            // Act
            expression.IsHandledBy(() => new DefaultPolicyViolationHandler());

            // Assert
            Assert.That(conventions.Single().As<PredicateToPolicyViolationHandlerInstanceConvention<DefaultPolicyViolationHandler>>().Predicate, Is.EqualTo(expectedPredicate));
        }
开发者ID:Ridermansb,项目名称:FluentSecurity,代码行数:13,代码来源:ViolationHandlerExpressionSpec.cs

示例13: SetUp

        public void SetUp()
        {
            typeNameSerializer = new TypeNameSerializer();
            var customConventions = new Conventions(typeNameSerializer)
            {
                ExchangeNamingConvention = x => "CustomExchangeNamingConvention",
                QueueNamingConvention = (x, y) => "CustomQueueNamingConvention",
                TopicNamingConvention = x => "CustomTopicNamingConvention"
            };

            mockBuilder = new MockBuilder(x => x.Register<IConventions>(_ => customConventions));
            mockBuilder.Bus.Publish(new TestMessage());
        }
开发者ID:JohnEffo,项目名称:EasyNetQ,代码行数:13,代码来源:ConventionsTests.cs

示例14: Should_return_metadata_for_a_mapped_type

            public void Should_return_metadata_for_a_mapped_type()
            {
                var conventions = new Conventions();
                conventions.IsMessageTypeAction = type => type == typeof(int);

                var defaultMessageRegistry = new MessageMetadataRegistry(conventions);
                defaultMessageRegistry.RegisterMessageTypesFoundIn(new List<Type> { typeof(int) });

                var messageMetadata = defaultMessageRegistry.GetMessageMetadata(typeof(int));

                Assert.AreEqual(typeof(int), messageMetadata.MessageType);
                Assert.AreEqual(1, messageMetadata.MessageHierarchy.Count());
            }
开发者ID:Particular,项目名称:NServiceBus,代码行数:13,代码来源:DefaultMessageRegistryTests.cs

示例15: SetUp

        public void SetUp()
        {
            var conventions = new Conventions(new TypeNameSerializer())
                {
                    ConsumerTagConvention = () => consumerTag
                };

            mockBuilder = new MockBuilder(x => x
                .Register<IConventions>(_ => conventions)
                //.Register<IEasyNetQLogger>(_ => new ConsoleLogger())
                );

            mockBuilder.Bus.Subscribe<MyMessage>(subscriptionId, message => { });
        }
开发者ID:autotagamerica,项目名称:EasyNetQ,代码行数:14,代码来源:SubscribeTests.cs


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