本文整理汇总了C#中Autofac.ContainerBuilder类的典型用法代码示例。如果您正苦于以下问题:C# ContainerBuilder类的具体用法?C# ContainerBuilder怎么用?C# ContainerBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ContainerBuilder类属于Autofac命名空间,在下文中一共展示了ContainerBuilder类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Init
public void Init() {
_settingsA = new ShellSettings { Name = "Alpha" };
_settingsB = new ShellSettings { Name = "Beta", };
_routes = new RouteCollection();
var rootBuilder = new ContainerBuilder();
rootBuilder.Register(ctx => _routes);
rootBuilder.RegisterType<ShellRoute>().InstancePerDependency();
rootBuilder.RegisterType<RunningShellTable>().As<IRunningShellTable>().SingleInstance();
rootBuilder.RegisterModule(new WorkContextModule());
rootBuilder.RegisterType<WorkContextAccessor>().As<IWorkContextAccessor>().InstancePerMatchingLifetimeScope("shell");
rootBuilder.RegisterType<HttpContextAccessor>().As<IHttpContextAccessor>();
rootBuilder.RegisterType<ExtensionManager>().As<IExtensionManager>();
rootBuilder.RegisterType<StubCacheManager>().As<ICacheManager>();
rootBuilder.RegisterType<StubAsyncTokenProvider>().As<IAsyncTokenProvider>();
rootBuilder.RegisterType<StubParallelCacheContext>().As<IParallelCacheContext>();
_rootContainer = rootBuilder.Build();
_containerA = _rootContainer.BeginLifetimeScope(
"shell",
builder => {
builder.Register(ctx => _settingsA);
builder.RegisterType<RoutePublisher>().As<IRoutePublisher>().InstancePerMatchingLifetimeScope("shell");
});
_containerB = _rootContainer.BeginLifetimeScope(
"shell",
builder => {
builder.Register(ctx => _settingsB);
builder.RegisterType<RoutePublisher>().As<IRoutePublisher>().InstancePerMatchingLifetimeScope("shell");
});
}
开发者ID:dioptre,项目名称:nkd,代码行数:33,代码来源:ShellRouteTests.cs
示例2: Init
public void Init() {
_contentDefinitionManager = new Mock<IContentDefinitionManager>();
var builder = new ContainerBuilder();
builder.RegisterType<DefaultContentManager>().As<IContentManager>();
builder.RegisterType<DefaultContentManagerSession>().As<IContentManagerSession>();
builder.RegisterInstance(_contentDefinitionManager.Object);
builder.RegisterInstance(new Mock<IContentDisplay>().Object);
builder.RegisterType<AlphaPartHandler>().As<IContentHandler>();
builder.RegisterType<BetaPartHandler>().As<IContentHandler>();
builder.RegisterType<GammaPartHandler>().As<IContentHandler>();
builder.RegisterType<DeltaPartHandler>().As<IContentHandler>();
builder.RegisterType<EpsilonPartHandler>().As<IContentHandler>();
builder.RegisterType<FlavoredPartHandler>().As<IContentHandler>();
builder.RegisterType<StyledHandler>().As<IContentHandler>();
builder.RegisterType<DefaultShapeTableManager>().As<IShapeTableManager>();
builder.RegisterType<ShapeTableLocator>().As<IShapeTableLocator>();
builder.RegisterType<DefaultShapeFactory>().As<IShapeFactory>();
builder.RegisterType<DefaultContentDisplay>().As<IContentDisplay>();
builder.RegisterType<StubExtensionManager>().As<IExtensionManager>();
builder.RegisterGeneric(typeof(Repository<>)).As(typeof(IRepository<>));
_session = _sessionFactory.OpenSession();
builder.RegisterInstance(new TestSessionLocator(_session)).As<ISessionLocator>();
_container = builder.Build();
_manager = _container.Resolve<IContentManager>();
}
开发者ID:sjbisch,项目名称:Orchard,代码行数:31,代码来源:DefaultContentManagerTests.cs
示例3: Register
public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder)
{
builder.RegisterType<ShippingByWeightService>().As<IShippingByWeightService>().InstancePerHttpRequest();
//data layer
var dataSettingsManager = new DataSettingsManager();
var dataProviderSettings = dataSettingsManager.LoadSettings();
if (dataProviderSettings != null && dataProviderSettings.IsValid())
{
//register named context
builder.Register<IDbContext>(c => new ShippingByWeightObjectContext(dataProviderSettings.DataConnectionString))
.Named<IDbContext>("nop_object_context_shipping_weight_zip")
.InstancePerHttpRequest();
builder.Register<ShippingByWeightObjectContext>(c => new ShippingByWeightObjectContext(dataProviderSettings.DataConnectionString))
.InstancePerHttpRequest();
}
else
{
//register named context
builder.Register<IDbContext>(c => new ShippingByWeightObjectContext(c.Resolve<DataSettings>().DataConnectionString))
.Named<IDbContext>("nop_object_context_shipping_weight_zip")
.InstancePerHttpRequest();
builder.Register<ShippingByWeightObjectContext>(c => new ShippingByWeightObjectContext(c.Resolve<DataSettings>().DataConnectionString))
.InstancePerHttpRequest();
}
//override required repository with our custom context
builder.RegisterType<EfRepository<ShippingByWeightRecord>>()
.As<IRepository<ShippingByWeightRecord>>()
.WithParameter(ResolvedParameter.ForNamed<IDbContext>("nop_object_context_shipping_weight_zip"))
.InstancePerHttpRequest();
}
开发者ID:emretiryaki,项目名称:paymill-nopcommerce,代码行数:35,代码来源:DependencyRegistrar.cs
示例4: BuildContainer
public static IContainer BuildContainer()
{
var builder = new ContainerBuilder();
builder.RegisterType<StatisticsViewModel>();
builder.RegisterType<DetailsViewModel>();
builder.RegisterType<MainView>();
builder.RegisterType<MainViewModel>();
builder.RegisterType<CameraView>();
builder.RegisterType<CameraViewModel>();
builder.RegisterType<MvxMessengerHub>().As<IMvxMessenger>().SingleInstance();
builder.RegisterType<ApplicationDataRepository>().As<IApplicationDataRepository>();
builder.RegisterAssemblyTypes(typeof(MyShuttleClient).Assembly)
.Where(t => t.Name.EndsWith("Service"))
.AsImplementedInterfaces();
builder.RegisterAssemblyTypes(typeof(MyShuttleClient).Assembly)
.Where(t => t.Name.EndsWith("ServiceSingleton"))
.AsImplementedInterfaces().SingleInstance();
builder.RegisterType<MyShuttleClient>().As<IMyShuttleClient>();
return builder.Build();
}
开发者ID:EmiiFont,项目名称:MyShuttle_RC,代码行数:27,代码来源:IocContainer.cs
示例5: RegisterContainer
private void RegisterContainer() {
var builder = new ContainerBuilder();
builder.RegisterControllers(Assembly.GetExecutingAssembly());
_pluginServicee.Startup(builder);
_container = builder.Build();
DependencyResolver.SetResolver(new AutofacDependencyResolver(_container));
}
开发者ID:fengzijun,项目名称:MvcPluginByGriffin.mvccontrib,代码行数:7,代码来源:Global.asax.cs
示例6: Application_Start
protected void Application_Start()
{
Database.SetInitializer(new TrainingDbInitializer());
var builder = new ContainerBuilder();
builder.RegisterType<EditableUserRepository>().As<IEditableRepository<User>>();
builder.RegisterType<EditableSysOpRepository>().As<IEditableRepository<SysOp>>();
builder.RegisterType<CompanyRepository>().As<IEditableRepository<Company>>();
builder.RegisterType<CommentRepository>().As<IEditableRepository<Comment>>();
builder.RegisterType<CourseRepository>().As<IEditableRepository<Course>>();
builder.RegisterType<EmployeeCourseRepository>().As<IEditableRepository<EmployeeCourse>>();
builder.RegisterType<DivisionRepository>().As<IEditableRepository<Division>>();
builder.RegisterType<EmployeeRepository>().As<IEditableRepository<Employee>>();
builder.RegisterType<EmployeeCourseStatusRepository>().As<IEditableRepository<EmployeeCourseStatus>>();
builder.RegisterType<InstructorRepository>().As<IEditableRepository<Instructor>>();
builder.RegisterType<RaceRepository>().As<IEditableRepository<Race>>();
builder.RegisterType<RegionRepository>().As<IEditableRepository<Region>>();
builder.RegisterType<ResultRepository>().As<IEditableRepository<Result>>();
builder.RegisterType<EmployeeDocumentRepository>().As<IEditableRepository<EmployeeDocument>>();
builder.RegisterType<TrainingScheduleRepository>().As<IEditableRepository<TrainingSchedule>>();
builder.RegisterType<EmployeeTrainingScheduleRepository>().As<IEditableRepository<EmployeeTrainingSchedule>>();
builder.RegisterType<TrainingManualRepository>().As<IEditableRepository<TrainingManual>>();
builder.RegisterType<CompanyBudgetRepository>().As<IEditableRepository<CompanyBudget>>();
builder.RegisterType<DivisionBudgetRepository>().As<IEditableRepository<DivisionBudget>>();
builder.RegisterApiControllers(Assembly.GetExecutingAssembly());
var container = builder.Build();
DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
GlobalConfiguration.Configuration.DependencyResolver = new AutofacWebApiDependencyResolver(container);
GlobalConfiguration.Configure(WebApiConfig.Register);
GlobalConfiguration.Configuration.MessageHandlers.Add(new BasicTrainingAuthMessageHandler());
}
开发者ID:Ruandv,项目名称:Training,代码行数:34,代码来源:Global.asax.cs
示例7: Init
public static void Init()
{
var serviceBusConnectionString = ConfigurationManager.ConnectionStrings["ServiceBus"].ConnectionString;
var builder = new ContainerBuilder();
var typeProvider = new AssemblyScanningTypeProvider(
Assembly.GetAssembly(typeof(ExampleEventHandler)),
Assembly.GetAssembly(typeof(ExampleCommand))
);
var applicationName = Assembly.GetExecutingAssembly().ToNimbusName();
var instanceName = Environment.MachineName;
builder.RegisterNimbus(typeProvider);
builder.RegisterType<NimbusLogger>().As<ILogger>();
builder.Register(componetContext => new BusBuilder()
.Configure()
.WithConnectionString(serviceBusConnectionString)
.WithNames(applicationName, instanceName)
.WithTypesFrom(typeProvider)
.WithDefaultTimeout(TimeSpan.FromSeconds(30))
.WithAutofacDefaults(componetContext)
.Build())
.As<IBus>()
.AutoActivate()
.OnActivated(o => o.Instance.Start())
.SingleInstance();
_container = builder.Build();
}
开发者ID:WIBORI,项目名称:api-template,代码行数:29,代码来源:Program.cs
示例8: Configure
public static void Configure()
{
var assemblies = BuildManager.GetReferencedAssemblies().Cast<Assembly>().ToArray();
var builder = new ContainerBuilder();
builder.RegisterAssemblyTypes(assemblies)
.Where(t => typeof(IStartable).IsAssignableFrom(t))
.As<IStartable>()
.SingleInstance();
builder.RegisterAssemblyModules(assemblies);
builder.RegisterControllers(Assembly.GetExecutingAssembly());
builder.RegisterApiControllers(Assembly.GetExecutingAssembly());
var container = builder.Build();
// Set the dependency resolver for Web API.
var webApiResolver = new AutofacWebApiDependencyResolver(container);
GlobalConfiguration.Configuration.DependencyResolver = webApiResolver;
// Set the dependency resolver for MVC.
var mvcResolver = new AutofacDependencyResolver(container);
DependencyResolver.SetResolver(mvcResolver);
}
开发者ID:desflan,项目名称:RiskAnalysis,代码行数:25,代码来源:IocConfig.cs
示例9: GetMinimalBuilder
public static ContainerBuilder GetMinimalBuilder()
{
var builder = new ContainerBuilder();
builder.Register(c => ReadAppConfigConfig()).SingleInstance();
return builder;
}
开发者ID:royra,项目名称:pwipper,代码行数:7,代码来源:ConfigurationHelpers.cs
示例10: RegisterTypes
public static void RegisterTypes()
{
var builder = new ContainerBuilder();
builder.RegisterType<VideoRepository>().As<IVideoRepository>().InstancePerLifetimeScope();
builder.RegisterType<OrderRepository>().As<IOrderRepository>().InstancePerLifetimeScope();
builder.RegisterType<UserRepository>().As<IUserRepository>();
builder.RegisterType<MockPaymentProcessor>().As<IPaymentProcessor>().InstancePerLifetimeScope();
builder.RegisterType<StoreController>()
.UsingConstructor(typeof(IVideoRepository), typeof(IUserRepository));
builder.RegisterType<CartController>()
.UsingConstructor(typeof(IVideoRepository));
builder.RegisterType<WishlistController>()
.UsingConstructor(typeof(IUserRepository), typeof(IVideoRepository));
builder.RegisterType<OrderController>()
.UsingConstructor(typeof(IVideoRepository), typeof(IOrderRepository), typeof(IUserRepository), typeof(IPaymentProcessor));
builder.RegisterType<HomeController>()
.UsingConstructor(typeof(IVideoRepository), typeof(IOrderRepository), typeof(IUserRepository));
builder.RegisterType<VideosController>()
.UsingConstructor(typeof(IVideoRepository));
builder.RegisterType<OrdersController>()
.UsingConstructor(typeof(IOrderRepository));
builder.RegisterType<UsersController>()
.UsingConstructor(typeof(IUserRepository));
builder.RegisterType<AccountController>()
.UsingConstructor(typeof(IUserRepository));
var container = builder.Build();
var resolver = new AutofacDependencyResolver(container);
DependencyResolver.SetResolver(resolver);
}
开发者ID:BGorski90,项目名称:SoccerHighlightsStore,代码行数:29,代码来源:AutofacConfig.cs
示例11: RegisterTypes
private static void RegisterTypes(ContainerBuilder builder)
{
string baseDirectory = HttpContext.Current.Server.MapPath("~/App_Data") + ConfigurationManager.AppSettings["dataFolderName"];
builder.RegisterControllers(typeof(MvcApplication).Assembly);
var repositoryAssemblies = Assembly.Load("FileRepository");
builder.RegisterAssemblyTypes(repositoryAssemblies).AsImplementedInterfaces().WithParameter(new NamedParameter("path", baseDirectory));
var serviceAssemblies = Assembly.Load("Services");
builder.RegisterAssemblyTypes(serviceAssemblies).AsImplementedInterfaces();
var configurationManagerWrapperAssembly = Assembly.Load("ConfigurationManagerWrapper");
builder.RegisterAssemblyTypes(configurationManagerWrapperAssembly).AsImplementedInterfaces();
var fileAssembly = Assembly.Load("SystemFileAdapter");
builder.RegisterAssemblyTypes(fileAssembly).AsImplementedInterfaces();
//builder.RegisterType<NLogLogger>().As<ILogger>();
builder.Register(c => new NLogLogger()).As<ILogger>().InstancePerHttpRequest();
builder.RegisterType<UserHub>();
builder.RegisterType<TodoHub>();
// builder.RegisterModule(new ConfigurationSettingsReader("autofac"));
builder.RegisterFilterProvider();
}
开发者ID:kevinrjones,项目名称:DevWeek2013,代码行数:25,代码来源:Global.asax.cs
示例12: Init
public void Init(IEnumerable<Type> dataMigrations) {
var builder = new ContainerBuilder();
_folders = new StubFolders();
var contentDefinitionManager = new Mock<IContentDefinitionManager>().Object;
builder.RegisterInstance(new ShellSettings { DataTablePrefix = "TEST_"});
builder.RegisterType<SqlServerDataServicesProvider>().As<IDataServicesProvider>();
builder.RegisterType<DataServicesProviderFactory>().As<IDataServicesProviderFactory>();
builder.RegisterType<NullInterpreter>().As<IDataMigrationInterpreter>();
builder.RegisterInstance(_folders).As<IExtensionFolders>();
builder.RegisterInstance(contentDefinitionManager).As<IContentDefinitionManager>();
builder.RegisterType<ExtensionManager>().As<IExtensionManager>();
builder.RegisterType<DataMigrationManager>().As<IDataMigrationManager>();
builder.RegisterGeneric(typeof(Repository<>)).As(typeof(IRepository<>));
builder.RegisterType<StubCacheManager>().As<ICacheManager>();
builder.RegisterType<StubParallelCacheContext>().As<IParallelCacheContext>();
builder.RegisterType<StubAsyncTokenProvider>().As<IAsyncTokenProvider>();
_session = _sessionFactory.OpenSession();
builder.RegisterInstance(new DefaultContentManagerTests.TestSessionLocator(_session)).As<ISessionLocator>().As<ITransactionManager>();
foreach(var type in dataMigrations) {
builder.RegisterType(type).As<IDataMigration>();
}
_container = builder.Build();
_container.Resolve<IExtensionManager>();
_dataMigrationManager = _container.Resolve<IDataMigrationManager>();
_repository = _container.Resolve<IRepository<DataMigrationRecord>>();
_transactionManager = _container.Resolve<ITransactionManager>();
InitDb();
}
开发者ID:dioptre,项目名称:nkd,代码行数:31,代码来源:DataMigrationTests.cs
示例13: Load
protected override void Load(ContainerBuilder builder)
{
builder.RegisterModule(new RepositoryModule());
builder.RegisterType(typeof(SampleArchContext)).As(typeof(DbContext)).InstancePerLifetimeScope();
builder.RegisterType(typeof(UnitOfWork)).As(typeof(IUnitOfWork)).InstancePerRequest();
}
开发者ID:syedshah,项目名称:MVCRepository,代码行数:7,代码来源:EFModule.cs
示例14: DictionaryDocument_Operations
public void DictionaryDocument_Operations()
{
var builder = new ContainerBuilder();
builder.RegisterModule(new SolrNetModule("http://localhost:8983/solr"));
var container = builder.Build();
var m = container.Resolve<ISolrOperations<Dictionary<string, object>>>();
}
开发者ID:rivuc,项目名称:SolrNet-1,代码行数:7,代码来源:AutofacTests.cs
示例15: TheyShouldBeResolvable
public void TheyShouldBeResolvable()
{
var interceptorTypes = new[] {typeof (DummyInterceptor)};
var builder = new ContainerBuilder();
var typeProvider = Substitute.For<ITypeProvider>();
typeProvider.InterceptorTypes.Returns(interceptorTypes);
builder.RegisterNimbus(typeProvider);
using (var container = builder.Build())
using (var dependencyResolver = container.Resolve<IDependencyResolver>())
using (var scope = dependencyResolver.CreateChildScope())
{
var interceptorSetting = new GlobalOutboundInterceptorTypesSetting
{
Value = interceptorTypes
};
var outboundInterceptorFactory = new OutboundInterceptorFactory(interceptorSetting,
new PropertyInjector(Substitute.For<IClock>(),
Substitute.For<IDispatchContextManager>(),
Substitute.For<ILargeMessageBodyStore>()));
var dummyNimbusMessage = new NimbusMessage("nullQueue");
var interceptors = outboundInterceptorFactory.CreateInterceptors(scope, dummyNimbusMessage);
interceptors.Count().ShouldBe(1);
}
}
开发者ID:fenix2222,项目名称:Nimbus,代码行数:29,代码来源:WhenRegisteringInterceptorsWithAutofac.cs
示例16: Application_Start
protected void Application_Start() {
AreaRegistration.RegisterAllAreas();
WebApiConfig.Register(GlobalConfiguration.Configuration);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
Store = new DocumentStore() { ConnectionStringName = "Onboarding" };
Store.Initialize();
var builder = new ContainerBuilder();
Store.Conventions.RegisterIdConvention<User>((dbname, commands, user) => "users/" + user.UserName);
builder.Register(c => {
var store = new DocumentStore {
ConnectionStringName = "Onboarding",
DefaultDatabase = "Onboarding"
}.Initialize();
return store;
}).As<IDocumentStore>().SingleInstance();
builder.Register(c => c.Resolve<IDocumentStore>().OpenAsyncSession()).As<IAsyncDocumentSession>().InstancePerLifetimeScope();
}
开发者ID:meridiumlabs,项目名称:Meridium.Onboarding,代码行数:27,代码来源:Global.asax.cs
示例17: Init
public void Init() {
var builder = new ContainerBuilder();
//builder.RegisterModule(new ImplicitCollectionSupportModule());
builder.RegisterType<MembershipService>().As<IMembershipService>();
builder.RegisterType<DefaultContentQuery>().As<IContentQuery>();
builder.RegisterType<DefaultContentManager>().As<IContentManager>();
builder.RegisterType(typeof(SettingsFormatter))
.As(typeof(IMapper<XElement, SettingsDictionary>))
.As(typeof(IMapper<SettingsDictionary, XElement>));
builder.RegisterType<ContentDefinitionManager>().As<IContentDefinitionManager>();
builder.RegisterType<DefaultContentManagerSession>().As<IContentManagerSession>();
builder.RegisterType<UserPartHandler>().As<IContentHandler>();
builder.RegisterType<StubWorkContextAccessor>().As<IWorkContextAccessor>();
builder.RegisterType<OrchardServices>().As<IOrchardServices>();
builder.RegisterAutoMocking(MockBehavior.Loose);
builder.RegisterGeneric(typeof(Repository<>)).As(typeof(IRepository<>));
builder.RegisterInstance(new Mock<IMessageEventHandler>().Object);
builder.RegisterType<DefaultMessageManager>().As<IMessageManager>();
builder.RegisterType<DefaultShapeTableManager>().As<IShapeTableManager>();
builder.RegisterType<DefaultShapeFactory>().As<IShapeFactory>();
builder.RegisterType<StubExtensionManager>().As<IExtensionManager>();
builder.RegisterType<DefaultContentDisplay>().As<IContentDisplay>();
_session = _sessionFactory.OpenSession();
builder.RegisterInstance(new TestSessionLocator(_session)).As<ISessionLocator>();
_container = builder.Build();
_membershipService = _container.Resolve<IMembershipService>();
}
开发者ID:juaqaai,项目名称:CompanyGroup,代码行数:28,代码来源:MembershipServiceTests.cs
示例18: Load
protected override void Load(ContainerBuilder builder)
{
builder.RegisterType<ViewFactory>().As<IViewFactory>().SingleInstance();
builder.RegisterType<Navigator>().As<INavigator>().SingleInstance();
builder.Register<INavigation>(ctx => App.Current.MainPage.Navigation).SingleInstance();
}
开发者ID:jperezaguila,项目名称:BlocNotasCurso,代码行数:7,代码来源:AutoFacMoludo.cs
示例19: Load
/// <summary>
/// Override to add registrations to the container.
/// </summary>
protected override void Load(ContainerBuilder builder)
{
base.Load(builder);
Log.Trace("Registering Cyclops.DependencyInjection module");
builder.RegisterCyclopsRepositories<PetstoreRepository>("PetstoreDatabase");
}
开发者ID:neutmute,项目名称:Cyclops,代码行数:10,代码来源:AutofacModule.cs
示例20: Init
public void Init() {
_tempFolderName = Path.GetTempFileName();
File.Delete(_tempFolderName);
var assembly = GetType().Assembly;
foreach (var name in assembly.GetManifestResourceNames()) {
if (name.StartsWith(DataPrefix)) {
string text;
using (var stream = assembly.GetManifestResourceStream(name)) {
using (var reader = new StreamReader(stream))
text = reader.ReadToEnd();
}
// Pro filtering
var relativePath = name
.Substring(DataPrefix.Length)
.Replace(".txt", ":txt")
.Replace(".recipe.xml", ":recipe:xml")
.Replace('.', Path.DirectorySeparatorChar)
.Replace(":txt", ".txt")
.Replace(":recipe:xml", ".recipe.xml");
var targetPath = Path.Combine(_tempFolderName, relativePath);
Directory.CreateDirectory(Path.GetDirectoryName(targetPath));
using (var stream = new FileStream(targetPath, FileMode.Create)) {
using (var writer = new StreamWriter(stream)) {
writer.Write(text);
}
}
}
}
var builder = new ContainerBuilder();
var harvester = new ExtensionHarvester(new StubCacheManager(), new StubWebSiteFolder(), new Mock<ICriticalErrorProvider>().Object);
_folders = new ModuleFolders(new[] { _tempFolderName }, harvester);
builder.RegisterType<RecipeManager>().As<IRecipeManager>();
builder.RegisterType<RecipeHarvester>().As<IRecipeHarvester>();
builder.RegisterType<RecipeStepExecutor>().As<IRecipeStepExecutor>();
builder.RegisterType<StubStepQueue>().As<IRecipeStepQueue>().InstancePerLifetimeScope();
builder.RegisterType<StubRecipeJournal>().As<IRecipeJournal>();
builder.RegisterType<StubRecipeScheduler>().As<IRecipeScheduler>();
builder.RegisterType<ExtensionManager>().As<IExtensionManager>();
builder.RegisterType<StubAppDataFolder>().As<IAppDataFolder>();
builder.RegisterType<StubClock>().As<IClock>();
builder.RegisterType<StubCacheManager>().As<ICacheManager>();
builder.RegisterType<StubParallelCacheContext>().As<IParallelCacheContext>();
builder.RegisterType<StubAsyncTokenProvider>().As<IAsyncTokenProvider>();
builder.RegisterInstance(_folders).As<IExtensionFolders>();
builder.RegisterInstance(new Mock<IRecipeExecuteEventHandler>().Object);
builder.RegisterType<Environment.Extensions.ExtensionManagerTests.StubLoaders>().As<IExtensionLoader>();
builder.RegisterType<RecipeParser>().As<IRecipeParser>();
builder.RegisterType<StubWebSiteFolder>().As<IWebSiteFolder>();
builder.RegisterType<CustomRecipeHandler>().As<IRecipeHandler>();
_container = builder.Build();
_recipeManager = _container.Resolve<IRecipeManager>();
_recipeParser = _container.Resolve<IRecipeParser>();
_recipeHarvester = _container.Resolve<IRecipeHarvester>();
}
开发者ID:kanujhun,项目名称:orchard,代码行数:60,代码来源:RecipeManagerTests.cs
注:本文中的Autofac.ContainerBuilder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论