Exemplo n.º 1
0
        static public async Task ActivateAsync(object activationArgs)
        {
            if (IsInteractive(activationArgs))
            {
                ServiceLocator.Configure(_serviceCollection);

                // Do not repeat app initialization when the Window already has content,
                // just ensure that the window is active
                if (Window.Current.Content == null)
                {
                    // Create a Frame to act as the navigation context
                    Window.Current.Content = new Frame();
                }
            }

            // Depending on activationArgs one of ActivationHandlers or DefaultActivationHandler
            // will navigate to the first page
            await HandleActivationAsync(activationArgs);

            if (IsInteractive(activationArgs))
            {
                IActivatedEventArgs activation = activationArgs as IActivatedEventArgs;
                if (activation.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    await ServiceLocator.Current.GetService <SuspendAndResumeService>().RestoreSuspendAndResumeData();
                }

                // Ensure the current window is active
                Window.Current.Activate();

                // Tasks after activation
                await StartupAsync();
            }
        }
Exemplo n.º 2
0
        public void ConfigureServices(IServiceCollection services)
        {
            ModwanaApp.Init(services, Configuration);


            services.AddControllersWithViews().AddRazorRuntimeCompilation();

            services.AddHttpContextAccessor();

            services.AddIdentity <User, Role>()
            .AddUserManager <ModwanaUserManager>()
            .AddEntityFrameworkStores <ModwanaDbContext>()
            .AddErrorDescriber <ModwanaIdentityErrorDescriber>()
            .AddClaimsPrincipalFactory <ModwanaClaimsPrincipalFactory>()
            .AddRoleStore <ModwanaRoleStore>()
            .AddUserStore <ModwanaUserStore>()
            .AddSignInManager <ModwanaSignInManager>()
            .AddDefaultTokenProviders();

            services.AddTransient <IDateTime, SystemDate>();

            services.AddTransient <IPrincipal>((provider) => provider.GetService <IHttpContextAccessor>().HttpContext?.User);

            ConfigureGitVersion(services);

            ServiceLocator.Configure(services);
        }
Exemplo n.º 3
0
        public static void Configure()
        {
            AppSettings.Configuration = new ConfigurationBuilder()
                                        .AddJsonFile("appsettings.json")
                                        .Build();

            var services = new ServiceCollection();


            services.AddIdentity <User, Role>()
            .AddUserManager <ModwanaUserManager>()
            .AddErrorDescriber <ModwanaIdentityErrorDescriber>()
            .AddClaimsPrincipalFactory <ModwanaClaimsPrincipalFactory>()
            .AddRoleStore <ModwanaRoleStore>()
            .AddUserStore <ModwanaUserStore>()
            .AddSignInManager <ModwanaSignInManager>()
            .AddDefaultTokenProviders();


            services.AddTransient <IDateTime, FakeDate>();

            ModwanaApp.Init(services, AppSettings.Configuration);

            ServiceLocator.Configure(services);

            InitDatabase();
        }
 // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
 public void Configure(IApplicationBuilder app, IHostingEnvironment env)
 {
     app.UseCors(builder =>
     {
         builder.AllowAnyHeader();
         builder.AllowAnyMethod();
         builder.AllowAnyOrigin();
     });
     //if (env.IsDevelopment())
     //{
     app.UseDeveloperExceptionPage();
     app.UseSwagger();
     app.UseSwaggerUI(c =>
     {
         typeof(ApiVersions).GetEnumNames().OrderByDescending(e => e).ToList().ForEach(version =>
         {
             c.SwaggerEndpoint($"/swagger/{version}/swagger.json", $"{_Project_Name} {version}");
         });
         //注入汉化文件
         c.InjectOnCompleteJavaScript($"/swagger_translator.js");
     });
     //}
     ServiceLocator.Configure(app.ApplicationServices);
     app.UseStaticFiles();
     app.UseMvc();
 }
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseRouting();

            // global cors policy
            app.UseCors(x => x.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader());

            app.UseAuthentication();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });

            // Instance Factory
            ServiceLocator.Configure(app.ApplicationServices);

            // drop create database always
            using var context = new ApplicationDbContext();
            context.Database.EnsureDeleted();
            context.Database.EnsureCreated();
        }
Exemplo n.º 6
0
 /// <summary>
 ///     Initializes services that you need before app activation take into account that the splash screen is shown while
 ///     this code runs.
 /// </summary>
 /// <returns></returns>
 private static async Task InitializeAsync(IActivatedEventArgs args)
 {
     ServiceLocator.Configure(Services);
     LanguageServiceInitializationDeferral ??= await InteractiveInkServices.LanguageService
     .InitializeAsync(new Uri(Urls.LanguagesJsonUrl), args is ToastNotificationActivatedEventArgs);
 }
Exemplo n.º 7
0
        public static async Task ConfigureAsync()
        {
            ServiceLocator.Configure(_serviceCollection);

            await EnsureSettingsAsync();
        }
Exemplo n.º 8
0
        static public void Configure()
        {
            ConfigureNavigation();

            ServiceLocator.Configure(_serviceCollection);
        }
 private void ConfigureServiceLocator()
 {
     ServiceLocator.Clear();
     ServiceLocator.Register(l => Host);
     ServiceLocator.Configure();
 }