public void StartServices() { // DI ready ServiceLocator.Start = (IServiceLocator locator) => { IProfiler profiler = new WebProfiler(); IApplicationHost host = new WebApplicationHost(profiler); ILocalizer localizer = new WebLocalizer(host); IDbContext dbContext = new SqlDbContext( profiler as IDataProfiler, host as IDataConfiguration, localizer as IDataLocalizer, host as ITenantManager); ILogger logger = new WebLogger(host, dbContext); IMessageService emailService = new IdentityEmailService(logger, host); IMessaging messaging = new MessageProcessor(host, dbContext, emailService, logger); IRenderer renderer = new XamlRenderer(profiler, host); IWorkflowEngine workflowEngine = new WorkflowEngine(host, dbContext, messaging); IDataScripter scripter = new VueDataScripter(host, localizer); ISmsService smsService = new SmsService(dbContext, logger); IExternalLoginManager externalLoginManager = new ExternalLoginManager(dbContext); IUserStateManager userStateManager = new WebUserStateManager(host, dbContext); IExternalDataProvider dataProvider = new ExternalDataContext(); IScriptProcessor scriptProcessor = new ScriptProcessor(scripter, host); locator.RegisterService <IDbContext>(dbContext); locator.RegisterService <IProfiler>(profiler); locator.RegisterService <IApplicationHost>(host); locator.RegisterService <IRenderer>(renderer); locator.RegisterService <IWorkflowEngine>(workflowEngine); locator.RegisterService <IMessaging>(messaging); locator.RegisterService <ILocalizer>(localizer); locator.RegisterService <IDataScripter>(scripter); locator.RegisterService <ILogger>(logger); locator.RegisterService <IMessageService>(emailService); locator.RegisterService <ISmsService>(smsService); locator.RegisterService <IExternalLoginManager>(externalLoginManager); locator.RegisterService <IUserStateManager>(userStateManager); locator.RegisterService <IExternalDataProvider>(dataProvider); locator.RegisterService <IScriptProcessor>(scriptProcessor); HttpContext.Current.Items.Add("ServiceLocator", locator); }; ServiceLocator.GetCurrentLocator = () => { if (HttpContext.Current == null) { throw new InvalidProgramException("There is no http context"); } var currentContext = HttpContext.Current; var locator = currentContext.Items["ServiceLocator"]; if (locator == null) { new ServiceLocator(); } return(HttpContext.Current.Items["ServiceLocator"] as IServiceLocator); }; }
public TokenAuthController( LogInManager logInManager, ITenantCache tenantCache, AbpLoginResultTypeHelper abpLoginResultTypeHelper, TokenAuthConfiguration configuration, UserManager userManager, ICacheManager cacheManager, IOptions <JwtBearerOptions> jwtOptions, IExternalAuthConfiguration externalAuthConfiguration, IExternalAuthManager externalAuthManager, UserRegistrationManager userRegistrationManager, IImpersonationManager impersonationManager, IUserLinkManager userLinkManager, IAppNotifier appNotifier, ISmsSender smsSender, IEmailSender emailSender, IOptions <IdentityOptions> identityOptions, GoogleAuthenticatorProvider googleAuthenticatorProvider, ExternalLoginManager externalLoginManager) { _logInManager = logInManager; _tenantCache = tenantCache; _abpLoginResultTypeHelper = abpLoginResultTypeHelper; _configuration = configuration; _userManager = userManager; _cacheManager = cacheManager; _jwtOptions = jwtOptions; _externalAuthConfiguration = externalAuthConfiguration; _externalAuthManager = externalAuthManager; _userRegistrationManager = userRegistrationManager; _impersonationManager = impersonationManager; _userLinkManager = userLinkManager; _appNotifier = appNotifier; _smsSender = smsSender; _emailSender = emailSender; _googleAuthenticatorProvider = googleAuthenticatorProvider; _identityOptions = identityOptions.Value; _externalLoginManager = externalLoginManager; }
public static void StartServices(IAppBuilder app) { // DI ready ServiceLocator.Start = (IServiceLocator locator) => { IProfiler profiler = new WebProfiler(); IUserLocale userLocale = new WebUserLocale(); IApplicationHost host = new WebApplicationHost(profiler, userLocale, locator); ILocalizer localizer = new WebLocalizer(host, userLocale); ITokenProvider tokenProvider = new WebTokenProvider(); IDbContext dbContext = new SqlDbContext( profiler as IDataProfiler, host as IDataConfiguration, localizer as IDataLocalizer, host as ITenantManager, tokenProvider); ILogger logger = new WebLogger(host, dbContext); IMessageService emailService = new IdentityEmailService(logger, host); ISmsService smsService = new SmsService(dbContext, logger); IRenderer renderer = new XamlRenderer(profiler, host); IDataScripter scripter = new VueDataScripter(host, localizer); IExternalLoginManager externalLoginManager = new ExternalLoginManager(dbContext); IUserStateManager userStateManager = new WebUserStateManager(host, dbContext); IMessaging messaging = new MessageProcessor(host, dbContext, emailService, smsService, logger); IWorkflowEngine workflowEngine = new WorkflowEngine(host, dbContext, messaging); IExternalDataProvider dataProvider = new ExternalDataContext(); IScriptProcessor scriptProcessor = new ScriptProcessor(scripter, host); IHttpService httpService = new HttpService(); IJavaScriptEngine javaScriptEngine = new JavaScriptEngine(dbContext, host, smsService); locator.RegisterService <IDbContext>(dbContext); locator.RegisterService <IProfiler>(profiler); locator.RegisterService <IApplicationHost>(host); locator.RegisterService <IRenderer>(renderer); locator.RegisterService <IWorkflowEngine>(workflowEngine); locator.RegisterService <IMessaging>(messaging); locator.RegisterService <IUserLocale>(userLocale); locator.RegisterService <ILocalizer>(localizer); locator.RegisterService <IDataScripter>(scripter); locator.RegisterService <ILogger>(logger); locator.RegisterService <IMessageService>(emailService); locator.RegisterService <ISmsService>(smsService); locator.RegisterService <IExternalLoginManager>(externalLoginManager); locator.RegisterService <IUserStateManager>(userStateManager); locator.RegisterService <IExternalDataProvider>(dataProvider); locator.RegisterService <IScriptProcessor>(scriptProcessor); locator.RegisterService <IHttpService>(httpService); locator.RegisterService <IJavaScriptEngine>(javaScriptEngine); locator.RegisterService <ITokenProvider>(tokenProvider); IDataProtectionProvider dataProtection = app.GetDataProtectionProvider(); locator.RegisterService <IDataProtectionProvider>(dataProtection); if (HttpContext.Current != null) { HttpContext.Current.Items.Add("ServiceLocator", locator); } }; IServiceLocator GetOrCreateStatic() { if (_currentLocator == null) { _currentLocator = new ServiceLocator(); } return(_currentLocator); } ServiceLocator.GetCurrentLocator = () => { if (HttpContext.Current == null) { return(GetOrCreateStatic()); } var currentContext = HttpContext.Current; var locator = currentContext.Items["ServiceLocator"]; if (locator == null) { var loc = new ServiceLocator(); // side effects var fromHttp = HttpContext.Current.Items["ServiceLocator"] as IServiceLocator; if (loc != fromHttp) { throw new InvalidOperationException("Invalid service locator"); } } return(HttpContext.Current.Items["ServiceLocator"] as IServiceLocator); }; }
public UserStore(UserManager userManager, ExternalLoginManager externalLoginManager, RoleManager roleManager) : base(userManager, externalLoginManager, roleManager) { }