public async void Run(IBackgroundTaskInstance taskInstance)
        {
            try
            {
                Deferral = taskInstance.GetDeferral();
                var containerFactory = new ContainerFactory();
                containerFactory.AddRegistrations(builder =>
                {
                    var uwpRegistrations = new UWPPlatformServicesRegistrator();
                    uwpRegistrations.RegisterPlatformSpecificServices(builder);
                });

                var container    = containerFactory.Build();
                var synchronizer = container.Resolve <ISynchronizer>();

                var serverOnline = await synchronizer.Synchronize();
            }
            catch (Exception ex)
            {
                //Console.WriteLine(ex.ToString());
            }
            finally
            {
                Deferral.Complete();
            }
        }
        public AndroidApplication()
        {
            var factory = new ContainerFactory();

            //Platform registrations
            factory.AddRegistrations(builder =>
            {
                builder.RegisterType <AndroidNavigationManager>().As <INavigationManager>();
                builder.Register <Context>(container => Application.Context);
            });

            this.Container = factory.Build();
        }
        public App(ContainerFactory containerFactory)
        {
            //InitializeComponent();
            containerFactory.AddRegistrations(builder =>
            {
                builder.Register <Application>(x => Application.Current);
                builder.Register <IContainer>(x => Container);

                builder.RegisterType <ConfigurationPresenter>().As <IConfigurationPresenter>();
                builder.RegisterType <ConfigurationView>().As <IConfigurationView>();
                builder.RegisterType <LoginPresenter>().As <ILoginPresenter>();
                builder.RegisterType <LoginView>().As <ILoginView>();
                builder.RegisterType <VaultExplorerPresenter>().As <IVaultExplorerPresenter>();
                builder.RegisterType <VaultExplorerView>().As <IVaultExplorerView>();
                builder.RegisterType <EntryDetailsPresenter>().As <IEntryDetailsPresenter>();
                builder.RegisterType <EntryDetailsView>().As <IEntryDetailsView>();

                //=== Platform Specific
                var platformServicesRegistrator = DependencyService.Get <IPlatformServicesRegistrator>();
                platformServicesRegistrator.RegisterPlatformSpecificServices(builder);
            });

            Container = containerFactory.Build();


            var configurationManager          = Container.Resolve <IMobileConfigurationReader>();
            var presenterFactory              = Container.Resolve <IPresenterFactory>();
            var synchronizationServiceManager = Container.Resolve <ISynchronizationServiceManager>();

            if (configurationManager.GetConfiguration().AlreadyInitialized)
            {
                if (configurationManager.GetConfiguration().ApplicationMode == ApplicationMode.Client)
                {
                    synchronizationServiceManager.StartSynchronizationService();
                }
                var loginPresenter = presenterFactory.Create <ILoginPresenter>();
                MainPage = new NavigationPage(loginPresenter.GetView() as Page);
            }
            else
            {
                var configPresenter = presenterFactory.Create <IConfigurationPresenter>();
                MainPage = new NavigationPage(configPresenter.GetView() as Page);
            }
        }
        protected override void OnHandleIntent(Intent intent)
        {
            try
            {
                Console.WriteLine("Service Started");
                var containerFactory = new ContainerFactory();
                containerFactory.AddRegistrations(builder =>
                {
                    var androidRegistrations = new AndroidPlatformServicesRegistrator();
                    androidRegistrations.RegisterPlatformSpecificServices(builder);
                });

                var container    = containerFactory.Build();
                var synchronizer = container.Resolve <ISynchronizer>();

                var serverOnline = synchronizer.Synchronize().Result;
                Console.WriteLine($"Service Synchronization Finished - Result: {serverOnline}");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
Esempio n. 5
0
        public override void OnReceive(Context context, Intent intent)
        {
            Console.WriteLine($"Boot receiver started. Action: {intent.Action}");
            var containerFactory = new ContainerFactory();

            containerFactory.AddRegistrations(builder =>
            {
                var androidRegistrations = new AndroidPlatformServicesRegistrator();
                androidRegistrations.RegisterPlatformSpecificServices(builder);
            });

            var container            = containerFactory.Build();
            var configurationManager = container.Resolve <IMobileConfigurationReader>();

            if (configurationManager.GetConfiguration().AlreadyInitialized)
            {
                if (configurationManager.GetConfiguration().ApplicationMode == ApplicationMode.Client)
                {
                    var synchronizer = container.Resolve <ISynchronizationServiceManager>();
                    synchronizer.StartSynchronizationService();
                }
            }
        }
        public override async void PerformFetch(UIApplication application, Action <UIBackgroundFetchResult> completionHandler)
        {
            try
            {
                var containerFactory = new ContainerFactory();
                containerFactory.AddRegistrations(builder =>
                {
                    var iosRegistrations = new iOSPlatformServicesRegistrator();
                    iosRegistrations.RegisterPlatformSpecificServices(builder);
                });

                var container    = containerFactory.Build();
                var synchronizer = container.Resolve <ISynchronizer>();

                var serverOnline = await synchronizer.Synchronize();

                completionHandler(UIBackgroundFetchResult.NewData);
            }
            catch (Exception ex)
            {
                completionHandler(UIBackgroundFetchResult.Failed);
            }
        }