Resolving typeConverter class possible?

Jan 26, 2011 at 2:25 PM

Can typeConverter class used for constructor parameter conversion be also resolved from Unity container? (and have constructor with parameters etc.)

Jan 26, 2011 at 7:27 PM

In the config file you mean? No, the type converters are needed before the container is available, so they're new'ed up directly rather than resolved through the container.


Jan 26, 2011 at 8:32 PM

Ok. Thanks.. One more question. Does Unity support non-static factories?

Jan 26, 2011 at 10:54 PM

From the API, you can pass in whatever delegate you want via RegisterFactory. Static, member, web service, whatever you want.

You cannot configure factories via the configuration file, however. I really didn't want to write a C# compiler to handle code in the config file.


Jan 27, 2011 at 12:06 AM

I need something like:

class B{...}

class A{  public A(B b);}
class C{   public B Lookup(string code)   {     ...   }}

var c = new C(...);
var a1 = new A(c.Lookup("code1"));

var a2 = new A(c.Lookup("code2"));

All class instances should be resolved from container..

The problem is here: "new A(c.Lookup("code1"))".. I can't configure calling of C.Lookup in the config (run-time or XML)