I have a Method that accepts a generic parameter:
I have two Validator classes (Incoming and Outgoing). Each contain an ERRORS collection. Below is an example of the OutgoingDefinitionCode:public void AddErrors<T>(T Validator) { }
It is defined as:
Error is a generic class that is a Translator of sorts that will hold a ErrorEnum and various other properties depending on the error type (i.e. Incoming/Outgoing)Code:public List<Error<OutgoingErrors>> Errors {get;set;}
What i want to do is create an instance of my Validator (either incoming or outgoing) and then pass it into my "AddErrors" method defined above.
On that validator, i want to grab the "ERRORS" property and get the value of that so that I can do something specific with it. The problem I'm having is validator.Errors doesn't compile since validator is defined as Generic.
So, I'm trying to use Reflection to grab the property info.
Once I grab the Errors Proprety Info, I'm trying to do a GetValue() on "errors" but I'm just haven't been able to obtain that property objectCode:var errors = validator.GetType().GetProperty("Errors");
Can someone give me some pointers on how to obtain that?


Reply With Quote

Bookmarks