I've got two objects which (Domain and Data) which in this case have the same property (let's presume Name). I've got an Action which I Would like to cast to Action;
public class DomItem {
public string Name {get;set;}
}
public class DataItem {
public string Name {get;set;}
}
public class Program {
public Program() {
Action<DomItem> domAction = New Action<DomItem>(x=>x.Name = "Test");
// Something Casted To Action<DataItem>(x=>x.Name = "Test");
}
}
Ofcourse this is just a basic example. It's by design that I can NOT use a common Interface. I do not care about the DataItem might not be having the same property.
I've been looking into Expressions and several other solutions but I just can't figure out how to create the Cast (or get the "x=>x.Name =..." part from the method).
Any help would be really appreciated!
Aucun commentaire:
Enregistrer un commentaire