How does one resolve dependencies in MVVMCross using the default Microsoft IServiceProvider?

Preferably, no dependencies would be resolved using Mvx.

All dependencies would be resolved using Microsoft's Dependency Injection.

How does one resolve dependencies in MVVMCross using the default IServiceProvider?

Here is an example

    public class Startup
    {
        private IConfiguration Configuration { get; set; }
        private IServiceProvider Services { get; set; }

        public Startup()
        {
            IServiceCollection services = new ServiceCollection();

            Configuration = BuildConfiguration();

            ConfigureServices(services);
            Services = services.BuildServiceProvider();
        }

        private IConfiguration BuildConfiguration()
        {
            return new ConfigurationBuilder()
                .SetBasePath(Directory.GetCurrentDirectory())
                .AddJsonFile("configuration.json")
                .Build();
        }

        private void ConfigureServices(IServiceCollection services)
        {
            services.AddSingleton<IManager, Manager>();
            services.AddSingleton<ITestService, TestService>();

            services.Configure<Options>(Configuration.GetSection("Options"));
        }
    }
Sign In or Register to comment.