예제 #1
0
        public App(string[] args = null, IFileProvider fileProvider = null)
        {
            var hostBuilder = MobileBlazorBindingsHost.CreateDefaultBuilder(args)
                              .ConfigureServices((hostContext, services) =>
            {
                // Adds web-specific services such as NavigationManager
                services.AddBlazorHybrid();

                // Add protected storage for storage of refresh tokens
                services.AddProtectedStorage();

                // Register app-specific services
                services.AddSingleton <CounterState>();
                services.AddOidcAuthentication(options =>
                {
                    options.ProviderOptions.Authority = "https://demo.identityserver.io/";
                    options.ProviderOptions.ClientId  = "interactive.public";
                    options.ProviderOptions.DefaultScopes.Add("openid");
                    options.ProviderOptions.DefaultScopes.Add("profile");
                    options.ProviderOptions.DefaultScopes.Add("api");

                    // request offline_access. This scope will enable refresh tokens to
                    // be sent to this application. Refresh tokens make it possible to
                    // start the application and not having to login again (or start the
                    // browser popup to read cookies).
                    options.ProviderOptions.DefaultScopes.Add("offline_access");
                    options.ProviderOptions.ResponseType = "code";
                });

                // Configure HttpClient for use when talking to server backend. We use a hardcoded URL for now.
                services.AddHttpClient("demo",
                                       client => client.BaseAddress = new Uri(BaseUrl))
                .AddHttpMessageHandler(() => new ApiAuthorizationMessageHandler(BaseUrl));

                // Add the http client as the default to inject.
                services.AddScoped <HttpClient>(sp =>
                {
                    var accessTokenProvider = sp.GetRequiredService <IAccessTokenProvider>();
                    var httpClientFactory   = sp.GetRequiredService <IHttpClientFactory>();
                    ApiAuthorizationMessageHandler.RegisterTokenProvider(BaseUrl, accessTokenProvider);
                    return(httpClientFactory.CreateClient("demo"));
                });
            })
                              .UseWebRoot("wwwroot");

            if (fileProvider != null)
            {
                hostBuilder.UseStaticFiles(fileProvider);
            }
            else
            {
                hostBuilder.UseStaticFiles();
            }
            var host = hostBuilder.Build();

            MainPage = new ContentPage {
                Title = "My Application"
            };
            host.AddComponent <Main>(parent: MainPage);
        }
예제 #2
0
        public VanillaWpfApplication(string[] args = null, IFileProvider fileProvider = null)
        {
            // bootstrapping code that would typically be pushed down to the platform-agnostic level (HybridApp.App)
            // leaving it here so as not to touch the rest of the solution for now
            var hostBuilder = MobileBlazorBindingsHost.CreateDefaultBuilder(args)
                              .ConfigureServices((hostContext, services) =>
            {
                // Adds web-specific services such as NavigationManager
                services.AddBlazorHybrid();

                // Register app-specific services
                services.AddSingleton <CounterState>();
            })
                              .UseWebRoot("wwwroot");

            if (fileProvider != null)
            {
                hostBuilder.UseStaticFiles(fileProvider);
            }
            else
            {
                hostBuilder.UseStaticFiles();
            }

            _host = hostBuilder.Build();
        }
예제 #3
0
        public App()
        {
            var host = MobileBlazorBindingsHost.CreateDefaultBuilder()
                       .ConfigureServices((hostContext, services) =>
            {
                ApplicationConfiguration.Build(
                    new ApplicationConfigurationOptions(
#if DEBUG
                        "Development"
#else
                        "Production"
#endif
                        )
                    );
                Console.WriteLine("ServerUrl Configuration: " + ApplicationConfiguration.Configuration["ServerUrl"]);
                // Register app-specific services
                services.AddSingleton <IChatSettings>(
                    new GenericChatSettings(
                        ApplicationConfiguration.Configuration["ServerUrl"]
                        //"http://1dd1c1c3.ngrok.io/chatHub"
                        )
                    );
            })
                       .Build();

            host.AddComponent <ChatPage>(parent: this);
        }
