Resolving typeConverter class possible?

Jan 26, 2011 at 1: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 6: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 7:32 PM

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

Jan 26, 2011 at 9: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 26, 2011 at 11:06 PM

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)