﻿using Autofac;
using Bit.Model.Events;
using Plugin.Connectivity.Abstractions;
using Prism;
using Prism.Autofac;
using Prism.Events;
using Prism.Ioc;
using Xamarin.Forms;

namespace Bit
{
    public abstract class BitApplication : PrismApplication
    {
        protected BitApplication(IPlatformInitializer platformInitializer = null)
            : base(platformInitializer)
        {
            MainPage = new ContentPage { };
        }

        protected override void OnInitialized()
        {
            IConnectivity connectivity = Container.Resolve<IConnectivity>();

            IEventAggregator eventAggregator = Container.Resolve<IEventAggregator>();

            connectivity.ConnectivityChanged += (sender, e) =>
            {
                eventAggregator.GetEvent<ConnectivityChangedEvent>()
                    .Publish(new ConnectivityChangedEvent { IsConnected = e.IsConnected });
            };
        }

        protected override void RegisterTypes(IContainerRegistry containerRegistry)
        {
            containerRegistry.GetBuilder().Register<IContainerProvider>(c => Container).SingleInstance().PreserveExistingDefaults();
        }
    }
}

﻿using Autofac;
using Bit.Model.Events;
using Plugin.Connectivity.Abstractions;
using Prism;
using Prism.Autofac;
using Prism.Events;
using Prism.Ioc;
using Xamarin.Forms;

namespace Bit
{
    public abstract class BitApplication : PrismApplication
    {
        protected BitApplication(IPlatformInitializer platformInitializer = null)
            : base(platformInitializer)
        {
            if (MainPage == null)
                MainPage = new ContentPage { Title = "DefaultPage" };
        }

        protected override void OnInitialized()
        {
            IConnectivity connectivity = Container.Resolve<IConnectivity>();

            IEventAggregator eventAggregator = Container.Resolve<IEventAggregator>();

            connectivity.ConnectivityChanged += (sender, e) =>
            {
                eventAggregator.GetEvent<ConnectivityChangedEvent>()
                    .Publish(new ConnectivityChangedEvent { IsConnected = e.IsConnected });
            };
        }

        protected override void RegisterTypes(IContainerRegistry containerRegistry)
        {
            containerRegistry.GetBuilder().Register<IContainerProvider>(c => Container).SingleInstance().PreserveExistingDefaults();
        }
    }
}

Set main page of bit application of cs client if no main page is provided (Due error/delay in initialization)
Set main page of bit application of cs client if no main page is provided (Due error/delay in initialization)
