Exemple #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);
        }
Exemple #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();
        }
Exemple #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);
        }
Exemple #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();
        }
Exemple #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);
        }
        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);
        }
Exemple #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);
        }
Exemple #8
0
        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);
        }
Exemple #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);
        }
Exemple #10
0
        public App()
        {
            AppHost = MobileBlazorBindingsHost.CreateDefaultBuilder()
                      .ConfigureServices((hostContext, services) =>
            {
                // Register app-specific services
                //services.AddSingleton<AppState>();
            })
                      .Build();

            AppHost.AddComponent <AppShell>(parent: this);
        }
Exemple #11
0
        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);
        }
Exemple #12
0
        public App()
        {
            _host = MobileBlazorBindingsHost.CreateDefaultBuilder()
                    .ConfigureServices((hostContext, services) =>
            {
                ConfigureServices(services);
            })
                    .Build();

            MainPage = new ContentPage();
            _host.AddComponent <ShellPage>(parent: this);
        }
Exemple #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
        }
Exemple #14
0
        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);
        }
Exemple #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);
        }
Exemple #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);
        }
Exemple #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);
        }
        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);
        }
Exemple #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);
        }
Exemple #20
0
        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);
        }
Exemple #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();
        }
Exemple #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);
        }
Exemple #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);
        }
Exemple #24
0
        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);
        }
Exemple #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);
        }
Exemple #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);
        }
Exemple #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);
        }
        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);
        }
Exemple #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);
        }