本文整理汇总了C#中Autofac类的典型用法代码示例。如果您正苦于以下问题:C# Autofac类的具体用法?C# Autofac怎么用?C# Autofac使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Autofac类属于命名空间,在下文中一共展示了Autofac类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Load
protected override void Load(Autofac.ContainerBuilder builder)
{
base.Load(builder);
builder.Register<IBridgePayWS>(ctx =>
{
var moqBridgePayWS = new Mock<IBridgePayWS>();
moqBridgePayWS.Setup(b => b.CPSGetAccountPackages(It.IsAny<String>(), It.IsAny<String>()))
.Returns(MockData.CPSGetAccountPackages());
moqBridgePayWS.Setup(b => b.CPSGetCurrentAccountPackage(It.IsAny<String>(), It.IsAny<String>()))
.Returns(MockData.CPSGetCurrentAccountPackage());
moqBridgePayWS.Setup(
b => b.CPSGetAvailableAddOns(It.IsAny<String>(), It.IsAny<String>(), It.IsAny<String>()))
.Returns(MockData.CPSGetAvailableAddOns());
moqBridgePayWS.Setup(
b => b.ListCountries()
).Returns(MockData.ListCountries());
moqBridgePayWS.Setup(b => b.ListIndustries()).Returns(MockData.ListIndustries());
moqBridgePayWS.Setup(b => b.CPSGetContactInfo(It.IsAny<String>(), It.IsAny<String>()))
.Returns(MockData.CPSGetContactInfo());
return moqBridgePayWS.Object;
}).InstancePerHttpRequest();
}
示例2: RegisterStyleSheetFiles
public override System.Collections.Generic.IEnumerable<string> RegisterStyleSheetFiles(Autofac.ContainerBuilder containerBuilder, ICmsConfiguration configuration)
{
return new[]
{
"/file/bcms-blog/Content/Styles/bcms.blog.css"
};
}
示例3: ConfigureContainerBuilder
protected override void ConfigureContainerBuilder(Autofac.ContainerBuilder builder)
{
base.ConfigureContainerBuilder(builder);
builder.RegisterControllers(typeof(MvcApplication).Assembly);
builder.RegisterViewModels(typeof(MvcApplication).Assembly);
}
示例4: Load
protected override void Load(Autofac.ContainerBuilder builder)
{
builder.RegisterType<FaceComparer>()
.As<FaceComparer>()
.WithProperty("FaceAlignmentModelPath", GetAbsolutePath(Properties.Settings.Default.FaceAlignModelFile))
.WithProperty("FaceAlignClassifierPath", GetAbsolutePath(Properties.Settings.Default.FaceAlignClassifierFile))
.WithProperty("FaceRepositoryPath", GetAbsolutePath(Properties.Settings.Default.FaceRepositoryPath))
.WithProperty("IlluminateReferenceFilePath", GetAbsolutePath(Properties.Settings.Default.IlluminateRefFilePath))
.PropertiesAutowired();
if (EnableFaceComparer)
{
if (System.IO.Directory.Exists(PersonOfInterestLibraryPath))
{
var personRepository = SuspectsRepositoryManager.LoadFrom(PersonOfInterestLibraryPath);
builder.RegisterInstance(personRepository.Peoples)
.As<IEnumerable<PersonOfInterest>>()
.ExternallyOwned();
}
}
else
{
builder.Register(c => new PersonOfInterest[0]).SingleInstance();
builder.RegisterType<NullRepositoryFaceComparer>()
.As<IRepositoryFaceComparer>();
}
}
示例5: Load
protected override void Load(Autofac.ContainerBuilder builder)
{
builder.RegisterType<RestApplication>().As<RestApplication, IRestApplication>();
builder.RegisterType<SoapApplication>().As<SoapApplication, ISoapApplication>();
builder.RegisterType<CommandConverter>().As<ICommandConverter>();
SetupExtensibility(builder);
if (WithDatabase)
SetupPostgres(builder);
SetupPatterns(builder);
SetupSerialization(builder);
builder.RegisterType<RepositoryAuthentication>().As<IAuthentication>();
builder.RegisterType<RepositoryPrincipalFactory>().As<IPrincipalFactory>();
builder.RegisterType<PermissionManager>().As<IPermissionManager>().SingleInstance();
builder.RegisterType<LogFactory>().As<ILogFactory>().SingleInstance();
builder.RegisterType<NLogLogger>().As<ILogger>();
builder.RegisterType(typeof(ProcessingEngine)).As(typeof(IProcessingEngine)).SingleInstance();
builder.RegisterType<OnContainerBuild>().As<IStartable>();
base.Load(builder);
}
示例6: ConfigureRequestContainer
protected override void ConfigureRequestContainer(Autofac.ILifetimeScope existingContainer)
{
var builder = new ContainerBuilder();
builder.RegisterType<IdeastrikeContext>()
.AsSelf()
.SingleInstance();
builder.RegisterType<IdeaRepository>()
.AsImplementedInterfaces()
.SingleInstance();
builder.RegisterType<ActivityRepository>()
.AsImplementedInterfaces()
.SingleInstance();
builder.RegisterType<FeatureRepository>()
.AsImplementedInterfaces()
.SingleInstance();
builder.RegisterType<SettingsRepository>()
.AsImplementedInterfaces()
.SingleInstance();
builder.RegisterType<UserRepository>()
.AsImplementedInterfaces()
.SingleInstance();
builder.RegisterType<ImageRepository>()
.AsImplementedInterfaces()
.SingleInstance();
builder.Update(existingContainer.ComponentRegistry);
}
示例7: RegisterJavaScriptModules
public override System.Collections.Generic.IEnumerable<JavaScriptModuleDescriptor> RegisterJavaScriptModules(Autofac.ContainerBuilder containerBuilder, ICmsConfiguration configuration)
{
return new[]
{
blogJavaScriptModuleDescriptor
};
}
示例8: Load
protected override void Load(Autofac.ContainerBuilder builder)
{
base.Load(builder);
builder.RegisterType<PosixIdentitySource>()
.AsImplementedInterfaces()
.InstancePerLifetimeScope();
}
示例9: RegisterApplicationJqService
/// <summary>
/// Registers the jq service.
/// </summary>
/// <param name="builder">The builder.</param>
protected static void RegisterApplicationJqService(Autofac.ContainerBuilder builder)
{
builder.RegisterType<Miaow.Application.jq.Service.AddSortService>()
.As<Miaow.Application.jq.Service.IAddSortService>().InstancePerHttpRequest();
builder.RegisterType<Miaow.Application.jq.Service.ArticleService>()
.As<Miaow.Application.jq.Service.IArticleService>().InstancePerHttpRequest();
builder.RegisterType<Miaow.Application.jq.Service.HomeService>()
.As<Miaow.Application.jq.Service.IHomeService>().InstancePerHttpRequest();
builder.RegisterType<Miaow.Application.jq.Service.PageService>()
.As<Miaow.Application.jq.Service.IPageService>().InstancePerHttpRequest();
builder.RegisterType<Miaow.Application.jq.Service.PicInfoService>()
.As<Miaow.Application.jq.Service.IPicInfoService>().InstancePerHttpRequest();
builder.RegisterType<Miaow.Application.jq.Service.SearchService>()
.As<Miaow.Application.jq.Service.ISearchService>().InstancePerHttpRequest(); ;
builder.RegisterType<Miaow.Application.jq.Service.SightInfoService>()
.As<Miaow.Application.jq.Service.ISightInfoService>().InstancePerHttpRequest();
builder.RegisterType<Miaow.Application.jq.Service.SinaInfoService>()
.As<Miaow.Application.jq.Service.ISinaInfoService>().InstancePerHttpRequest();
builder.RegisterType<Miaow.Application.jq.Service.TicketService>()
.As<Miaow.Application.jq.Service.ITicketService>().InstancePerHttpRequest();
builder.RegisterType<Miaow.Application.jq.Service.TopClassService>()
.As<Miaow.Application.jq.Service.ITopClassService>().InstancePerHttpRequest();
builder.RegisterType<Miaow.Application.jq.Service.VideoInfoService>()
.As<Miaow.Application.jq.Service.IVideoInfoService>().InstancePerHttpRequest();
}
示例10: Load
protected override void Load(Autofac.ContainerBuilder builder)
{
base.Load(builder);
builder.RegisterType<HtpasswdIdentitySource>()
.AsImplementedInterfaces()
.SingleInstance();
}
示例11: SetupExtensibility
private static void SetupExtensibility(Autofac.ContainerBuilder builder, bool withAspects)
{
var dynamicProxy = new CastleDynamicProxyProvider();
var aopRepository = new AspectRepository(dynamicProxy);
var assemblies = Revenj.Utility.AssemblyScanner.GetAssemblies().Where(it => it.FullName.StartsWith("Revenj."));
builder.RegisterInstance(new PluginsConfiguration { Assemblies = assemblies });
builder.RegisterType<SystemInitialization>();
builder.RegisterType<AutofacObjectFactory>().As<IObjectFactory>().SingleInstance();
builder.RegisterType<AutofacMefProvider>().As<IExtensibilityProvider>().SingleInstance();
builder.RegisterGeneric(typeof(PluginRepository<>)).As(typeof(IPluginRepository<>)).SingleInstance();
builder.RegisterInstance(aopRepository).As<IAspectRegistrator, IAspectComposer, IInterceptorRegistrator>();
builder.RegisterInstance(dynamicProxy).As<IMixinProvider, IDynamicProxyProvider>();
if (withAspects)
{
foreach (var m in AssemblyScanner.GetAllTypes())
{
if (m.IsPublic && typeof(Autofac.Module).IsAssignableFrom(m) && m.GetConstructor(new Type[0]) != null)
builder.RegisterModule((Autofac.Module)Activator.CreateInstance(m));
}
builder.RegisterModule(new AspectsModule(aopRepository));
}
}
示例12: RegisterApplicationJqService
/// <summary>
/// Registers the jq service.
/// </summary>
/// <param name="builder">The builder.</param>
protected static void RegisterApplicationJqService(Autofac.ContainerBuilder builder)
{
builder.RegisterType<iPow.Application.jq.Service.AddSortService>()
.As<iPow.Application.jq.Service.IAddSortService>();
builder.RegisterType<iPow.Application.jq.Service.ArticleService>()
.As<iPow.Application.jq.Service.IArticleService>();
builder.RegisterType<iPow.Application.jq.Service.HomeService>()
.As<iPow.Application.jq.Service.IHomeService>();
builder.RegisterType<iPow.Application.jq.Service.PageService>()
.As<iPow.Application.jq.Service.IPageService>();
builder.RegisterType<iPow.Application.jq.Service.PicInfoService>()
.As<iPow.Application.jq.Service.IPicInfoService>();
builder.RegisterType<iPow.Application.jq.Service.SearchService>()
.As<iPow.Application.jq.Service.ISearchService>();
builder.RegisterType<iPow.Application.jq.Service.SightInfoService>()
.As<iPow.Application.jq.Service.ISightInfoService>();
builder.RegisterType<iPow.Application.jq.Service.SinaInfoService>()
.As<iPow.Application.jq.Service.ISinaInfoService>();
builder.RegisterType<iPow.Application.jq.Service.TicketService>()
.As<iPow.Application.jq.Service.ITicketService>();
builder.RegisterType<iPow.Application.jq.Service.TopClassService>()
.As<iPow.Application.jq.Service.ITopClassService>();
builder.RegisterType<iPow.Application.jq.Service.VideoInfoService>()
.As<iPow.Application.jq.Service.IVideoInfoService>();
//add 2012-4-28 JPomichael
builder.RegisterType<iPow.Application.jq.Service.SightInfoSortService>()
.As<iPow.Application.jq.Service.ISightInfoSortService>();
//end
}
示例13: Register
protected override void Register(Autofac.ContainerBuilder builder) {
builder.RegisterType<PlacementFileParser>().As<IPlacementFileParser>();
builder.RegisterType<StubCacheManager>().As<ICacheManager>();
builder.RegisterType<StubParallelCacheContext>().As<IParallelCacheContext>();
builder.RegisterType<InMemoryWebSiteFolder>().As<IWebSiteFolder>()
.As<InMemoryWebSiteFolder>().InstancePerLifetimeScope();
}
示例14: Load
protected override void Load(Autofac.ContainerBuilder builder)
{
builder.RegisterAssemblyTypes(Assembly.Load("EF-Learn.DAL"))
.Where(t => t.Name.EndsWith("Dal"))
.AsImplementedInterfaces()
.InstancePerLifetimeScope();
base.Load(builder);
}
示例15: ApplicationStartup
protected override void ApplicationStartup(Autofac.ILifetimeScope container, Nancy.Bootstrapper.IPipelines pipelines)
{
CookieBasedSessions.Enable(pipelines);
base.ApplicationStartup(container, pipelines);
GlobalHost.DependencyResolver = new AutofacDependencyResolver(container);
RouteTable.Routes.MapHubs();
}