jeudi 10 mars 2016

set property value with its implemented type

I want to inject a type to a property

[ServiceDependency]
public IPostBusiness postBiz { get; set; }

then somewhere I get the property and resolve as below with castle windsor

var instance = ContainerManager.Container.Resolve(prop.PropertyType);

then to set the postBiz property

prop.SetValue(this.GetType(), instance);

that I get this error "Object does not match target type." which instance type is PostBusiness but property is IPostBusiness.

Is there any way to do that ? or I do something wrong !!





Aucun commentaire:

Enregistrer un commentaire