예제 #4
0
        public MainPage(IFileProvider fileProvider = null)
        {
            var hostBuilder = MobileBlazorBindingsHost.CreateDefaultBuilder()
                              .ConfigureServices((hostContext, services) =>
            {
                // Adds web-specific services such as NavigationManager
                services.AddBlazorHybrid();

                // Register app-specific services
                services.AddSingleton <AppState>();
            })
                              .UseWebRoot("wwwroot");

            if (fileProvider != null)
            {
                hostBuilder.UseStaticFiles(fileProvider);
            }
            else
            {
                hostBuilder.UseStaticFiles();
            }
            Host = hostBuilder.Build();

            InitializeComponent();

            FolderWebView.Host = Host;

            MasterDetails.IsPresented = false;
            WorkaroundDisplayIssue();
        }
예제 #5
0
        public App()
        {
            BlazorHybridHost.AddResourceAssembly(GetType().Assembly, contentRoot: "WebUI/wwwroot");

            var host = MobileBlazorBindingsHost.CreateDefaultBuilder()
                       .ConfigureServices((hostContext, services) =>
            {
                // Adds web-specific services such as NavigationManager
                services.AddBlazorHybrid();

                // Register app-specific services
                services.AddSingleton <CounterState>();


                services.AddSingleton <AppState>();
                services.AddOptions();
                services.AddAuthorizationCore();
                services.AddScoped <CustomStateProvider>();
                services.AddScoped <AuthenticationStateProvider>(s => s.GetRequiredService <CustomStateProvider>());
                services.AddScoped <IAuthService, AuthService>();
            })
                       .Build();

            MainPage = new ContentPage {
                Title = "My Application"
            };
            host.AddComponent <Main>(parent: MainPage);
        }
예제 #6
0
        public App(IFileProvider fileProvider = null)
        {
            IHostBuilder hostBuilder = MobileBlazorBindingsHost.CreateDefaultBuilder()
                                       .ConfigureServices((hostContext, services) =>
            {
                // Adds web-specific services such as NavigationManager
                services.AddBlazorHybrid();

                // Register app-specific services
                services.AddSingleton <TodosState>();

                services.AddScoped(sp => new HttpClient {
                    BaseAddress = new Uri("https://jsonplaceholder.typicode.com/")
                });
            })
                                       .UseWebRoot("wwwroot");

            if (fileProvider != null)
            {
                hostBuilder.UseStaticFiles(fileProvider);
            }
            else
            {
                hostBuilder.UseStaticFiles();
            }
            IHost host = hostBuilder.Build();

            MainPage = new ContentPage {
                Title = GlobalConstants.AppName
            };
            host.AddComponent <Main>(parent: MainPage);
        }
예제 #7
0
        public App(IFileProvider fileProvider = null)
        {
            var hostBuilder = MobileBlazorBindingsHost.CreateDefaultBuilder()
                              .ConfigureServices((hostContext, services) =>
            {
                // Adds web-specific services such as NavigationManager
                services.AddBlazorHybrid();

                // Register app-specific services
                services.AddSingleton <CounterState>();
            })
                              .UseWebRoot("wwwroot");

            if (fileProvider != null)
            {
                hostBuilder.UseStaticFiles(fileProvider);
            }
            else
            {
                hostBuilder.UseStaticFiles();
            }
            var host = hostBuilder.Build();

            MainPage = new ContentPage {
                Title = "My Application"
            };
            host.AddComponent <Main>(parent: MainPage);
        }
예제 #8
0
파일: App.cs 프로젝트: DanGould/Hara
        public App(IFileProvider fileProvider = null, Action <IServiceCollection> configureDI = null)
        {
            var hostBuilder = MobileBlazorBindingsHost.CreateDefaultBuilder()
                              .ConfigureServices((hostContext, services) =>
            {
                // Adds web-specific services such as NavigationManager
                services.AddBlazorHybrid();

                // Register app-specific services
                services.AddSingleton <ICounterState, CounterState>();
                services.AddSingleton <ILocalContentFetcher, FileProviderLocalContentFetcher>();
                services.AddSingleton <IWebsiteLauncher, XamarinEssentialsWebsiteLauncher>();
                services.AddSingleton <IWeatherForecastFetcher, WeatherForecastFetcher>();
                services.AddSingleton <IConfigProvider, XamarinEssentialsConfigProvider>();
                configureDI?.Invoke(services);
            })
                              .UseWebRoot("wwwroot");

            if (fileProvider != null)
            {
                hostBuilder.UseStaticFiles(fileProvider);
            }
            else
            {
                hostBuilder.UseStaticFiles();
            }

            _host = hostBuilder.Build();

            MainPage = new ContentPage {
                Title = "My Application"
            };
            _host.AddComponent <Main>(parent: MainPage);
        }
