inversion of control - How do I do this in Unity? -


The one example is an article on the use of Jimmy Bogart He uses Strccrmap but I'm using Unity And I'm not sure how to use the injection constructor.

Below is the code from the paragraph and below is my bad attempt. Can anyone tell me how to do it properly?

  public class configuration registry: Registry {public configuration registry () (ForRequestedType & lt; Configuration & gt; () .CacheBy (InstanceScope.Singleton) .Default.Is.OfConcreteType & lt; Configuration & gt; () .CtorDependency & lt; IEnumerable & lt; IObjectMapper & gt; & gt; (). what is (expr = & gt; expr.Constructed By (MapperRegistry.AllMappers)); ForRequestedType & lt; IConfigurationProvider & gt ; () Kdifoltkais. Constrkt the (ctx = & gt; ctx.GetInstance & lt; configuration & gt; (the)); ForRequestedType & lt; IConfiguration & gt; () Kdifoltkais. Constrkt made ( Ctx = & g t; ctx.GetInstance & lt; Configuration & gt; ());}}  

My try:

  container . Registration type & lt; IConfiguration, configuration & gt; (new Singleton Lifetime). configure & lt; Injektmmber & gt; (). & for Confifikeshn injection lt; configuration & gt; (new Injekshnsnketk (Taipf (IEnumerable & lt; IObjectMapper & gt;), MapRarist AllMappers;  

This is what I am doing:

 < Code> INMMerable & lt; IObjectMapper & gt; New = New list & amp; Lt; IObjectMapper & gt; New AssignableMapper (), // new typemapmaprar (typemapmapmigration.org), new stringmaper (), new flagmem Mapper (), new animator (), new Aramapaper (), new dictionarymapper (), newer NemerineMemper (), new AssignableMapper (), // New TypeConverterMapper (), New NullableMapper (),}; Container. Registration Registration & lt; Configuration & gt; (New Singleton Lifetime). Confidential & Lt; Injectemember & gt; (). Configuration InjectionFor & lt; Configuration & gt; (New injection conector (all mapper)); Container. Registration Type & lt; IConfigurationProvider, Configuration & gt; (); Container. Registration Type & lt; IConfiguration, Configuration & gt; (); Container. Registration Type & lt; IMappingEngine, Mapping Engine & gt; ();  

This works but if there is a better implementation of someone else then I am all ears and there is still a reward on this.


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -