Example #1
0
        private void ConfigureServices()
        {
            var services = new ServiceCollection();

            // The CSLA configuration here uses an ApplicationContextManager
            // copied from the Csla.Xaml.Shared project, so the same manager
            // used for WPF, UWP, etc.

            // use local data portal
            services.AddCsla(o => o
                             .RegisterContextManager <Csla.Xaml.ApplicationContextManager>());
            services.AddTransient(typeof(DataAccess.IPersonDal), typeof(DataAccess.PersonDal));

            // use remote data portal (requires an app server
            // that can be reached from your Android emulator)
            //
            //services.AddTransient<System.Net.Http.HttpClient>();
            //services.AddCsla(o => o
            //  .RegisterContextManager<Csla.Xaml.ApplicationContextManager>()
            //  .DataPortal(dpo => dpo
            //    .UseHttpProxy(hpo => hpo
            //      .DataPortalUrl = "http://myserver/api/dataportal")));

            var provider = services.BuildServiceProvider();

            ApplicationContext = provider.GetService <ApplicationContext>();

            //var proxy = provider.GetService<Csla.DataPortalClient.IDataPortalProxy>();
            //var dp = provider.GetService<IDataPortal<BusinessLibrary.PersonList>>();
            //var dp = Csla.Xaml.ApplicationContextManager.GetApplicationContext()
            //  .GetRequiredService<IDataPortal<BusinessLibrary.PersonList>>();
        }