本文整理汇总了C#中Autofac.ContainerBuilder.RegisterAggregateService方法的典型用法代码示例。如果您正苦于以下问题:C# ContainerBuilder.RegisterAggregateService方法的具体用法?C# ContainerBuilder.RegisterAggregateService怎么用?C# ContainerBuilder.RegisterAggregateService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Autofac.ContainerBuilder
的用法示例。
在下文中一共展示了ContainerBuilder.RegisterAggregateService方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RegisterAggregateService_WithType_RegistersServiceInterface
public void RegisterAggregateService_WithType_RegistersServiceInterface()
{
var builder = new ContainerBuilder();
builder.RegisterAggregateService(typeof(IMyContext));
var container = builder.Build();
Assert.That(container.IsRegistered<IMyContext>());
}
示例2: Load
protected override void Load(ContainerBuilder builder)
{
// Aggregate Services
builder.RegisterAggregateService<IComponents>();
// Settings
builder.RegisterType<CodeGenerator>().As<ICodeGenerator>();
builder.RegisterType<EmailSender>().As<IEmailSender>();
builder.RegisterType<SmsSender>().As<ISmsSender>();
}
示例3: RegisterAggregateService_IsPerDependencyScoped
public void RegisterAggregateService_IsPerDependencyScoped()
{
var builder = new ContainerBuilder();
builder.RegisterAggregateService<IMyContext>();
builder.RegisterInstance(new Mock<IMyService>().Object);
var container = builder.Build();
var firstInstance = container.Resolve<IMyContext>();
var secondInstance = container.Resolve<IMyContext>();
Assert.That(firstInstance, Is.Not.SameAs(secondInstance));
}
示例4: Setup
public void Setup()
{
_someDependencyMock = new Mock<ISomeDependency>().Object;
_someOtherDependencyMock = new Mock<ISomeOtherDependency>().Object;
var builder = new ContainerBuilder();
builder.RegisterAggregateService<ISubService>();
builder.RegisterInstance(_someDependencyMock);
builder.RegisterInstance(_someOtherDependencyMock);
_container = builder.Build();
_aggregateService = _container.Resolve<ISubService>();
}
示例5: RegisterAggregateService_DifferentLifeTimeScopes_YieldsDifferentInstances
public void RegisterAggregateService_DifferentLifeTimeScopes_YieldsDifferentInstances()
{
var builder = new ContainerBuilder();
builder.RegisterAggregateService(typeof(IMyContext));
builder.RegisterType<MyServiceImpl>()
.As<IMyService>()
.InstancePerLifetimeScope();
var container = builder.Build();
var rootScope = container.Resolve<IMyContext>();
var subScope = container.BeginLifetimeScope().Resolve<IMyContext>();
Assert.That(rootScope.MyService, Is.Not.SameAs(subScope.MyService));
}
示例6: Load
protected override void Load(ContainerBuilder builder)
{
// Aggregate Services
builder.RegisterAggregateService<IServices>();
builder.RegisterAggregateService<IAdminServices>();
// All Services
builder.RegisterAssemblyTypes(ThisAssembly)
.Where(t => t.Name.EndsWith("Service"))
.PropertiesAutowired()
.AsImplementedInterfaces();
// Settings
builder.RegisterType<DictionaryAdapterFactory>().As<IDictionaryAdapterFactory>().SingleInstance();
// Resolve ISettings by resolving the DictionaryAdapterFactory and initialising it with AppSettings from web.config
builder.Register(x => x.Resolve<IDictionaryAdapterFactory>()
.GetAdapter<ISettings>(ConfigurationManager.AppSettings))
.As<ISettings>().SingleInstance();
// Resolve the specified settings by resolving ISettings then just taking the appropriate property
builder.Register(x => x.Resolve<ISettings>().Twilio).As<ITwilioSettings>();
builder.Register(x => x.Resolve<ISettings>().Aws).As<IAwsSettings>();
}
示例7: Load
protected override void Load(ContainerBuilder builder)
{
builder.RegisterType<RiskContext>().As<IRiskContext>().InstancePerRequest();
builder.RegisterType<RiskContext>().As<DbContext>().InstancePerRequest();
builder.RegisterAggregateService<IServices>();
builder.RegisterType<CustomerService>().As<ICustomerService>();
builder.RegisterType<SettledBetService>().As<ISettledBetService>();
builder.RegisterType<UnsettledBetService>().As<IUnsettledBetService>();
builder.RegisterType<CustomerAnalysisService>().As<ICustomerAnalysisService>();
builder.RegisterType<UnsettledBetAnalysisService>().As<IUnsettledBetAnalysisService>();
builder.RegisterType<CustomerCalculatorService>().As<ICustomerCalculatorService>();
builder.RegisterType<BetCalculatorService>().As<IBetCalculatorService>();
base.Load(builder);
}
示例8: Setup
public void Setup()
{
_someDependencyMock = new Mock<ISomeDependency>().Object;
var builder = new ContainerBuilder();
builder.RegisterAggregateService<IMyContext>();
builder.RegisterType<MyServiceImpl>()
.As<IMyService>()
.InstancePerDependency();
builder.RegisterInstance(_someDependencyMock);
_container = builder.Build();
_aggregateService = _container.Resolve<IMyContext>();
}
示例9: RegisterAggregateService_WithNullInterfaceType_ThrowsArgumentNullException
public void RegisterAggregateService_WithNullInterfaceType_ThrowsArgumentNullException()
{
var builder = new ContainerBuilder();
builder.RegisterAggregateService(null);
}
示例10: RegisterAggregateService_WithNonInterfaceType_ThrowsArgumentException
public void RegisterAggregateService_WithNonInterfaceType_ThrowsArgumentException()
{
var builder = new ContainerBuilder();
builder.RegisterAggregateService(typeof(MyServiceImpl));
}