예제 #9
0
        public App(string[] args = null, IFileProvider fileProvider = null)
        {
            var hostBuilder = MobileBlazorBindingsHost.CreateDefaultBuilder()
                              .ConfigureServices((hostContext, services) =>
            {
                // Adds web-specific services such as NavigationManager
                services.AddBlazorHybrid();

                // Register app-specific services
                //services.AddSingleton<CounterState>();

                var web3ServiceProvider                  = new Web3ProviderService();
                var accountsService                      = new AccountsService(web3ServiceProvider);
                var newBlockProcessingService            = new NewBlockProcessingService(web3ServiceProvider);
                var toastsViewModel                      = new ToastsViewModel();
                var blocksViewModel                      = new BlocksViewModel(newBlockProcessingService);
                var latestBlockTransactionsViewModel     = new LatestBlockTransactionsViewModel(web3ServiceProvider);
                var newAccountPrivateKeyViewModel        = new NewAccountPrivateKeyViewModel();
                var accountsViewModel                    = new AccountsViewModel(accountsService, newAccountPrivateKeyViewModel);
                var accountsTransactionMonitoringService = new AccountsTransactionMonitoringService(accountsService, web3ServiceProvider);

                services.AddSingleton <IWeb3ProviderService, Web3ProviderService>((x) => web3ServiceProvider);
                services.AddSingleton <IAccountsService, AccountsService>((x) => accountsService);
                services.AddSingleton <NewBlockProcessingService>(newBlockProcessingService);
                services.AddSingleton <ToastsViewModel>(toastsViewModel);
                services.AddSingleton <BlocksViewModel>(blocksViewModel);
                services.AddSingleton <LatestBlockTransactionsViewModel>(latestBlockTransactionsViewModel);
                services.AddTransient <BlockTransactionsViewModel>();
                services.AddSingleton <AccountsViewModel>(accountsViewModel);
                services.AddSingleton <NewAccountPrivateKeyViewModel>(newAccountPrivateKeyViewModel);
                services.AddSingleton <SendTransactionViewModel>();
                services.AddSingleton <SendErc20TransactionViewModel>();
                services.AddSingleton(accountsTransactionMonitoringService);
                services.AddSingleton <TransactionWithReceiptViewModel>();
                services.AddSingleton <Web3UrlViewModel>();

                services.AddFlexGrid(cfg =>
                {
                    cfg.ApplyConfiguration(new TransactionsViewModelGridConfiguration());
                });
            })
                              .UseWebRoot("wwwroot");

            if (fileProvider != null)
            {
                hostBuilder.UseStaticFiles(fileProvider);
            }
            else
            {
                hostBuilder.UseStaticFiles();
            }
            var host = hostBuilder.Build();

            MainPage = new ContentPage();
            NavigationPage.SetHasNavigationBar(MainPage, false);
            host.AddComponent <Main>(parent: MainPage);
        }
예제 #10
0
        public App()
        {
            AppHost = MobileBlazorBindingsHost.CreateDefaultBuilder()
                      .ConfigureServices((hostContext, services) =>
            {
                // Register app-specific services
                //services.AddSingleton<AppState>();
            })
                      .Build();

            AppHost.AddComponent <AppShell>(parent: this);
        }
예제 #11
0
파일: App.cs 프로젝트: Saurer/BlazorMobile
        public App()
        {
            var host = MobileBlazorBindingsHost.CreateDefaultBuilder()
                       .ConfigureServices((hostContext, services) => {
                // Register app-specific services
                //services.AddSingleton<AppState>();
            })
                       .Build();

            // MainPage = new ContentPage();
            host.AddComponent <TodoApp>(parent: this);
        }
