mvvmcross - How to resolve a Collection of Types from within the IoC Container -


We are using MvvmCross in our app, and

In App startup, we register Are all our migration
The successor of all migration

  It is easy to connect with the type of immigration. Assembly. Surgery type (). Inheritance & lt; IMAGE & gt; () .AsTypes (). Registrar Ezazzi Sysington ();   

After the registration of the migration, we need to constantly run them, and so the migration operator looks something like this.

  Mvx.Resolve & lt; IMigrationRunner & gt; (). RunAll (SystemRol.Customer, new list & lt; emigration & gt; {Mvx.IocConstruct & lt; migration 2001 & gt; (), Mvx.IocConstruct & lt; Migration 002 & gt; ()});   

As you can see, I am clearly using MVX to build each migration. It is tedious and there is a possibility of mistakes, when a bunch of migration ends in the app.

What I want to be able to do is hide the entire collection in one, each time I create a new migration, then touch it.

Is there any way to do this through MVVMCross?


Pseudo Code

  Mvx .Resolve & LT; IMigrationRunner & gt; () .RunAll (SystemRole.Client, Mvx.ResolveAll & lt; emigration & gt; ());    

After

I will use LINQ to get a list of type. Unfortunately there is no way to get the list of registered types, so you have to calculate the type of type you need to register for registration. You can also sort by the name of the type. Now if you have a list of types then you can create a new list of instantiated / resolved type to pass it in RunAll () Something like:

 migrationTypes = typeof (emigration) on  .Assembly .CreatableTypes (). Inherits & LT; Emigration & gt; () .AsTypes () .OrderBy (T = & gt; t.Name) .Olist (); Mvx.Resolve & LT; IMigrationRunner & gt; () .RunAll (SystemRole.Client, migrationTypes.Select (t => Mvx.Resolve (t) ToList ());   

This is a "browser" code, so there is no guarantee, but you get the essence.

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -