Give parameters to Resolve function for constructor

Jan 14, 2009 at 8:56 AM

//  my configuration

<

type type="IDataRepository" mapTo="DataRepository">

 

<

lifetime type="singleton"/>

 

<

constructor>

 

<

param name="entity" genericParameterName="T">

 

<

dependency />

 

</

param>

 

</

constructor>

 

</

type>

/////////////////////////

 

class

DataRepository<T>  where T : IDataRepositoryType

 

 

 

{

DataRepository(T entity)

{

_entity=entity;

}

 

private T _entity;

 

 

}

How I can give parameter "suggestion" to the defined constructor

// calling

 

ISuggestion

suggestion= _businessLayerUnityContainer.Resolve<ISuggestion>();

 

 

IDataRepository<ISuggestion> repository = _businessLayerUnityContainer.Resolve<IDataRepository<ISuggestion>>();

 

 

 

 

Jan 14, 2009 at 11:58 AM
Hi,

Please see if this helps.
http://www.codeplex.com/unity/Thread/View.aspx?ThreadId=30104


Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com
Jan 16, 2009 at 1:21 AM
You could use InjectionConstructor when you register the type to the container as shown in the thread link above.  But if you specifically want it to pass in the call to the Resolve method, it's not supported in Unity.  I've read from other threads that there have been some discussions about that but no more beyond that for now.  

http://www.codeplex.com/unity/Thread/View.aspx?ThreadId=44217

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com