예제 #12
0
        public App()
        {
            _host = MobileBlazorBindingsHost.CreateDefaultBuilder()
                    .ConfigureServices((hostContext, services) =>
            {
                ConfigureServices(services);
            })
                    .Build();

            MainPage = new ContentPage();
            _host.AddComponent <ShellPage>(parent: this);
        }
예제 #13
0
        public App()
        {
            var host = MobileBlazorBindingsHost.CreateDefaultBuilder()
                       .ConfigureServices((hostContext, services) =>
            {
                // Register app-specific services
                //services.AddSingleton<AppState>();
            })
                       .Build();

            MainPage = new ContentPage();
            host.AddComponent <Main>(parent: MainPage); // Change 'HelloWorld' to your app's main UI page
        }
예제 #14
0
파일: App.cs 프로젝트: 4423/GoLab
        public App()
        {
            var host = MobileBlazorBindingsHost.CreateDefaultBuilder()
                       .ConfigureServices((hostContext, services) =>
            {
                // Register app-specific services
                services.AddSingleton <DirectionsService>();
            })
                       .Build();

            MainPage = new ContentPage();
            host.AddComponent <MainPage>(parent: MainPage);
        }
예제 #15
0
        public App(string[] args = null)
        {
            var host = MobileBlazorBindingsHost.CreateDefaultBuilder(args)
                       .ConfigureServices((hostContext, services) =>
            {
                // Register app-specific services
                //services.AddSingleton<AppState>();
            })
                       .Build();

            MainPage = new ContentPage();
            host.AddComponent <HelloWorld>(parent: MainPage);
        }
예제 #16
0
        public App()
        {
            var host = MobileBlazorBindingsHost.CreateDefaultBuilder()
                       .ConfigureServices((hostContext, services) =>
            {
                services.AddSingleton <AppState>();
                services.AddSingleton <IAsyncContentManager>(b => b.GetRequiredService <AppState>().DBManager);
            })
                       .Build();

            MainPage = new TabbedPage();
            host.AddComponent <LastWeekApp>(parent: MainPage);
        }
예제 #17
0
        public App()
        {
            var host = MobileBlazorBindingsHost.CreateDefaultBuilder()
                       .ConfigureServices((hostContext, services) =>
            {
                services.AddSingleton <IStorageService, StorageService>();
            })
                       .Build();

            MainPage = new ContentPage();
            MainPage.On <iOS>().SetUseSafeArea(true);
            host.AddComponent <LoginPage>(parent: MainPage);
        }
예제 #18
0
        public App(string[] args = null)
        {
            var host = MobileBlazorBindingsHost.CreateDefaultBuilder(args)
                       .ConfigureServices((hostContext, services) =>
            {
                // Register app-specific services
                //services.AddSingleton<AppState>();
                services.AddSingleton <ShellNavigationManager>();
            })
                       .Build();

            MainPage = new ContentPage();
            host.AddComponent <AppShell>(this);
        }
예제 #19
0
        public App(string[] args = null, IFileProvider fileProvider = null)
        {
            var hostBuilder = MobileBlazorBindingsHost.CreateDefaultBuilder(args)
                              .ConfigureServices((hostContext, services) =>
            {
                // Adds web-specific services such as NavigationManager
                services.AddBlazorHybrid();

                // Add protected storage for storage of refresh tokens
                services.AddProtectedStorage();

                // Register app-specific services
                services.AddSingleton <CounterState>();

                services.AddMsalAuthentication(sp =>
                {
                    var builder = PublicClientApplicationBuilder
                                  .Create(ClientId)
                                  .WithTenantId(TenantId);

                    if (Device.RuntimePlatform == Device.WPF)
                    {
                        builder = builder.WithRedirectUri("http://localhost");
                    }
                    else if (Device.RuntimePlatform == Device.iOS)
                    {
                        // should be the same as Entitlements.plist
                        builder.WithIosKeychainSecurityGroup("com.companyname");
                    }

                    return(builder.Build());
                });
            })
                              .UseWebRoot("wwwroot");

            if (fileProvider != null)
            {
                hostBuilder.UseStaticFiles(fileProvider);
            }
            else
            {
                hostBuilder.UseStaticFiles();
            }
            var host = hostBuilder.Build();

            MainPage = new ContentPage {
                Title = "My Application"
            };
            host.AddComponent <Main>(parent: MainPage);
        }
