private void InnerGenericPostTreatment <TEntity>(IInvocation invocation, List <TEntity> pEntities) { string assemblyName = invocation.InvocationTarget.GetType().BaseType.Assembly.ManifestModule.Name.Replace(".dll", "."); string validatorName = "I" + invocation.InvocationTarget.GetType().BaseType.Name + "PostTreatmentExecutor"; TypeResolver typeResolver = _iocResolver.Resolve <TypeResolver>(); Type validatorInterfaceType = typeResolver[assemblyName + validatorName]; if (validatorInterfaceType is null) { return; } IPostTreatmentExecutor <TEntity> postTreatmentExecutor = _iocResolver.Resolve(validatorInterfaceType) as IPostTreatmentExecutor <TEntity>; Type executorType = postTreatmentExecutor.GetType(); string methodName = "PostTreatment_" + invocation.MethodInvocationTarget.Name; MethodInfo method = executorType.GetMethod(methodName); var request = invocation.Arguments[0]; var result = invocation.ReturnValue.GetType().GetProperty("Result").GetValue(invocation.ReturnValue); var infos = new object[] { request, result }; method.Invoke(postTreatmentExecutor, infos); }
public async Task <GetCountThuTucDashBoardDto> GetCountThuTucDashBoard(GetCountThuTucDashBoardDto input) { try { input.Total = 0; string maTT = input.ThuTuc < 10 ? $"0{input.ThuTuc}" : input.ThuTuc.ToString(); Type girdAppServiceType = Type.GetType($"newPSG.PMS.Services.IXuLyHoSoGridView{maTT}AppService"); Type XHoSoInputDto = Type.GetType($"newPSG.PMS.Dto.HoSoInput{maTT}Dto"); if (girdAppServiceType == null || XHoSoInputDto == null) { return(null); } dynamic _gridSerVice = _iocResolver.Resolve(girdAppServiceType); dynamic xinput = Activator.CreateInstance(XHoSoInputDto); xinput.FormId = input.FormId; xinput.IsOnlyToTal = true; foreach (var formCase in input.ListFormCase) { xinput.FormCase = formCase; var getList = await _gridSerVice.GetListHoSoPaging(xinput); input.Total += Convert.ToInt32(getList.TotalCount); } return(input); } catch (Exception ex) { Logger.Fatal(ex.Message); throw ex; } }
public IActionResult TestNh() { try { var userClaimRepository = _iocResolver.Resolve <IRepository <UserClaim, long> >(); var userClaims = userClaimRepository.GetAllListAsync(uc => uc.UserId == 1); userClaims.Wait(); var r = userClaims.Result; var factory = _iocResolver.Resolve <ISessionFactory>(); var currentSession = factory.GetCurrentSession(); var user = currentSession.Get <Authorization.Users.User>((Int64)1); var tenant = currentSession.Get <MultiTenancy.Tenant>((int)1); var role = currentSession.Get <Authorization.Roles.Role>((int)1); user.DeleterUser = user; } catch (Exception e) { } return(Content("Test successful")); }
public static void JobInitializer(IIocResolver iocResolver) { IMailHelper mailHelper = iocResolver.Resolve <IMailHelper>(); IPushNotificationHelper pushNotificationHelper = iocResolver.Resolve <IPushNotificationHelper>(); new MyTestScheduler(mailHelper, pushNotificationHelper).Run(); }
public TDbContext Resolve <TDbContext>(string connectionString, DbConnection existingConnection) where TDbContext : EfCoreDbContextBase { return(_iocResolver.Resolve <TDbContext>(new Dictionary <string, object>() { { "options", CreateOptions <TDbContext>(connectionString, existingConnection) } })); }
public object Resolve(Type type, object argumentsAsAnonymousType) { var resolvedObject = argumentsAsAnonymousType != null ? _iocResolver.Resolve(type, argumentsAsAnonymousType) : _iocResolver.Resolve(type); _resolvedObjects.Add(resolvedObject); return(resolvedObject); }
public TDbContext Resolve <TDbContext>(string connectionString, DbConnection existingConnection) where TDbContext : DbContext { var dbContextType = typeof(TDbContext); Type concreteType = null; var isAbstractDbContext = dbContextType.GetTypeInfo().IsAbstract; if (isAbstractDbContext) { concreteType = _dbContextTypeMatcher.GetConcreteType(dbContextType); } try { if (isAbstractDbContext) { // return (TDbContext) _iocResolver.Resolve(concreteType, new // { // options = CreateOptionsForType(concreteType, connectionString, existingConnection) // }); return((TDbContext)_iocResolver.Resolve(concreteType, new object[] { CreateOptionsForType(concreteType, connectionString, existingConnection) })); } // return _iocResolver.Resolve<TDbContext>(new // { // options = CreateOptions<TDbContext>(connectionString, existingConnection) // }); return(_iocResolver.Resolve <TDbContext>(new object[] { CreateOptions <TDbContext>(connectionString, existingConnection) })); } catch (Castle.MicroKernel.Resolvers.DependencyResolverException ex) { var hasOptions = isAbstractDbContext ? HasOptions(concreteType) : HasOptions(dbContextType); if (!hasOptions) { throw new AggregateException($"The parameter name of {dbContextType.Name}'s constructor must be 'options'", ex); } throw; } bool HasOptions(Type contextType) { return(contextType.GetConstructors().Any(ctor => { var parameters = ctor.GetParameters(); return parameters.Length == 1 && parameters.FirstOrDefault()?.Name == "options"; })); } }
/// <summary> /// Called by MVC system and creates controller instance for given controller type. /// </summary> /// <param name="requestContext">Request context</param> /// <param name="controllerType">Controller type</param> /// <returns></returns> protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType) { if (controllerType == null) { return(base.GetControllerInstance(requestContext, controllerType)); } return(_iocManager.Resolve <IController>(controllerType)); }
public TenantIdAccessor( ITenantCache tenantCache, IIocResolver iocResolver) { _tenantCache = tenantCache; _iocResolver = iocResolver; _Session = new Lazy <IInfrastructureSession>(() => _iocResolver.Resolve <IInfrastructureSession>(), true); _tenancyNameFinder = new Lazy <ITenancyNameFinder>(() => _iocResolver.Resolve <ITenancyNameFinder>(), true); }
public void Publish(IMessageWrapper messageWrapper) { var messageBus = _iocResolver.Resolve <IMessageBus>(); messageBus .OnMessageReceivedAsync(messageWrapper.Message, messageWrapper.Descriptor as IRichMessageDescriptor) .GetAwaiter() .GetResult() ; }
public TDbContext Resolve <TDbContext>(string connectionString) where TDbContext : DbContext { var dbContextType = GetConcreteType <TDbContext>(); return((TDbContext)_iocResolver.Resolve(dbContextType, new { nameOrConnectionString = connectionString })); }
public TenantIdAccessor( ITenantCache tenantCache, IIocResolver iocResolver) { _tenantCache = tenantCache; _iocResolver = iocResolver; _currentTenant = new AsyncLocal <int?>(); _abpSession = new Lazy <IAbpSession>(() => _iocResolver.Resolve <IAbpSession>(), true); _tenancyNameFinder = new Lazy <ITenancyNameFinder>(() => _iocResolver.Resolve <ITenancyNameFinder>(), true); }
public AdvertAccountAppService(IProductManager productManager, IAdvertAccountManager advertAccountManager, ILocalizationManager localizationManager, IIocResolver iocResolver) { this._productManager = productManager; this._advertAccountManager = advertAccountManager; this._localizationManager = localizationManager; this._tenantAdvertAccountSyncor = iocResolver.Resolve <TenantAdvertAccountSyncor>(typeof(IAdvertAccountSyncor)); this._toutiaoAdvertAccountSyncor = iocResolver.Resolve <TenantAdvertAccountSyncor>(typeof(IAdvertAccountSyncor)); }
public AdvertDailyStatisticSyncSingleJob( IIocResolver iocResolver, IUnitOfWorkManager unitOfWorkManager, IAdvertAccountManager advertAccountManager, ILogger logger) { this._unitOfWorkManager = unitOfWorkManager; this._advertAccountManager = advertAccountManager; this._logger = logger; this._tenantAdvertAccountSyncor = iocResolver.Resolve <TenantAdvertAccountSyncor>(typeof(IAdvertAccountSyncor)); this._toutiaoAdvertAccountSyncor = iocResolver.Resolve <TenantAdvertAccountSyncor>(typeof(IAdvertAccountSyncor)); }
public EmbeddedResourceFileProvider(IIocResolver iocResolver) { this._embeddedResourceManager = new Lazy <IEmbeddedResourceManager>( () => iocResolver.Resolve <IEmbeddedResourceManager>(), true ); this._configuration = new Lazy <IWebEmbeddedResourcesConfiguration>( () => iocResolver.Resolve <IWebEmbeddedResourcesConfiguration>(), true ); }
public PluginEmbeddedResourceFileProvider(IIocResolver iocResolver) { _iocResolver = iocResolver; _embeddedResourceManager = new Lazy <IEmbeddedResourceManager>( () => iocResolver.Resolve <IEmbeddedResourceManager>(), true ); _configuration = new Lazy <IEmbeddedResourcesConfiguration>( () => iocResolver.Resolve <IEmbeddedResourcesConfiguration>(), true ); }
public TDbContext Resolve <TDbContext>() { var dbContextType = typeof(TDbContext); if (!dbContextType.IsAbstract) { return(_iocResolver.Resolve <TDbContext>()); } else { var concreteType = _dbContextTypeMatcher.GetConcreteType(dbContextType); return((TDbContext)_iocResolver.Resolve(concreteType)); } }
public TDbContext Resolve <TDbContext>(string connectionString) { //TODO: connectionString is not used. We should find a way of creating DbContextOptions<TDbContext> based on that connection string var dbContextType = typeof(TDbContext); if (!dbContextType.IsAbstract) { return(_iocResolver.Resolve <TDbContext>()); } var concreteType = _dbContextTypeMatcher.GetConcreteType(dbContextType); return((TDbContext)_iocResolver.Resolve(concreteType)); }
internal TDbContext GetOrCreateDbContext <TDbContext>() where TDbContext : DbContext { DbContext dbContext; if (!_activeDbContexts.TryGetValue(typeof(TDbContext), out dbContext)) { dbContext = _iocResolver.Resolve <TDbContext>(); foreach (var filter in Filters) { if (filter.IsEnabled) { dbContext.EnableFilter(filter.FilterName); } else { dbContext.DisableFilter(filter.FilterName); } foreach (var filterParameter in filter.FilterParameters) { //TODO: Implement if filterParameter.Value is Func<object>! dbContext.SetFilterScopedParameterValue(filter.FilterName, filterParameter.Key, filterParameter.Value); } } _activeDbContexts[typeof(TDbContext)] = dbContext; } return((TDbContext)dbContext); }
public IUnitOfWorkCompleteHandle Begin(UnitOfWorkOptions options) { options.FillDefaultsForNonProvidedOptions(_defaultOptions); IUnitOfWork current = _currentUnitOfWorkProvider.Current; if (options.Scope == TransactionScopeOption.Required && current != null) { return(new InnerUnitOfWorkCompleteHandle()); } IUnitOfWork uow = _iocResolver.Resolve <IUnitOfWork>(); uow.Completed += delegate { _currentUnitOfWorkProvider.Current = null; }; uow.Failed += delegate { _currentUnitOfWorkProvider.Current = null; }; uow.Disposed += delegate { _iocResolver.Release(uow); }; if (current != null) { options.FillOuterUowFiltersForNonProvidedOptions(current.Filters.ToList()); } uow.Begin(options); _currentUnitOfWorkProvider.Current = uow; return(uow); }
/// <inheritdoc /> public IUnitOfWorkCompleteHandle Begin(UnitOfWorkOptions options) { options.FillDefaultsForNonProvidedOptions(_defaultOptions); var outerUow = _currentUnitOfWorkProvider.Current; if (options.Scope == TransactionScopeOption.Required && outerUow != null) { return(new InnerUnitOfWorkCompleteHandle()); } var uow = _iocResolver.Resolve <IUnitOfWork>(); uow.OnCompleted += (sender, args) => _currentUnitOfWorkProvider.Current = null; uow.OnFailed += (sender, args) => _currentUnitOfWorkProvider.Current = null; uow.OnDisposed += (sender, args) => _iocResolver.Release(uow); if (outerUow != null) { options.FillOuterUowFiltersForNonProvidedOptions(outerUow.Filters.ToList()); } uow.Begin(options); _currentUnitOfWorkProvider.Current = uow; return(uow); }
public IUnitOfWorkCompleteHandle Begin(UnitOfWorkOptions options) { if (_currentUnitOfWorkProvider.Current != null) { return(new InnerUnitOfWorkCompleteHandle()); } options.FillDefaultsForNonProvidedOptions(_defaultOptions); var uow = _iocResolver.Resolve <IUnitOfWork <TTenantId, TUserId> >(); uow.Completed += (sender, args) => { _currentUnitOfWorkProvider.Current = null; }; uow.Failed += (sender, args) => { _currentUnitOfWorkProvider.Current = null; }; uow.Disposed += (sender, args) => { _iocResolver.Release(uow); }; uow.Begin(options); _currentUnitOfWorkProvider.Current = uow; return(uow); }
public IUnitOfWorkCompleteHandle Begin(UnitOfWorkOptions options) { options.FillDefaultsForNonProvidedOptions(_defaultOptions); if (options.Scope == TransactionScopeOption.Required && _currentUnitOfWorkProvider.Current != null) { return(new InnerUnitOfWorkCompleteHandle()); } var uow = _iocResolver.Resolve <IUnitOfWork>(); uow.Completed += (sender, args) => { _currentUnitOfWorkProvider.Current = null; }; uow.Failed += (sender, args) => { _currentUnitOfWorkProvider.Current = null; }; uow.Disposed += (sender, args) => { _iocResolver.Release(uow); }; uow.Begin(options); _currentUnitOfWorkProvider.Current = uow; return(uow); }
public ProcessAdvertShipJob( IIocResolver iocResolver, IShipmentManager shipmentManager) { this._advertAccountSyncor = iocResolver.Resolve <TenantAdvertAccountSyncor>(); this._shipmentManager = shipmentManager; }
/// <inheritdoc /> public DbContext GetDbContext() { if (_dbContext == null) { _dbContext = _iocResolver.Resolve <DbContext>(); } return(_dbContext); }
/// <summary> /// This method is called by ABP before first usage. /// </summary> public virtual void Initialize(ILocalizationConfiguration configuration, IIocResolver iocResolver) { _configuration = configuration; _logger = iocResolver.IsRegistered(typeof(ILoggerFactory)) ? iocResolver.Resolve <ILoggerFactory>().Create(typeof(ResourceFileLocalizationSource)) : NullLogger.Instance; }
public void Subscribe() { var consumers = typeFinder.Find(t => t.IsClass && typeof(IRedisConsumer).IsAssignableFrom(t)); var sub = databaseProvider.GetDatabase().Multiplexer.GetSubscriber(); foreach (var item in consumers) { var obj = iocResolver.Resolve(item); var channel = (string)item.InvokeMember("GetChannelName", BindingFlags.InvokeMethod, null, obj, null); sub.Subscribe(channel, (c, v) => { var messageType = (Type)item.InvokeMember("GetMessageType", BindingFlags.InvokeMethod, null, obj, null); var message = objectSerializer.Deserialize(messageType, v); item.InvokeMember("ConsumeAsync", BindingFlags.InvokeMethod, null, obj, new[] { message }); }); } }
public void CreateUser(User user) { var lockerService = _iocResolver.Resolve <ILockService>(); lockerService.Execute(nameof(User), () => { _userRepository.AddUser(user); }); }
public override void Initialize(ILocalizationConfiguration configuration, IIocResolver iocResolver) { base.Initialize(configuration, iocResolver); if (Logger is NullLogger && iocResolver.IsRegistered(typeof(ILoggerFactory))) { Logger = iocResolver.Resolve<ILoggerFactory>().Create(typeof (MultiTenantLocalizationSource)); } }
/// <summary> /// 构建服务并设置本地程序平台的Resolver /// </summary> /// <param name="services">服务映射信息集合</param> /// <param name="assemblies">要检索的程序集集合</param> /// <returns>服务提供者</returns> protected override IServiceProvider BuildAndSetResolver(IServiceCollection services, Assembly[] assemblies) { ContainerBuilder builder = new ContainerBuilder(); builder.Populate(services); IContainer container = builder.Build(); LocalIocResolver.Container = container; Resolver = container.Resolve<IIocResolver>(); return Resolver.Resolve<IServiceProvider>(); }
public void Install(IWindsorContainer container, IConfigurationStore store) { container.Register( Component.For <CommandDispatcher>().Instance(new CommandDispatcher(iocResolver)).LifestyleSingleton() ); commandDispatcher = iocResolver.Resolve <CommandDispatcher>(); container.Kernel.ComponentRegistered += Kernel_ComponentRegistered; }
public override void Initialize(ILocalizationConfiguration configuration, IIocResolver iocResolver) { base.Initialize(configuration, iocResolver); if (Logger is NullLogger && iocResolver.IsRegistered(typeof(ILoggerFactory))) { Logger = iocResolver.Resolve <ILoggerFactory>().Create(typeof(MultiTenantLocalizationSource)); } }
private static string GetNameOrConnectionStringOrNull(IIocResolver iocResolver) { if (iocResolver.IsRegistered<IBdfStartupConfiguration>()) { var defaultConnectionString = iocResolver.Resolve<IBdfStartupConfiguration>().DefaultNameOrConnectionString; if (!string.IsNullOrWhiteSpace(defaultConnectionString)) { return defaultConnectionString; } } return ConfigurationManager.ConnectionStrings["Default"] != null ? "Default" : null; }
private static string GetNameOrConnectionStringOrNull(IIocResolver iocResolver) { if (iocResolver.IsRegistered<IAbpStartupConfiguration>()) { var defaultConnectionString = iocResolver.Resolve<IAbpStartupConfiguration>().DefaultNameOrConnectionString; if (!string.IsNullOrWhiteSpace(defaultConnectionString)) { return defaultConnectionString; } } if (ConfigurationManager.ConnectionStrings.Count == 1) { return ConfigurationManager.ConnectionStrings[0].Name; } if (ConfigurationManager.ConnectionStrings["Default"] != null) { return "Default"; } return null; }
public EventBusInstaller(IIocResolver iocResolver) { _iocResolver = iocResolver; _eventBusConfiguration = iocResolver.Resolve<IEventBusConfiguration>(); }