本文整理汇总了C#中BusConfiguration.Conventions方法的典型用法代码示例。如果您正苦于以下问题:C# BusConfiguration.Conventions方法的具体用法?C# BusConfiguration.Conventions怎么用?C# BusConfiguration.Conventions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BusConfiguration
的用法示例。
在下文中一共展示了BusConfiguration.Conventions方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnStart
protected override void OnStart(string[] args)
{
var busConfiguration = new BusConfiguration();
busConfiguration.EndpointName("SendNsbMessage");
busConfiguration.UseSerialization<XmlSerializer>();
if (Environment.UserInteractive && Debugger.IsAttached)
{
//TODO: For production use, please select a durable persistence.
busConfiguration.UsePersistence<InMemoryPersistence>();
//TODO: For production use, please script your installation.
busConfiguration.EnableInstallers();
busConfiguration.Conventions()
.DefiningCommandsAs(t => t.Namespace != null && t.Namespace == "IntegrationSample.Messages.Commands");
busConfiguration.Conventions()
.DefiningEventsAs(t => t.Namespace != null && t.Namespace == "IntegrationSample.Messages.Events");
}
var startableBus = Bus.Create(busConfiguration);
bus = startableBus.Start();
Console.WriteLine("\r\nPress '1' to send an NSB message\r\n");
while (true)
{
var key = Console.ReadKey(true);
if (key.KeyChar == '1')
bus.Send(new ProcessOrder()
{
OrderId = Guid.NewGuid(),
});
Console.WriteLine("\r\nPress '1' to send an NSB message\r\n");
}
}
示例2: Customize
public void Customize(BusConfiguration configuration)
{
configuration.UseSerialization<JsonSerializer>();
configuration.UsePersistence<InMemoryPersistence>();
// configure message definitions
configuration.Conventions().DefiningCommandsAs(e => e.Namespace != null & e.Namespace.EndsWith("Commands"));
configuration.Conventions().DefiningEventsAs(e => e.Namespace != null & e.Namespace.EndsWith("Events"));
}
示例3: Customize
public void Customize(BusConfiguration config)
{
if (Environment.UserInteractive)
Console.Title = "Saga";
// herewith we can avoid implementation of the ICommand interface in the Nsb.Commands assembly
config.Conventions().DefiningCommandsAs(t => t.Namespace != null && t.Namespace.StartsWith("Nsb") && t.Name.EndsWith("Command"));
// herewith we can avoid implementation of the IMessage interface in the Nsb.Messages assembly
config.Conventions().DefiningMessagesAs(t => t.Namespace != null && t.Namespace.StartsWith("Nsb") && t.Name.EndsWith("Message"));
config.UsePersistence<InMemoryPersistence>();
}
示例4: Should_not_throw_propertyType_is_not_serializable_if_a_IDataBusSerializer_is_already_registered
public void Should_not_throw_propertyType_is_not_serializable_if_a_IDataBusSerializer_is_already_registered()
{
if (!Debugger.IsAttached)
{
Assert.Ignore("This only work in debug mode.");
}
var builder = new BusConfiguration();
builder.EndpointName("xyz");
builder.TypesToScan(new[]
{
typeof(MessageWithNonSerializableDataBusProperty)
});
builder.Conventions().DefiningDataBusPropertiesAs(p => p.Name.EndsWith("DataBus"));
builder.RegisterComponents(c =>
{
c.RegisterSingleton<IDataBus>(new InMemoryDataBus());
c.ConfigureComponent<IDataBusSerializer>(() => new MyDataBusSerializer(), DependencyLifecycle.SingleInstance);
});
var config = builder.BuildConfiguration();
var feature = new DataBus();
Assert.DoesNotThrow(() => feature.CheckPrerequisites(new FeatureConfigurationContext(config)));
}
示例5: Main
static void Main()
{
var builder = new ContainerBuilder();
builder.RegisterType<Program>();
var container = builder.Build();
var configuration = new BusConfiguration();
configuration.UseContainer<AutofacBuilder>(c => c.ExistingLifetimeScope(container));
configuration.UseTransport<AzureStorageQueueTransport>()
.ConnectionString("UseDevelopmentStorage=true");
configuration.UsePersistence<AzureStoragePersistence>();
configuration.UseSerialization<JsonSerializer>();
configuration.DisableFeature<Sagas>();
configuration.DisableFeature<TimeoutManager>();
configuration.Conventions().DefiningCommandsAs(t => t.Namespace != null && t.Namespace.StartsWith("NServiceBusDemo.Messages.Commands"));
configuration.Conventions().DefiningEventsAs(t => t.Namespace != null && t.Namespace.StartsWith("NServiceBusDemo.Messages.Events"));
configuration.Conventions().DefiningMessagesAs(t => t.Namespace != null && t.Namespace.StartsWith("NServiceBusDemo.Messages.Responses"));
Bus.Create(configuration).Start();
using (var scope = container.BeginLifetimeScope())
{
scope.Resolve<Program>().Run();
}
}
示例6: Main
static void Main()
{
// configure the bus
var busConfiguration = new BusConfiguration();
busConfiguration.UseSerialization<JsonSerializer>();
busConfiguration.UsePersistence<RavenDBPersistence>();
busConfiguration.Conventions().DefiningCommandsAs(e => e.Namespace != null & e.Namespace.EndsWith("Commands"));
busConfiguration.Conventions().DefiningEventsAs(e => e.Namespace != null & e.Namespace.EndsWith("Events"));
// start the bus
var startableBus = Bus.Create(busConfiguration);
using (var bus = startableBus.Start())
{
Start(bus);
}
}
示例7: Customize
public void Customize(BusConfiguration configuration)
{
XmlConfigurator.Configure();
configuration.UseContainer<NinjectBuilder>(k => k.ExistingKernel(CreateKernel()));
configuration.RegisterComponents(x => x.ConfigureComponent<IRepository>(
builder =>
{
return new Repository(() =>
{
var nh = builder.Build<NHibernateStorageContext>();
var e = new OrderContext((DbConnection)nh.Connection);
return e;
});
},
DependencyLifecycle.InstancePerUnitOfWork));
configuration.RegisterComponents(components => components.ConfigureComponent<UnitOfWork>(DependencyLifecycle.InstancePerUnitOfWork));
configuration.UsePersistence<NHibernatePersistence>();
configuration.UseTransport<MsmqTransport>();
configuration.UseDataBus<FileShareDataBus>().BasePath(Constants.NServiceBus_DataBusBasePath);
configuration.RijndaelEncryptionService();
configuration.Transactions();
configuration.EnableOutbox();
configuration.Conventions().OrderConventions();
//
}
示例8: Main
static void Main( string[] args )
{
var config = new BusConfiguration();
config.UsePersistence<InMemoryPersistence>();
config.UseSerialization<JsonSerializer>();
config.UseTransport<RabbitMQTransport>()
.DisableCallbackReceiver();
config.Transactions()
.DisableDistributedTransactions();
config.EnableInstallers();
config.Conventions()
.DefiningCommandsAs( t => t.Namespace != null && t.Namespace.EndsWith( ".Commands" ) )
.DefiningEventsAs( t => t.Namespace != null && t.Namespace.EndsWith( ".Events" ) )
.DefiningMessagesAs( t => t.Namespace != null && t.Namespace.EndsWith( ".Messages" ) );
using( var bus = Bus.Create( config ).Start() )
{
Logic.Run( setup =>
{
setup.DefineAction( ConsoleKey.P, "Publish sample event", () =>
{
bus.Publish<IMessagePublished>(e =>
{
e.ClientId = "client-id";
e.MessageId = "sample-message-id";
});
} );
} );
}
}
示例9: Main
static void Main(string[] args)
{
Console.Title = "Complaint.Backend";
Console.WriteLine("Complaint Backend starting up...");
var configuration = new BusConfiguration();
configuration.Conventions()
.DefiningCommandsAs(t => t.Namespace != null && t.Namespace.StartsWith("SiriusCyberneticsCorp.InternalMessages"))
.DefiningEventsAs(t => t.Namespace != null && t.Namespace.StartsWith("SiriusCyberneticsCorp.Contract"));
configuration.CustomConfigurationSource(new CustomConfigurationSource());
configuration.UseSerialization<JsonSerializer>();
configuration.UsePersistence<RavenDBPersistence>();
configuration.UseTransport<MsmqTransport>();
var bus = Bus.Create(configuration).Start();
Console.WriteLine("Press any key to shut down.");
Console.ReadLine();
Console.WriteLine("Complaint Backend shutting down...");
bus.Dispose();
}
示例10: Main
static void Main()
{
BusConfiguration busConfiguration = new BusConfiguration();
busConfiguration.EndpointName("Samples.Scaleout.Sender");
busConfiguration.EnableInstallers();
busConfiguration.UseSerialization<JsonSerializer>();
busConfiguration.UsePersistence<InMemoryPersistence>();
busConfiguration.Conventions()
.DefiningMessagesAs(t => t.GetInterfaces().Contains(typeof (IMessage)));
using (IBus bus = Bus.Create(busConfiguration).Start())
{
Console.WriteLine("Press 'Enter' to send a message.");
Console.WriteLine("Press any other key to exit.");
while (true)
{
ConsoleKeyInfo key = Console.ReadKey();
Console.WriteLine();
if (key.Key != ConsoleKey.Enter)
{
return;
}
SendMessage(bus);
}
}
}
示例11: Customize
public void Customize(BusConfiguration configuration)
{
configuration.Conventions()
.DefiningMessagesAs(t => t.Namespace != null && t.Namespace.EndsWith(".Contracts"));
configuration.UsePersistence<RavenDBPersistence>();
}
示例12: Usage
Usage(BusConfiguration busConfiguration)
{
#region DefiningEncryptedPropertiesAs
ConventionsBuilder conventions = busConfiguration.Conventions();
conventions.DefiningEncryptedPropertiesAs(info => info.Name.EndsWith("EncryptedProperty"));
#endregion
}
示例13: Customize
public void Customize(BusConfiguration config)
{
config.Conventions()
.DefiningCommandsAs(t => t.Namespace != null && t.Namespace.StartsWith("Example2.Internal.Commands"))
.DefiningEventsAs(t => t.Namespace != null && t.Namespace.StartsWith("Example2.Contracts"))
.DefiningMessagesAs(t => t.Namespace != null && t.Namespace.StartsWith("Example2.Internal.Messages"));
}
示例14: Customize
public void Customize(BusConfiguration configuration)
{
configuration.UseTransport<RabbitMQTransport>();
configuration.UsePersistence<InMemoryPersistence>();
configuration.RijndaelEncryptionService();
UnobtrusiveMessageConventions.Init(configuration.Conventions());
}
示例15: Init
public static void Init()
{
if (Bus != null)
return;
lock (SyncLock)
{
if (Bus != null)
return;
var cfg = new BusConfiguration();
cfg.EndpointName(MethodBase.GetCurrentMethod().DeclaringType.Namespace);
cfg.UseTransport<MsmqTransport>();
cfg.UsePersistence<InMemoryPersistence>();
cfg.EnableInstallers();
cfg.UseSerialization<JsonSerializer>();
cfg.Conventions()
.DefiningMessagesAs(t => t.Namespace != null && t.Namespace.EndsWith(".Messages"))
.DefiningCommandsAs(t => t.Namespace != null && t.Namespace.EndsWith(".Commands"))
.DefiningEventsAs(t => t.Namespace != null && t.Namespace.EndsWith(".Events"));
Bus = NServiceBus.Bus.Create(cfg).Start();
}
}