예제 #20
0
파일: App.cs 프로젝트: julc14/MealPlanner
        public App()
        {
            var host = MobileBlazorBindingsHost.CreateDefaultBuilder()
                       .ConfigureServices((hostContext, services) =>
            {
                services.AddSingleton <IRecipeProvider, InternalRecipeProvider>();
                services.AddSingleton <ShellNavigationManager>();
                services.AddSingleton <MealPlanGenerator>();
            })
                       .Build();

            MainPage = new ContentPage();
            host.AddComponent <AppShell>(parent: this);
        }
예제 #21
0
        public BlazorApp(IFileProvider fileProvider = null, Action <IServiceCollection> configureDI = null)
        {
            var hostBuilder = MobileBlazorBindingsHost.CreateDefaultBuilder()
                              .ConfigureServices((hostContext, services) =>
            {
                services.AddCommonServices();
                services.AddUIServices();

                // Adds web-specific services such as NavigationManager
                services.AddBlazorHybrid();

                services.AddScoped <IClipboard, XamarinClipboard>();
                services.AddSingleton <IDataDirProvider, XamarinDataDirProvider>();
                services.AddSingleton <IMainThreadInvoker, XamarinMainThreadInvoker>();
                services.AddSingleton <IShare, XamarinShare>();
                services.AddSingleton <IThemeManager, XamarinThemeManager>();

                configureDI?.Invoke(services);
            })
                              .UseWebRoot("wwwroot");

            if (fileProvider != null)
            {
                hostBuilder.UseStaticFiles(fileProvider);
            }
            else
            {
                hostBuilder.UseStaticFiles();
            }

            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            TaskScheduler.UnobservedTaskException      += TaskScheduler_UnobservedTaskException;

            _host    = hostBuilder.Build();
            MainPage = new ContentPage {
                Title = "Chaincase"
            };
            _host.AddComponent <Main>(parent: MainPage);

            var dataDir = ServiceProvider.GetRequiredService <IDataDirProvider>().Get();

            Directory.CreateDirectory(dataDir);
            var config = ServiceProvider.GetRequiredService <Config>();

            config.LoadOrCreateDefaultFile();
            var uiConfig = ServiceProvider.GetRequiredService <UiConfig>();

            uiConfig.LoadOrCreateDefaultFile();
        }
예제 #22
0
        public App()
        {
            var host = MobileBlazorBindingsHost.CreateDefaultBuilder()
                       .ConfigureServices((hostContext, services) =>
            {
                // Register app-specific services
                //services.AddSingleton<AppState>();
                services.AddHttpClient();
                services.AddScoped <ChatHubService>();
            })
                       .Build();

            MainPage = new ContentPage();
            host.AddComponent <ChatComponent>(parent: MainPage);
        }
예제 #23
0
        public App()
        {
            var host = MobileBlazorBindingsHost.CreateDefaultBuilder()
                       .ConfigureServices((hostContext, services) =>
            {
                // Register app-specific services
                //services.AddSingleton<AppState>();
            })
                       .Build();

            MainPage = new ContentPage {
                BackgroundColor = Color.FromHex("#532676")
            };
            host.AddComponent <BlazorHomePage>(parent: MainPage);
        }
예제 #24
0
파일: App.cs 프로젝트: xamarinhub/Rezipe
        public App()
        {
            AppHost = MobileBlazorBindingsHost.CreateDefaultBuilder()
                      .ConfigureServices((hostContext, services) =>
            {
                // Register app-specific services
                //services.AddSingleton<AppState>();
                services.AddSingleton <ShellNavigationManager>();
                services.AddSingleton <RecipeStore>();
                services.AddSingleton <UserDataStore>();
            })
                      .Build();

            MainPage = new ContentPage();
            AppHost.AddComponent <RezipeApp>(parent: this);
        }
