本文整理汇总了C#中JobHostConfiguration.GetService方法的典型用法代码示例。如果您正苦于以下问题:C# JobHostConfiguration.GetService方法的具体用法?C# JobHostConfiguration.GetService怎么用?C# JobHostConfiguration.GetService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JobHostConfiguration
的用法示例。
在下文中一共展示了JobHostConfiguration.GetService方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Initialize_PerformsExpectedRegistrations
public void Initialize_PerformsExpectedRegistrations()
{
JobHostConfiguration config = new JobHostConfiguration();
config.AddService<INameResolver>(new RandomNameResolver());
ServiceBusConfiguration serviceBusConfig = new ServiceBusConfiguration();
ServiceBusExtensionConfig serviceBusExtensionConfig = new ServiceBusExtensionConfig(serviceBusConfig);
IExtensionRegistry extensions = config.GetService<IExtensionRegistry>();
ITriggerBindingProvider[] triggerBindingProviders = extensions.GetExtensions<ITriggerBindingProvider>().ToArray();
Assert.Equal(0, triggerBindingProviders.Length);
IBindingProvider[] bindingProviders = extensions.GetExtensions<IBindingProvider>().ToArray();
Assert.Equal(0, bindingProviders.Length);
ExtensionConfigContext context = new ExtensionConfigContext
{
Config = config,
Trace = new TestTraceWriter(TraceLevel.Verbose)
};
serviceBusExtensionConfig.Initialize(context);
// ensure the ServiceBusTriggerAttributeBindingProvider was registered
triggerBindingProviders = extensions.GetExtensions<ITriggerBindingProvider>().ToArray();
Assert.Equal(1, triggerBindingProviders.Length);
ServiceBusTriggerAttributeBindingProvider triggerBindingProvider = (ServiceBusTriggerAttributeBindingProvider)triggerBindingProviders[0];
Assert.NotNull(triggerBindingProvider);
// ensure the ServiceBusAttributeBindingProvider was registered
bindingProviders = extensions.GetExtensions<IBindingProvider>().ToArray();
Assert.Equal(1, bindingProviders.Length);
ServiceBusAttributeBindingProvider bindingProvider = (ServiceBusAttributeBindingProvider)bindingProviders[0];
Assert.NotNull(bindingProvider);
}
示例2: UseServiceBus_NoServiceBusConfiguration_PerformsExpectedRegistration
public void UseServiceBus_NoServiceBusConfiguration_PerformsExpectedRegistration()
{
JobHostConfiguration config = new JobHostConfiguration();
string serviceBusConnection = "test service bus connection";
#pragma warning disable 0618
config.ServiceBusConnectionString = serviceBusConnection;
#pragma warning restore 0618
IExtensionRegistry extensions = config.GetService<IExtensionRegistry>();
IExtensionConfigProvider[] configProviders = extensions.GetExtensions<IExtensionConfigProvider>().ToArray();
Assert.Equal(0, configProviders.Length);
config.UseServiceBus();
// verify that the service bus config provider was registered
configProviders = extensions.GetExtensions<IExtensionConfigProvider>().ToArray();
Assert.Equal(1, configProviders.Length);
ServiceBusExtensionConfig serviceBusExtensionConfig = (ServiceBusExtensionConfig)configProviders.Single();
// verify that a default ServiceBusConfiguration was created, with the host (obsolete)
// service bus connection string propagated
#pragma warning disable 0618
Assert.Equal(serviceBusConnection, serviceBusExtensionConfig.Config.ConnectionString);
#pragma warning restore 0618
}
开发者ID:rafaelmtz,项目名称:azure-webjobs-sdk,代码行数:26,代码来源:ServiceBusJobHostConfigurationExtensionsTests.cs
示例3: ConstructorDefaults
public void ConstructorDefaults()
{
JobHostConfiguration config = new JobHostConfiguration();
Assert.NotNull(config.Singleton);
Assert.NotNull(config.Tracing);
Assert.Equal(TraceLevel.Info, config.Tracing.ConsoleLevel);
Assert.Equal(0, config.Tracing.Tracers.Count);
StorageClientFactory clientFactory = config.GetService<StorageClientFactory>();
Assert.NotNull(clientFactory);
}
示例4: UseServiceBus_ServiceBusConfigurationProvided_PerformsExpectedRegistration
public void UseServiceBus_ServiceBusConfigurationProvided_PerformsExpectedRegistration()
{
JobHostConfiguration config = new JobHostConfiguration();
IExtensionRegistry extensions = config.GetService<IExtensionRegistry>();
IExtensionConfigProvider[] configProviders = extensions.GetExtensions<IExtensionConfigProvider>().ToArray();
Assert.Equal(0, configProviders.Length);
ServiceBusConfiguration serviceBusConfig = new ServiceBusConfiguration
{
ConnectionString = "test service bus connection"
};
config.UseServiceBus(serviceBusConfig);
// verify that the service bus config provider was registered
configProviders = extensions.GetExtensions<IExtensionConfigProvider>().ToArray();
Assert.Equal(1, configProviders.Length);
ServiceBusExtensionConfig serviceBusExtensionConfig = (ServiceBusExtensionConfig)configProviders.Single();
Assert.Same(serviceBusConfig, serviceBusExtensionConfig.Config);
}
开发者ID:ConnorMcMahon,项目名称:azure-webjobs-sdk,代码行数:21,代码来源:ServiceBusJobHostConfigurationExtensionsTests.cs
示例5: UseServiceBus_NoServiceBusConfiguration_PerformsExpectedRegistration
public void UseServiceBus_NoServiceBusConfiguration_PerformsExpectedRegistration()
{
JobHostConfiguration config = new JobHostConfiguration();
IExtensionRegistry extensions = config.GetService<IExtensionRegistry>();
IExtensionConfigProvider[] configProviders = extensions.GetExtensions<IExtensionConfigProvider>().ToArray();
Assert.Equal(0, configProviders.Length);
config.UseServiceBus();
// verify that the service bus config provider was registered
configProviders = extensions.GetExtensions<IExtensionConfigProvider>().ToArray();
Assert.Equal(1, configProviders.Length);
ServiceBusExtensionConfig serviceBusExtensionConfig = (ServiceBusExtensionConfig)configProviders.Single();
// verify that a default ServiceBusConfiguration was created, with the host (obsolete)
// service bus connection string propagated
string serviceBusConnection = Environment.GetEnvironmentVariable("AzureWebJobsServiceBus");
Assert.Equal(serviceBusConnection, serviceBusExtensionConfig.Config.ConnectionString);
}
开发者ID:ConnorMcMahon,项目名称:azure-webjobs-sdk,代码行数:21,代码来源:ServiceBusJobHostConfigurationExtensionsTests.cs
示例6: StorageClientFactory_GetterSetter
public void StorageClientFactory_GetterSetter()
{
JobHostConfiguration configuration = new JobHostConfiguration();
StorageClientFactory clientFactory = configuration.StorageClientFactory;
Assert.NotNull(clientFactory);
Assert.Same(clientFactory, configuration.GetService<StorageClientFactory>());
CustomStorageClientFactory customFactory = new CustomStorageClientFactory();
configuration.StorageClientFactory = customFactory;
Assert.Same(customFactory, configuration.StorageClientFactory);
Assert.Same(customFactory, configuration.GetService<StorageClientFactory>());
}
示例7: AddService_ReplacesExistingService
public void AddService_ReplacesExistingService()
{
JobHostConfiguration configuration = new JobHostConfiguration();
IComparable service = "test1";
configuration.AddService<IComparable>(service);
IComparable result = configuration.GetService<IComparable>();
Assert.Same(service, result);
IComparable service2 = "test2";
configuration.AddService<IComparable>(service2);
result = configuration.GetService<IComparable>();
Assert.Same(service2, result);
}
示例8: AddService_AddsNewService
public void AddService_AddsNewService()
{
JobHostConfiguration configuration = new JobHostConfiguration();
IComparable service = "test1";
configuration.AddService<IComparable>(service);
IComparable result = configuration.GetService<IComparable>();
Assert.Same(service, result);
}
示例9: GetService_ReturnsNull_WhenServiceTypeNotFound
public void GetService_ReturnsNull_WhenServiceTypeNotFound()
{
JobHostConfiguration configuration = new JobHostConfiguration();
object result = configuration.GetService(typeof(IComparable));
Assert.Null(result);
}
示例10: GetService_ThrowsArgumentNull_WhenServiceTypeIsNull
public void GetService_ThrowsArgumentNull_WhenServiceTypeIsNull()
{
JobHostConfiguration configuration = new JobHostConfiguration();
ArgumentNullException exception = Assert.Throws<ArgumentNullException>(
() => configuration.GetService(null)
);
Assert.Equal("serviceType", exception.ParamName);
}
示例11: GetService_ReturnsExpectedDefaultServices
public void GetService_ReturnsExpectedDefaultServices()
{
JobHostConfiguration configuration = new JobHostConfiguration();
IExtensionRegistry extensionRegistry = configuration.GetService<IExtensionRegistry>();
extensionRegistry.RegisterExtension<IComparable>("test1");
extensionRegistry.RegisterExtension<IComparable>("test2");
extensionRegistry.RegisterExtension<IComparable>("test3");
Assert.NotNull(extensionRegistry);
IComparable[] results = extensionRegistry.GetExtensions<IComparable>().ToArray();
Assert.Equal(3, results.Length);
IJobHostContextFactory jobHostContextFactory = configuration.GetService<IJobHostContextFactory>();
Assert.NotNull(jobHostContextFactory);
}
示例12: GetService_ReturnsExpectedDefaultServices
public void GetService_ReturnsExpectedDefaultServices(Type serviceType, Type expectedInstanceType)
{
JobHostConfiguration configuration = new JobHostConfiguration();
var service = configuration.GetService(serviceType);
Assert.Equal(expectedInstanceType, service.GetType());
}