LiftetimeManager force IBuilderContext

Jan 4, 2010 at 2:49 PM

Hi

I'm using Unity with WCF. I have something like:

public class WCFLifetimeManager<I, T> : LifetimeManager
    where T : I, new()
    where I : class
{
    static private T client = default(T);
   
    public override object GetValue()
    {
        if (client == null)
        {         
            client = new T(); // Create with object Builder?
        }
        
        CheckState();            

        return client;
    }
}

Works ok if the Proxy hast default constructor. But now i have the situation, that i need to pass a Context to the WCF Client Proxy constructor. I have passed a InjectionConstructor at RegisterType - but now my LifetimeManager doesnt work anymore. How can i use the ObjectBuilder to recreate something inside the LifetimeManager?

Thanks a lot

Best regards
Michael

 

 

Jan 4, 2010 at 5:09 PM

Ah sorry - misunderstood the meaning of GetValue and SetValue. Returning null for object reacreation in GetValue works ;-)

Sorry for spam

Best regards
Michael