예제 #1
0
        public static async Task Main(string[] args)
        {
            var builder = WebAssemblyHostBuilder.CreateDefault(args);

            builder.Services.AddSingleton(new HttpClient {
                BaseAddress = new Uri(builder.HostEnvironment.BaseAddress)
            });

            #region Services registration

            ServicesHelper.ConfigureCommonServices(builder.Services);

            #endregion


            BlazorMobileService.OnBlazorMobileLoaded += (object source, BlazorMobileOnFinishEventArgs eventArgs) =>
            {
                Console.WriteLine($"Initialization success: {eventArgs.Success}");
                Console.WriteLine("Device is: " + BlazorDevice.RuntimePlatform);
            };

            builder.RootComponents.Add <MobileApp>("app");

            await builder.Build().RunAsync();
        }
예제 #2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc().AddNewtonsoftJson();
            services.AddRazorPages();
            services.AddServerSideBlazor();
            services.AddResponseCompression(opts =>
            {
                opts.MimeTypes = ResponseCompressionDefaults.MimeTypes.Concat(
                    new[] { "application/octet-stream" });
            });

            // Server Side Blazor doesn't register HttpClient by default
            if (!services.Any(x => x.ServiceType == typeof(HttpClient)))
            {
                // Setup HttpClient for server side in a client side compatible fashion
                services.AddScoped <HttpClient>(s =>
                {
                    // Creating the URI helper needs to wait until the JS Runtime is initialized, so defer it.
                    var uriHelper = s.GetRequiredService <NavigationManager>();
                    return(new HttpClient
                    {
                        BaseAddress = new Uri(uriHelper.BaseUri)
                    });
                });
            }

            services.AddBlazorMobileNativeServices <InteropBlazorApp.Program>();
            ServicesHelper.ConfigureCommonServices(services);
        }
예제 #3
0
        public static async Task Main(string[] args)
        {
            var builder = WebAssemblyHostBuilder.CreateDefault(args);

            builder.Services.AddSingleton(new HttpClient {
                BaseAddress = new Uri(builder.HostEnvironment.BaseAddress)
            });

            #region Services registration

            ServicesHelper.ConfigureCommonServices(builder.Services);

            #endregion

            #if DEBUG
            //Only if you want to test WebAssembly with remote debugging from a dev machine
            BlazorMobileService.EnableClientToDeviceRemoteDebugging("127.0.0.1", 8888);
            #endif

            BlazorMobileService.OnBlazorMobileLoaded += (object source, BlazorMobileOnFinishEventArgs eventArgs) =>
            {
                Console.WriteLine($"Initialization success: {eventArgs.Success}");
                Console.WriteLine("Device is: " + BlazorDevice.RuntimePlatform);
            };

            builder.RootComponents.Add <MobileApp>("app");

            await builder.Build().RunAsync();
        }
예제 #4
0
        public static async Task Main(string[] args)
        {
            var builder = WebAssemblyHostBuilder.CreateDefault(args);

            #region Services registration

            ServicesHelper.ConfigureCommonServices(builder.Services);

            #endregion

            #region DEBUG

            //Only if you want to test WebAssembly with remote debugging from a dev machine
            BlazorMobileService.EnableClientToDeviceRemoteDebugging("127.0.0.1", 8888);

            #endregion

            BlazorMobileService.Init((bool success) =>
            {
                Console.WriteLine($"Initialization success: {success}");
                Console.WriteLine("Device is: " + BlazorDevice.RuntimePlatform);
            });

            builder.RootComponents.Add <MobileApp>("app");

            await builder.Build().RunAsync();
        }
