本文整理汇总了C#中BusConfiguration.TypesToScan方法的典型用法代码示例。如果您正苦于以下问题:C# BusConfiguration.TypesToScan方法的具体用法?C# BusConfiguration.TypesToScan怎么用?C# BusConfiguration.TypesToScan使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BusConfiguration
的用法示例。
在下文中一共展示了BusConfiguration.TypesToScan方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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)));
}
示例2: GetConfiguration
public BusConfiguration GetConfiguration(RunDescriptor runDescriptor, EndpointConfiguration endpointConfiguration, IConfigurationSource configSource, Action<BusConfiguration> configurationBuilderCustomization)
{
var settings = runDescriptor.Settings;
LogManager.UseFactory(new ContextAppender(runDescriptor.ScenarioContext, endpointConfiguration.EndpointName));
var types = GetTypesScopedByTestClass(endpointConfiguration);
typesToInclude.AddRange(types);
var builder = new BusConfiguration();
builder.EndpointName(endpointConfiguration.EndpointName);
builder.TypesToScan(typesToInclude);
builder.CustomConfigurationSource(configSource);
builder.EnableInstallers();
builder.DefineTransport(settings, endpointConfiguration.BuilderType);
builder.DefineTransactions(settings);
builder.DefineBuilder(settings);
builder.RegisterComponents(r =>
{
r.RegisterSingleton(runDescriptor.ScenarioContext.GetType(), runDescriptor.ScenarioContext);
r.RegisterSingleton(typeof(ScenarioContext), runDescriptor.ScenarioContext);
});
SetSerializer(settings, builder);
builder.DefinePersistence(settings);
builder.GetSettings().SetDefault("ScaleOut.UseSingleBrokerQueue", true);
configurationBuilderCustomization(builder);
return builder;
}
示例3: GetConfiguration
public BusConfiguration GetConfiguration(RunDescriptor runDescriptor, EndpointConfiguration endpointConfiguration, IConfigurationSource configSource, Action<BusConfiguration> configurationBuilderCustomization)
{
var settings = runDescriptor.Settings;
var types = GetTypesToUse(endpointConfiguration);
var config = new BusConfiguration();
config.EndpointName(endpointConfiguration.EndpointName);
config.TypesToScan(types);
config.CustomConfigurationSource(configSource);
config.UsePersistence<InMemoryPersistence>();
config.PurgeOnStartup(true);
// Plugin a behavior that listens for subscription messages
config.Pipeline.Register<SubscriptionBehavior.Registration>();
config.RegisterComponents(c => c.ConfigureComponent<SubscriptionBehavior>(DependencyLifecycle.InstancePerCall));
// Important: you need to make sure that the correct ScenarioContext class is available to your endpoints and tests
config.RegisterComponents(r =>
{
r.RegisterSingleton(runDescriptor.ScenarioContext.GetType(), runDescriptor.ScenarioContext);
r.RegisterSingleton(typeof(ScenarioContext), runDescriptor.ScenarioContext);
});
// Call extra custom action if provided
if (configurationBuilderCustomization != null)
{
configurationBuilderCustomization(config);
}
return config;
}
示例4: ScanningListOfTypes
void ScanningListOfTypes(BusConfiguration busConfiguration, IEnumerable<Type> myTypes)
{
#region ScanningListOfTypes
busConfiguration.TypesToScan(myTypes);
#endregion
}
示例5: ScanningPublicApi
public ScanningPublicApi()
{
IEnumerable<Assembly> myListOfAssemblies = null;
Assembly assembly2 = null;
Assembly assembly1 = null;
IEnumerable<Type> myTypes = null;
#region ScanningDefault
BusConfiguration busConfiguration = new BusConfiguration();
#endregion
#region ScanningExcludeByName
busConfiguration.AssembliesToScan(AllAssemblies.Except("MyAssembly1.dll").And("MyAssembly2.dll"));
#endregion
#region ScanningListOfTypes
busConfiguration.TypesToScan(myTypes);
#endregion
#region ScanningListOfAssemblies
busConfiguration.AssembliesToScan(myListOfAssemblies);
// or
busConfiguration.AssembliesToScan(assembly1, assembly2);
#endregion
#region ScanningIncludeByPattern
busConfiguration.AssembliesToScan(AllAssemblies.Matching("NServiceBus").And("MyCompany.").And("SomethingElse"));
#endregion
#region ScanningCustomDirectory
busConfiguration.ScanAssembliesInDirectory(@"c:\my-custom-dir");
#endregion
#region ScanningMixingIncludeAndExclude
busConfiguration.AssembliesToScan(AllAssemblies.Matching("NServiceBus").And("MyCompany.").Except("BadAssembly.dll"));
#endregion
}
示例6: ScanningListOfTypes
public void ScanningListOfTypes()
{
IEnumerable<Type> myTypes = null;
BusConfiguration busConfiguration = new BusConfiguration();
#region ScanningListOfTypes
busConfiguration.TypesToScan(myTypes);
#endregion
}
示例7: Databus_should_not_be_activated_if_no_databus_property_is_found
public void Databus_should_not_be_activated_if_no_databus_property_is_found()
{
var builder = new BusConfiguration();
builder.EndpointName("xyz");
builder.TypesToScan(new[] { typeof(MessageWithoutDataBusProperty) });
var feature = new DataBus();
Assert.False(feature.CheckPrerequisites(new FeatureConfigurationContext(builder.BuildConfiguration())).IsSatisfied);
}
示例8: Databus_should_be_activated_if_a_databus_property_is_found
public void Databus_should_be_activated_if_a_databus_property_is_found()
{
var builder = new BusConfiguration();
builder.EndpointName("xyz");
builder.TypesToScan(new[]{typeof(MessageWithDataBusProperty)});
builder.RegisterComponents(c => c.ConfigureComponent<InMemoryDataBus>(DependencyLifecycle.SingleInstance));
var config = builder.BuildConfiguration();
Assert.True(new DataBus().CheckPrerequisites(new FeatureConfigurationContext(config)).IsSatisfied);
}
示例9: Should_construct_serializer_that_uses_requested_encoding
public void Should_construct_serializer_that_uses_requested_encoding()
{
var builder = new BusConfiguration();
builder.TypesToScan(new Type[0]);
builder.UseSerialization<JsonSerializer>().Encoding(Encoding.UTF7);
var config = builder.BuildConfiguration();
var context = new FeatureConfigurationContext(config);
new JsonSerialization().SetupFeature(context);
var serializer = config.Builder.Build<JsonMessageSerializer>();
Assert.AreSame(Encoding.UTF7, serializer.Encoding);
}
示例10: Should_throw_if_propertyType_is_not_serializable
public void Should_throw_if_propertyType_is_not_serializable()
{
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"));
var feature = new DataBus();
Assert.Throws<InvalidOperationException>(() => feature.CheckPrerequisites(new FeatureConfigurationContext(builder.BuildConfiguration())));
}
示例11: Simple
public void Simple()
{
// Autofac
var listOfAssemblies = new List<Assembly>();
var listOfTypes = new List<Type>();
string directoryToProbe = null;
#region TypeScanningV4
var configuration = new BusConfiguration();
configuration.AssembliesToScan(listOfAssemblies);
// or
configuration.TypesToScan(listOfTypes);
//or
configuration.ScanAssembliesInDirectory(directoryToProbe);
#endregion
}