public NarikJwtLoginService(
     IUserPasswordStore <ApplicationUser> userPasswordStore,
     IPasswordHasher <ApplicationUser> passwordHasher, NarikModulesConfig config)
 {
     _userPasswordStore = userPasswordStore;
     _passwordHasher    = passwordHasher;
     _config            = config;
 }
Пример #2
0
        private void Init(IServiceCollection services)
        {
            var moduleConfig = _configuration.GetSection("NarikModulesConfig");

            services.Configure <NarikModulesConfig>(moduleConfig);
            _config = moduleConfig.Get <NarikModulesConfig>();
            _unityContainer.RegisterInstance(typeof(NarikModulesConfig), _config);
            if (_options == null)
            {
                _options = new NarikStarupOptions
                {
                }
            }
            ;
        }
Пример #3
0
        protected BaseDataService()
        {
            _cacheService            = ServiceLocator.Current.GetInstance <ICacheService>();
            mapperConfig             = ServiceLocator.Current.GetInstance <AutoMapper.IConfigurationProvider>();
            _config                  = ServiceLocator.Current.GetInstance <NarikModulesConfig>();
            LocalizationService      = ServiceLocator.Current.GetInstance <ILocalizationService>();
            _entityUpdatePushService = ServiceLocator.Current.GetInstance <IEntityUpdatePushService>();
            LoggingService           = ServiceLocator.Current.GetInstance <ILoggingService>();

            Configuration = ServiceLocator.Current.GetInstance <IConfiguration>();

            lock (_lock)
            {
                if (!DomainServiceDescriptions.ContainsKey(GetType()))
                {
                    DomainServiceDescriptions.TryAdd(GetType(), new DomainServiceDescription(GetType()));
                }
                DomainServiceDescription = DomainServiceDescriptions[GetType()];
            }

            DbContext = CreateDbContext();
        }
Пример #4
0
        public void InitModules()
        {
            var narikModuleConfig = new NarikModulesConfig();

            _configuration.GetSection("NarikModulesConfig").Bind(narikModuleConfig);

            AvaialbleModules = narikModuleConfig.Modules.OfType <INarikModuleModel>().ToList();

            var runTimeAssemblyPath = Path.Combine(_environment.AppRoot, @"Narik.Modules.Runtime.dll");

            if (!File.Exists(runTimeAssemblyPath))
            {
                throw new Exception($"'Runtime Module'  Not Found in {runTimeAssemblyPath}");
            }
            //Load Runtime
            AssemblyLoadContext.Default
            .LoadFromAssemblyPath(runTimeAssemblyPath);

            if (narikModuleConfig.Modules != null)
            {
                foreach (var narikModuleModel in narikModuleConfig.Modules)
                {
                    AssemblyLoadContext.Default
                    .LoadFromAssemblyPath(Path.Combine(_environment.AppRoot, narikModuleModel.AssemblyName));
                    if (!string.IsNullOrEmpty(narikModuleModel.Dependencies))
                    {
                        var dependencies =
                            narikModuleModel.Dependencies.Split(",", StringSplitOptions.RemoveEmptyEntries);
                        foreach (var dependency in dependencies)
                        {
                            AssemblyLoadContext.Default
                            .LoadFromAssemblyPath(Path.Combine(_environment.AppRoot, dependency));
                        }
                    }
                }
            }


            _unityContainer.RegisterTypes(
                AllClasses.FromLoadedAssemblies().
                Where(type => typeof(INarikModule).IsAssignableFrom(type) && !type.IsInterface)
                .Distinct(),
                WithMappings.FromAllInterfaces,
                WithName.TypeName,
                WithLifetime.ContainerControlled);


            var modules = _unityContainer.ResolveAll <INarikModule>().ToList();

            _loggingService.Log("Modules Count:" + modules.Count);


            foreach (var module in modules)
            {
                _moduleAssemlies.Add(module.Key, module.GetType().Assembly);
            }


            //Init RuntimeModule
            var runtimeModule = modules.FirstOrDefault(x => x.Key == RuntimeModule);

            if (runtimeModule != null)
            {
                InitModule(runtimeModule);
            }
            else
            {
                throw new Exception("Module Runtime Not Found");
            }


            //Init Other Module
            var modulesQuery = from m in modules
                               join am in AvaialbleModules
                               on m.Key equals am.Key
                               orderby am.InitOrder
                               select new { m, am };

            var mustInitModules = modulesQuery.ToList();

            var orderbyQuery = mustInitModules.OrderBy(x => x.am.InitOrder).ToList();

            foreach (var module in orderbyQuery)
            {
                InitModule(module.m);
            }
        }
Пример #5
0
 public RuntimeModule(IUnityContainer container, NarikModulesConfig config)
 {
     _unityContainer = container;
     container.RegisterType <IUserStore <ApplicationUser>, NarikUserStore>(new ContainerControlledLifetimeManager());
 }