本文整理汇总了C#中Conventions类的典型用法代码示例。如果您正苦于以下问题:C# Conventions类的具体用法?C# Conventions怎么用?C# Conventions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Conventions类属于命名空间,在下文中一共展示了Conventions类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: CssProcessorTests
public CssProcessorTests()
{
conventions = new Conventions();
var mappers = new List<IMapper>
{
new BackgroundMapper(),
new FontSizeMapper(),
new FontFamilyMapper(),
new MarginMapper()
};
subject = new CssProcessor(new CssParser(), mappers);
}
开发者ID:shiftkey,项目名称:cloaked-hipster,代码行数:14,代码来源:CssProcessorTests.cs
示例17: SetUp
protected void SetUp()
{
ConsumerErrorStrategy = MockRepository.GenerateStub<IConsumerErrorStrategy>();
IConventions conventions = new Conventions(new TypeNameSerializer())
{
ConsumerTagConvention = () => ConsumerTag
};
MockBuilder = new MockBuilder(x => x
.Register(_ => conventions)
.Register(_ => ConsumerErrorStrategy)
//.Register<IEasyNetQLogger>(_ => new ConsoleLogger())
);
AdditionalSetUp();
}
开发者ID:EricAtWork,项目名称:EasyNetQ,代码行数:16,代码来源:ConsumerTestBase.cs
示例18: SetUp
public void SetUp()
{
var customConventions = new Conventions
{
ExchangeNamingConvention = x => "CustomExchangeNamingConvention",
QueueNamingConvention = (x, y) => "CustomQueueNamingConvention",
TopicNamingConvention = x => "CustomTopicNamingConvention"
};
mockBuilder = new MockBuilder(x => x.Register<IConventions>(_ => customConventions));
using (var publishChannel = mockBuilder.Bus.OpenPublishChannel())
{
publishChannel.Publish(new TestMessage());
}
}
开发者ID:stemarie,项目名称:EasyNetQ,代码行数:16,代码来源:ConventionsTests.cs
示例19: SetUp
public void SetUp()
{
var conventions = new Conventions
{
RpcExchangeNamingConvention = () => "rpc_exchange",
RpcReturnQueueNamingConvention = () => "rpc_return_queue",
ConsumerTagConvention = () => "the_consumer_tag"
};
mockBuilder = new MockBuilder(x => x
.Register<IEasyNetQLogger>(_ => new ConsoleLogger())
.Register<IConventions>(_ => conventions)
);
AdditionalSetup();
}
开发者ID:JohnEffo,项目名称:EasyNetQ,代码行数:16,代码来源:RequestResponseTestBase.cs
示例20: SetUp
protected void SetUp()
{
ConsumerErrorStrategy = MockRepository.GenerateStub<IConsumerErrorStrategy>();
ConsumerErrorStrategy.Stub(x => x.PostExceptionAckStrategy()).Return(PostExceptionAckStrategy.ShouldAck);
IConventions conventions = new Conventions
{
ConsumerTagConvention = () => ConsumerTag
};
MockBuilder = new MockBuilder(x => x
.Register(_ => conventions)
.Register(_ => ConsumerErrorStrategy)
//.Register<IEasyNetQLogger>(_ => new ConsoleLogger())
);
AdditionalSetUp();
}
开发者ID:stemarie,项目名称:EasyNetQ,代码行数:17,代码来源:ConsumerTestBase.cs
注:本文中的Conventions类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论