예제 #25
0
        public App()
        {
            var database = new BudgetTrackerDb(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "budgettracker.db3"));

            var host = MobileBlazorBindingsHost.CreateDefaultBuilder()
                       .ConfigureServices((hostContext, services) =>
            {
                // Register app-specific services
                services.AddSingleton <BudgetTrackerDb>(database);
                services.AddSingleton <AppState>();
            })
                       .Build();

            MainPage = new ContentPage();
            host.AddComponent <HomePage>(parent: MainPage);
        }
예제 #26
0
        public App()
        {
            AppHost = MobileBlazorBindingsHost.CreateDefaultBuilder()
                      .ConfigureServices((hostContext, services) =>
            {
                // Register app-specific services
                //services.AddSingleton<AppState>();
            })
                      .Build();

            //We have to set a placeholder MainPage here, because setting it in AddComponent happens after it returns.
            //This causes iOS to kill the app because iOS thinks we never set a page.
            MainPage = new ContentPage();

            AppHost.AddComponent <AppShell>(parent: this);
        }
예제 #27
0
        public App()
        {
            BlazorHybridHost.AddResourceAssembly(typeof(App).Assembly, contentRoot: "WebUI/wwwroot");

            var host = MobileBlazorBindingsHost.CreateDefaultBuilder()
                       .ConfigureServices((hostContext, services) =>
            {
                services.AddBlazorHybrid();
                services.AddSingleton <BlazorLib.State.CounterState>();
            })
                       .Build();

            MainPage = new ContentPage {
                Title = "My Application"
            };
            host.AddComponent <Main>(parent: MainPage);
        }
        public App()
        {
            var host = MobileBlazorBindingsHost.CreateDefaultBuilder()
                       .ConfigureServices((hostContext, services) =>
            {
                // Register app-specific services
                //services.AddSingleton<AppState>();
                services.AddSingleton <BLEService>();
                services.AddSingleton <IPermissions>((e) => CrossPermissions.Current);
                services.AddSingleton <IBluetoothLE>((e) => CrossBluetoothLE.Current);
                services.AddSingleton <IAdapter>((e) => CrossBluetoothLE.Current.Adapter);
            })
                       .Build();

            MainPage = new ContentPage();
            host.AddComponent <AppPage>(parent: MainPage);
        }
예제 #29
0
        public App(IServiceCollection additionalServices)
        {
            AppHost = MobileBlazorBindingsHost.CreateDefaultBuilder()
                      .ConfigureServices((hostContext, services) =>
            {
                if (additionalServices != null)
                {
                    services.AddAdditionalServices(additionalServices);
                }

                // Register app-specific services
                services.AddSingleton <AppState>();
            })
                      .Build();

            MainPage = new TabbedPage();
            AppHost.AddComponent <TodoApp>(parent: MainPage);
        }
예제 #30
0
        public AppStartup(IFileProvider fileProvider = null)
        {
            var hostBuilder = MobileBlazorBindingsHost.CreateDefaultBuilder()
                              .ConfigureServices((hostContext, services) =>
            {
                // Adds web-specific services such as NavigationManager
                services.AddBlazorHybrid();

                services.AddTransient <IWeatherForecastService, BindingWeatherForecastService>();
                services.TryAddReactiveViewServices
                (
                    XamarinDispatcherScheduler.Current,
                    new LayoutConfigBuilder()
                    .WithIsServer(false)
                    .WithIsPreRendering(false)
                    .WithResponsive(true)
                    // .WithDisableBinding(true)
                    .Build()
                );
            })
                              .UseWebRoot("wwwroot");

            if (fileProvider != null)
            {
                hostBuilder.UseStaticFiles(fileProvider);
            }
            else
            {
                hostBuilder.UseStaticFiles();
            }
            var host = hostBuilder.Build();

            var contentPage = new ContentPage {
                Title = "Skclusive Reactive"
            };

            // hiding the title bar
            NavigationPage.SetHasNavigationBar(contentPage, false);

            MainPage = contentPage;

            host.AddComponent <Main>(parent: MainPage);
        }