Exemplo n.º 1
0
        public App(IPlatformInitializer initializer = null)
        {
            InitializeComponent();

            if (initializer != null)
            {
                initializer.RegisterTypes();
            }
            ViewModelLocator.RegisterViews();

            m_masterDetailRoot = new MasterDetailRoot();
            MainPage           = m_masterDetailRoot;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Run the bootstrapper process.
        /// </summary>
        public virtual void Initialize()
        {
            Logger = CreateLogger();

            ModuleCatalog = CreateModuleCatalog();
            ConfigureModuleCatalog();

            Container = CreateContainer();

            ConfigureContainer();

            RegisterTypes();

            _platformInitializer?.RegisterTypes(Container);

            NavigationService = CreateNavigationService();

            InitializeModules();
        }
Exemplo n.º 3
0
        public IContainer Boot()
        {
            try
            {
                var builder = new ContainerBuilder();

                var assembly = Assembly.GetExecutingAssembly();

                builder.RegisterAssemblyTypes(assembly)
                .Where(t => typeof(IAutoMapperConfiguration).IsAssignableFrom(t))
                .InstancePerLifetimeScope().AsImplementedInterfaces()
                .AsImplementedInterfaces();


                var container = builder.Build();

                var automappers = container.Resolve <IEnumerable <IAutoMapperConfiguration> >();

                var config = new MapperConfiguration(cfg =>
                {
                    foreach (var instance in automappers)
                    {
                        var automapperConfig = instance;
                        automapperConfig?.ConfigureAutomapper(cfg);
                    }
                });

                var mapper = config.CreateMapper();

                RegisterCommonServices(mapper);

                // register the native types
                _platformInitializer.RegisterTypes(_containerBuilder);

                // register the views and view models
                _containerBuilder.RegisterViews(assembly);
                _containerBuilder.RegisterViewModels(assembly);
                _containerBuilder.RegisterScreen(assembly);

                _containerBuilder.RegisterType <LoginView>().As <IViewFor <LoginViewModel> >();

                var container1 = _containerBuilder.Build();
                RxAppAutofacExtension.UseAutofacDependencyResolver(container1);

                StartAppCenter();

                Router = new RoutingState();

                // You must register This as IScreen to represent your app's main screen
                Locator.CurrentMutable.RegisterConstant(this, typeof(IScreen));

                NavigationService.Create(container1, Router);
                NavigationService.Navigation(typeof(LoginViewModel));

                return(container1);
            }
            catch (Exception ex)
            {
                // log
                throw ex;
            }
        }
Exemplo n.º 4
0
 public App(IPlatformInitializer initializer = null) : base(initializer)
 {
     initializer?.RegisterTypes(Container);
     SetStartPage();
 }