本文整理汇总了C#中ITypeFinder.GetAssemblies方法的典型用法代码示例。如果您正苦于以下问题:C# ITypeFinder.GetAssemblies方法的具体用法?C# ITypeFinder.GetAssemblies怎么用?C# ITypeFinder.GetAssemblies使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITypeFinder
的用法示例。
在下文中一共展示了ITypeFinder.GetAssemblies方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Register
public void Register(Autofac.ContainerBuilder builder, ITypeFinder typeFinder)
{
builder.RegisterType<WorkflowEngine>().As<IWorkflowEngine>().InstancePerHttpRequest();
builder.RegisterAssemblyTypes(typeFinder.GetAssemblies().ToArray())
.AssignableTo<IAutoActivityHandler>()
.AsImplementedInterfaces();
Assembly[] assemblies = typeFinder.GetAssemblies().ToArray();
builder.RegisterAssemblyTypes(assemblies)
.AssignableTo<IAutoActivityHandler>()
.AsImplementedInterfaces();
//regisger [UUID("ApplyQuota-2.0-Approve-ActivityExecutedEvent")]
var handlers = typeFinder.FindClassesOfType(typeof(IAutoActivityHandler)).ToList();
foreach (var handler in handlers)
{
object[] attrs = handler.GetCustomAttributes(typeof(UUIDAttribute), false);
string uuid = string.Empty;
if (attrs != null)
{
foreach (UUIDAttribute attr in attrs)
{
uuid = attr.UUID;
}
builder.RegisterType(handler).As<IAutoActivityHandler>().Keyed<IAutoActivityHandler>(uuid)
.InstancePerHttpRequest();
}
}
//regisger [UUID("ApplyQuota-2.0-Approve-ActivityExecutedEvent")]
var consumers = typeFinder.FindClassesOfType(typeof(IConsumer<>)).ToList();
foreach (var consumer in consumers)
{
object[] attrs = consumer.GetCustomAttributes(typeof(UUIDAttribute), false);
string uuid = string.Empty;
if (attrs != null)
{
foreach (UUIDAttribute attr in attrs)
{
uuid = attr.UUID;
}
var interfaceType = consumer.FindInterfaces((type, criteria) =>
{
var isMatch = type.IsGenericType && ((Type)criteria).IsAssignableFrom(type.GetGenericTypeDefinition());
return isMatch;
}, typeof(IConsumer<>))[0];
builder.RegisterType(consumer).As(interfaceType)
.Keyed(uuid, interfaceType)
.InstancePerHttpRequest();
}
}
}
示例2: Register
public void Register(ContainerBuilder builder, ITypeFinder typeFinder)
{
//HttpContext
builder.Register(c =>
//register FakeHttpContext when HttpContext is not available
HttpContext.Current != null
? (new HttpContextWrapper(HttpContext.Current) as HttpContextBase)
: (new FakeHttpContext("~/") as HttpContextBase))
.As<HttpContextBase>()
.InstancePerLifetimeScope();
builder.Register(c => c.Resolve<HttpContextBase>().Request)
.As<HttpRequestBase>()
.InstancePerLifetimeScope();
builder.Register(c => c.Resolve<HttpContextBase>().Response)
.As<HttpResponseBase>()
.InstancePerLifetimeScope();
builder.Register(c => c.Resolve<HttpContextBase>().Server)
.As<HttpServerUtilityBase>()
.InstancePerLifetimeScope();
builder.Register(c => c.Resolve<HttpContextBase>().Session)
.As<HttpSessionStateBase>()
.InstancePerLifetimeScope();
builder.RegisterType<PageHeadBuilder>().As<IPageHeadBuilder>().InstancePerLifetimeScope();
//MVC
builder.RegisterControllers(typeFinder.GetAssemblies().ToArray());
//Api
builder.RegisterApiControllers(typeFinder.GetAssemblies().ToArray());
//Route
builder.RegisterType<RoutePublisher>().As<IRoutePublisher>().SingleInstance();
builder.RegisterType<WebWorkContext>().As<IWorkContext>().InstancePerLifetimeScope();
//Cache
builder.RegisterType<MemoryCacheManager>().As<ICacheManager>().SingleInstance();
//WebHelper
builder.RegisterType<WebHelper>().As<IWebHelper>().InstancePerDependency();
//Services
builder.RegisterType<LocalizationService>().As<ILocalizationService>()
.InstancePerLifetimeScope();
builder.RegisterType<FormsAuthenticationService>().As<IAuthenticationService>().InstancePerLifetimeScope();
builder.RegisterType<UserService>().As<IUserService>().InstancePerLifetimeScope();
builder.RegisterType<InstallationService>().As<IInstallationService>().InstancePerLifetimeScope();
}
示例3: Register
public void Register(ContainerBuilder builder, ITypeFinder typeFinder)
{
builder.RegisterApiControllers(typeFinder.GetAssemblies().ToArray());
builder.RegisterType<R2DisasterContext>().As<IDbContext>().InstancePerRequest();
builder.RegisterGeneric(typeof(EFRepository<>)).As(typeof(IRepository<>)).InstancePerRequest();
builder.RegisterType<BookRepository>().As<IBookRepository>().InstancePerRequest();
builder.RegisterType<BookService>().As<IBookService>().InstancePerRequest();
builder.RegisterType<ComprehensiveService>().As<IComprehensiveService>().InstancePerRequest();
builder.RegisterType<DebrisFlowService>().As<IDebrisFlowService>().InstancePerRequest();
builder.RegisterType<PhyGeoDisasterService>().As<IPhyGeoDisasterService>().InstancePerRequest();
// builder.RegisterType<Phy>().As<IPhyGeoDisasterService>().InstancePerRequest();
builder.RegisterType<MassPreService>().As<IMassPreService>().InstancePerRequest();
builder.RegisterType<MonthlyReportService>().As<IMonthlyReportService>().InstancePerRequest();
builder.RegisterType<EmergencySurveyReportService>().As<IEmergencySurveyReportService>().InstancePerRequest();
//矿山复绿
builder.RegisterType<MineArchiveService>().As<IMineArchiveService>().InstancePerRequest();
builder.RegisterType<MineEnvironmentSurveyService>().As<IMineEnvironmentSurveyService>().InstancePerRequest();
builder.RegisterType<MineRemoteSensingCardService>().As<IMineRemoteSensingCardService>().InstancePerRequest();
//移民搬迁
builder.RegisterType<RelocationComprehensiveService>().As<IRelocationComprehensiveService>().InstancePerRequest();
builder.RegisterType<RelocationDebrisFlowCheckService>().As<IRelocationDebrisFlowCheckService>().InstancePerRequest();
builder.RegisterType<RelocationLandCollapseCheckService>().As<IRelocationLandCollapseCheckService>().InstancePerRequest();
builder.RegisterType<RelocationLandSlideCheckService>().As<IRelocationLandSlideCheckService>().InstancePerRequest();
builder.RegisterType<RelocationLandSlipCheckService>().As<IRelocationLandSlipCheckService>().InstancePerRequest();
builder.RegisterType<RelocationSlopeCheckService>().As<IRelocationSlopeCheckService>().InstancePerRequest();
builder.RegisterType<RelocationPlaceEvaluationService>().As<IRelocationPlaceEvaluationService>().InstancePerRequest();
builder.RegisterType<RainfallStationService>().As<IRainfallStationService>().InstancePerRequest();
}
示例4: Register
public void Register(ContainerBuilder builder, ITypeFinder typeFinder, NopConfig config)
{
builder.RegisterType<MovieService>().As<IMovieService>().InstancePerLifetimeScope();
builder.RegisterControllers(typeFinder.GetAssemblies().ToArray());
string conn = "Data Source=.;Initial Catalog=Axxe;Trusted_Connection=False;";
builder.RegisterGeneric(typeof(EfRepository<>)).As(typeof(IRepository<>)).InstancePerLifetimeScope();
var dataSettingsManager = new DataSettingsManager();
var dataProviderSettings = dataSettingsManager.LoadSettings();
builder.Register(c => dataSettingsManager.LoadSettings()).As<DataSettings>();
builder.Register<IDbContext>(c => new NopObjectContext(conn)).InstancePerLifetimeScope();
builder.Register(x => new EfDataProviderManager(x.Resolve<DataSettings>())).As<BaseDataProviderManager>().InstancePerDependency();
var efDataProviderManager = new EfDataProviderManager(dataSettingsManager.LoadSettings());
var dataProvider = efDataProviderManager.LoadDataProvider();
dataProvider.InitConnectionFactory();
}
示例5: Register
public void Register(ContainerBuilder builder, ITypeFinder typeFinder)
{
//controllers
builder.RegisterControllers(typeFinder.GetAssemblies().ToArray());
//data access
var dataSettingsManager = new DataSettingsManager();
var dataProviderSettings = dataSettingsManager.LoadSettings();
//todo:暂时把连接字符串写死,测试时使用
//dataProviderSettings.DataConnectionString = @"Data Source=(localdb)\ProjectsV12;Initial Catalog=FzrainFramework;attachdbfilename=E:\MyFramework\Fzrain.Framework\Fzrain.Web\App_Data\FzrainFramework.mdf;Integrated Security=True;Persist Security Info=False;";
//dataProviderSettings.DataProvider = "sqlserver";
builder.Register(c => dataProviderSettings).As<DataSettings>();
builder.Register(x => new EfDataProviderManager(x.Resolve<DataSettings>())).As<BaseDataProviderManager>().InstancePerDependency();
builder.Register(x => x.Resolve<BaseDataProviderManager>().LoadDataProvider()).As<IDataProvider>().InstancePerDependency();
if (dataProviderSettings != null && dataProviderSettings.IsValid())
{
var efDataProviderManager = new EfDataProviderManager(dataProviderSettings);
var dataProvider = efDataProviderManager.LoadDataProvider();
dataProvider.InitConnectionFactory();
builder.Register<IDbContext>(c => new FzrainContext(dataProviderSettings.DataConnectionString)).InstancePerLifetimeScope();
}
else
{
builder.Register<IDbContext>(c => new FzrainContext(dataSettingsManager.LoadSettings().DataConnectionString)).InstancePerLifetimeScope();
}
//repository
builder.RegisterGeneric(typeof(EfRepository<>)).As(typeof(IRepository<>)).InstancePerLifetimeScope();
//service
builder.RegisterType<UserService>().As<IUserService>().InstancePerLifetimeScope();
builder.RegisterType<LolService>().As<ILolService>().InstancePerLifetimeScope();
builder.RegisterType<SettingService>().As<ISettingService>().InstancePerLifetimeScope();
}
示例6: Register
public void Register(ContainerBuilder builder, ITypeFinder typeFinder)
{
builder.RegisterControllers(typeFinder.GetAssemblies().ToArray());
builder.Register<IDbContext>(c => new MmDataContext(ConfigurationManager.ConnectionStrings["MmDataContext"].ConnectionString)).InstancePerHttpRequest();
builder.RegisterGeneric(typeof(Repository<>)).As(typeof(IRepository<>)).InstancePerHttpRequest();
builder.Register(c => new HttpContextWrapper(HttpContext.Current) as HttpContextBase)
.As<HttpContextBase>()
.InstancePerHttpRequest();
builder.Register(c => c.Resolve<HttpContextBase>().Request)
.As<HttpRequestBase>()
.InstancePerHttpRequest();
builder.Register(c => c.Resolve<HttpContextBase>().Response)
.As<HttpResponseBase>()
.InstancePerHttpRequest();
builder.Register(c => c.Resolve<HttpContextBase>().Server)
.As<HttpServerUtilityBase>()
.InstancePerHttpRequest();
builder.Register(c => c.Resolve<HttpContextBase>().Session)
.As<HttpSessionStateBase>()
.InstancePerHttpRequest();
//services
builder.RegisterType<FormAuthenticationService>().As<IAuthenticationService>().InstancePerHttpRequest();
builder.RegisterType<UserService>().As<IUserService>().InstancePerHttpRequest();
builder.RegisterType<EmailSender>().As<IEmailSender>().InstancePerHttpRequest();
builder.RegisterType<ArticleService>().As<IArticleService>().InstancePerHttpRequest();
builder.RegisterType<FormatService>().As<IFormatService>().InstancePerHttpRequest();
builder.RegisterType<MaterialService>().As<IMaterialService>().InstancePerHttpRequest();
builder.RegisterType<TagService>().As<ITagService>().InstancePerHttpRequest();
builder.RegisterType<ThingService>().As<IThingService>().InstancePerHttpRequest();
builder.RegisterType<StateService>().As<IStateService>().InstancePerHttpRequest();
}
示例7: Register
public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder)
{
//webworkcontenxt 上下文注入
builder.RegisterType<WebWorkContext>().As<IWorkContext>().InstancePerLifetimeScope();
//bll 注入
builder.RegisterType<CustomerService>().As<ICustomersService>().InstancePerLifetimeScope();
//用户身份认证
builder.RegisterType<AuthenticationService>().As<IAuthenticationService>().InstancePerHttpRequest();
//验证码管理器
builder.RegisterType<DefaultCaptchaManager>().As<ICaptchaManager>().SingleInstance();
//缓存注册
//builder.Register(c => new DefaultCacheService(new RuntimeMemoryCache(), 1.0f))
// .As<ICacheService>()
// .SingleInstance();
//cachemanager注入
//系统日志注入
builder.RegisterType<Log4NetLoggerFactoryAdapter>().As<ILoggerFactoryAdapter>().SingleInstance();
builder.RegisterType<CacheManagerFactoryAdapter>().As<ICacheManagerFactoryAdapter>().SingleInstance();
//所有的controllers 注入
builder.RegisterControllers(typeFinder.GetAssemblies().ToArray());
//数据层注入
var configstrategy = new ConfigStrategy();
var RDBSConfigInfo = configstrategy.GetRDBSConfigInfo();
builder.Register<IDbContext>(
c => new ShepherdsFrameworkDbContext(RDBSConfigInfo.RDBSConnectionString))
.InstancePerLifetimeScope();
//泛型注入
builder.RegisterGeneric(typeof(EFRepository<>)).As(typeof(IRepository<>)).InstancePerLifetimeScope();
}
示例8: Register
public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder)
{
builder.RegisterType<WebWorkContext>().As<IWorkContext>().InstancePerLifetimeScope();
builder.RegisterType<CustomerService>().As<ICustomersService>().InstancePerLifetimeScope();
//所有的controllers 注入
builder.RegisterControllers(typeFinder.GetAssemblies().ToArray());
}
示例9: Register
public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder)
{
builder.RegisterControllers(typeFinder.GetAssemblies().ToArray());
builder.RegisterType<R2HaloContext>().As<IDbContext>().InstancePerRequest();
builder.RegisterGeneric(typeof(EFRepository<>)).As(typeof(IRepository<>)).InstancePerRequest();
builder.RegisterType<DefaultLogger>().As<ILogger>().InstancePerHttpRequest();
builder.RegisterAssemblyTypes(Assembly.GetAssembly(typeof(EntityServiceBase<>))).Where(t => t.Name.EndsWith("Service")).AsImplementedInterfaces().InstancePerRequest();
//以上为黄圣所加
builder.RegisterType<EmbeddedViewResolver>().As<IEmbeddedViewResolver>().SingleInstance();
builder.RegisterType<RoutePublisher>().As<IRoutePublisher>().SingleInstance();
}
示例10: Register
public static void Register(ContainerBuilder builder, ITypeFinder typeFinder)
{
//webworkcontenxt 上下文注入
builder.RegisterType<WebWorkContext>().As<IWorkContext>().InstancePerLifetimeScope();
//bll 注入
builder.RegisterType<CustomerService>().As<ICustomersService>().InstancePerLifetimeScope();
//所有的controllers 注入
builder.RegisterControllers(typeFinder.GetAssemblies().ToArray());
//数据层注入
//泛型注入
builder.RegisterGeneric(typeof(EFRepository<>)).As(typeof(IRepository<>)).InstancePerLifetimeScope();
}
示例11: Register
public void Register(ContainerBuilder builder, ITypeFinder typeFinder)
{
builder.RegisterApiControllers(typeFinder.GetAssemblies().ToArray());
builder.RegisterType<R2DisasterContext>().As<IDbContext>().InstancePerRequest();
builder.RegisterGeneric(typeof(EFRepository<>)).As(typeof(IRepository<>)).InstancePerRequest();
builder.RegisterType<BookRepository>().As<IBookRepository>().InstancePerRequest();
builder.RegisterType<BookService>().As<IBookService>().InstancePerRequest();
builder.RegisterType<ComprehensiveService>().As<IComprehensiveService>().InstancePerRequest();
builder.RegisterType<DebrisFlowService>().As<IDebrisFlowService>().InstancePerRequest();
builder.RegisterType<PhyGeoDisasterService>().As<IPhyGeoDisasterService>().InstancePerRequest();
builder.RegisterType<MassPreService>().As<IMassPreService>().InstancePerRequest();
builder.RegisterType<RainfallStationService>().As<IRainfallStationService>().InstancePerRequest();
}
示例12: Register
public void Register(ContainerBuilder builder, ITypeFinder typeFinder)
{
builder.Register(c => new HttpContextWrapper(HttpContext.Current) as HttpContextBase)
.As<HttpContextBase>()
.InstancePerHttpRequest();
builder.Register<IDbContext>(c=>new PublicDataContext()).InstancePerHttpRequest();
builder.RegisterGeneric(typeof(EfRepository<>)).As(typeof(IRepository<>)).InstancePerHttpRequest();
builder.RegisterControllers(typeFinder.GetAssemblies().ToArray());
builder.RegisterType<MemoryCacheManager>().As<ICacheManager>().SingleInstance();
builder.RegisterType<PerRequestCacheManager>().As<ICacheManager>().Named<ICacheManager>("nop_cache_per_request").InstancePerHttpRequest();
builder.RegisterType<WebHelper>().As<IWebHelper>().InstancePerHttpRequest();
}
示例13: Register
public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder)
{
//webworkcontenxt 上下文注入
builder.RegisterType<WebWorkContext>().As<IWorkContext>().InstancePerLifetimeScope();
//bll 注入
builder.RegisterType<CustomerService>().As<ICustomersService>().InstancePerLifetimeScope();
//所有的controllers 注入
builder.RegisterControllers(typeFinder.GetAssemblies().ToArray());
//数据层注入
var configstrategy = new ConfigStrategy();
builder.Register<IDbContext>(c => new ShepherdsFrameworkDbContext(configstrategy.GetRDBSConfigInfo().RDBSConnectionString))
//泛型注入
builder.RegisterGeneric(typeof(EFRepository<>)).As(typeof(IRepository<>)).InstancePerLifetimeScope();
}
示例14: Register
/// <summary>
/// The register.
/// </summary>
/// <param name="builder">
/// The builder.
/// </param>
/// <param name="typeFinder">
/// The type finder.
/// </param>
/// <param name="isActiveModule">
/// The is active module.
/// </param>
public void Register(ContainerBuilder builder, ITypeFinder typeFinder, bool isActiveModule)
{
// HTTP context and other related stuff
builder.Register(
c => // register FakeHttpContext when HttpContext is not available
(new HttpContextWrapper(HttpContext.Current) as HttpContextBase))
.As<HttpContextBase>()
.InstancePerLifetimeScope();
builder.Register(c => c.Resolve<HttpContextBase>().Request).As<HttpRequestBase>().InstancePerLifetimeScope();
builder.Register(c => c.Resolve<HttpContextBase>().Response)
.As<HttpResponseBase>()
.InstancePerLifetimeScope();
builder.Register(c => c.Resolve<HttpContextBase>().Server)
.As<HttpServerUtilityBase>()
.InstancePerLifetimeScope();
builder.Register(c => c.Resolve<HttpContextBase>().Session)
.As<HttpSessionStateBase>()
.InstancePerLifetimeScope();
// controllers
var controllers = typeFinder.GetAssemblies().ToArray();
builder.RegisterControllers(controllers);
}
示例15: Register
public void Register(ContainerBuilder builder, ITypeFinder typeFinder)
{
//HTTP context and other related stuff
builder.Register(c =>
//register FakeHttpContext when HttpContext is not available
HttpContext.Current != null ?
(new HttpContextWrapper(HttpContext.Current) as HttpContextBase) :
(new FakeHttpContext("~/") as HttpContextBase))
.As<HttpContextBase>()
.InstancePerLifetimeScope();
builder.Register(c => c.Resolve<HttpContextBase>().Request)
.As<HttpRequestBase>()
.InstancePerLifetimeScope();
builder.Register(c => c.Resolve<HttpContextBase>().Response)
.As<HttpResponseBase>()
.InstancePerLifetimeScope();
builder.Register(c => c.Resolve<HttpContextBase>().Server)
.As<HttpServerUtilityBase>()
.InstancePerLifetimeScope();
builder.Register(c => c.Resolve<HttpContextBase>().Session)
.As<HttpSessionStateBase>()
.InstancePerLifetimeScope();
//controllers
builder.RegisterControllers(typeFinder.GetAssemblies().ToArray());
builder.Register<IDbContext>(c => new BlogObjectContext()).InstancePerLifetimeScope();
builder.RegisterGeneric(typeof(EfRepository<>)).As(typeof(IRepository<>)).InstancePerLifetimeScope();
builder.RegisterType<BlogService>().As<IBlogService>().InstancePerLifetimeScope();
builder.RegisterType<UrlService>().As<IUrlService>().InstancePerLifetimeScope();
builder.RegisterType<RoutePublisher>().As<IRoutePublisher>().SingleInstance();
}