예제 #5
0
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddSingleton <IStorage, KudoCodeLocalStorage>();
            services.AddSingleton <ITokenCache, CsrfLocalTokenCache>();

            services.AddAutoMapper(typeof(Startup).Assembly);
            services.AddKudoCodeNavigation();
            services.AddScoped <IApplicationUserContext, ApplicationUserContext>();
            services.AddScoped <WebHandlerController>();
            services.AddScoped <IWebHandler <GetTokenRequest, int>, GetTokenRequestWebHandler>();
            services.AddScoped <IApplicationContextHandler, ApplicationContextHandler>();
            services.AddScoped <HttpHandler>();
            services.AddScoped(typeof(ApiPostHandler <,>));
            services.AddScoped <ApiPostController>();
            services.AddScoped <WebHandlerController>();
            services.AddEnvironmentConfiguration <Startup>(() =>
                                                           new EnvironmentChooser("development")
                                                           .Add("localhost", "development")
                                                           .Add("kudocode.me", "Production", false));

            ServicesHelper.ConfigureCommonServices(services);

            services.AddMvc().AddNewtonsoftJson();
            services.AddServerSideBlazor();
            services.AddResponseCompression(opts =>
            {
                opts.MimeTypes = ResponseCompressionDefaults.MimeTypes.Concat(
                    new[] { "application/octet-stream" });
            });

            // Server Side Blazor doesn't register HttpClient by default
            if (!services.Any(x => x.ServiceType == typeof(HttpClient)))
            {
                // Setup HttpClient for server side in a client side compatible fashion
                services.AddScoped <HttpClient>(s =>
                {
                    // Creating the URI helper needs to wait until the JS Runtime is initialized, so defer it.
                    var uriHelper = s.GetRequiredService <NavigationManager>();
                    return(new HttpClient
                    {
                        BaseAddress = new Uri(uriHelper.BaseUri)
                    });
                });
            }

            ServicesHelper.ConfigureCommonServices(services);
        }
예제 #6
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddSingleton <IStorage, KudoCodeLocalStorage>();
            services.AddSingleton <ITokenCache, CsrfLocalTokenCache>();

            services.AddAutoMapper(typeof(Startup).Assembly);
            services.AddKudoCodeNavigation();
            services.AddScoped <IApplicationUserContext, ApplicationUserContext>();
            services.AddScoped <WebHandlerController>();
            services.AddScoped <IWebHandler <GetTokenRequest, int>, GetTokenRequestWebHandler>();
            services.AddScoped <IApplicationContextHandler, ApplicationContextHandler>();
            services.AddScoped <HttpHandler>();
            services.AddScoped(typeof(ApiPostHandler <,>));
            services.AddScoped <ApiPostController>();
            services.AddScoped <WebHandlerController>();
            services.AddEnvironmentConfiguration <Startup>(() =>
                                                           new EnvironmentChooser("development")
                                                           .Add("localhost", "development")
                                                           .Add("kudocode.me", "Production", false));

            ServicesHelper.ConfigureCommonServices(services);
        }
예제 #7
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddBlazorMobileNativeServices <InteropBlazorApp.Startup>();

            ServicesHelper.ConfigureCommonServices(services);
        }
예제 #8
0
 public void ConfigureServices(IServiceCollection services)
 {
     ServicesHelper.ConfigureCommonServices(services);
 }
예제 #9
0
        public static async Task Main(string[] args)
        {
            var builder = WebAssemblyHostBuilder.CreateDefault(args);

            builder.Services.AddSingleton(new HttpClient {
                BaseAddress = new Uri(builder.HostEnvironment.BaseAddress)
            });



            #region Services registration

            ServicesHelper.ConfigureCommonServices(builder.Services);


            builder.Services
            .AddScoped <IAuthenticationService, AuthenticationService>()
            .AddScoped <IUserService, UserService>()
            .AddScoped <IHttpService, HttpService>()
            .AddScoped <ILocalStorageService, LocalStorageService>();

            // configure http client
            builder.Services.AddScoped(x =>
            {
                var apiUrl = new Uri(builder.Configuration["apiUrl"]);

                // use fake backend if "fakeBackend" is "true" in appsettings.json
                if (builder.Configuration["fakeBackend"] == "true")
                {
                    return new HttpClient(new FakeBackendHandler())
                    {
                        BaseAddress = apiUrl
                    }
                }
                ;

                return(new HttpClient()
                {
                    BaseAddress = apiUrl
                });
            });

            var host = builder.Build();

            var authenticationService = host.Services.GetRequiredService <IAuthenticationService>();
            await authenticationService.Initialize();


            #endregion


            BlazorMobileService.OnBlazorMobileLoaded += (object source, BlazorMobileOnFinishEventArgs eventArgs) =>
            {
                Console.WriteLine($"Initialization success: {eventArgs.Success}");
                Console.WriteLine("Device is: " + BlazorDevice.RuntimePlatform);
            };

            builder.RootComponents.Add <MobileApp>("app");

            await builder.Build().RunAsync();
        }