I'm creating a set of validation-type classes where a context object is passed into the parent. The parent will have a list of validators and each child validator may itself contain a list of validators. The plan is to have the context object pass through all the nested validators. Any errors detected by a respective validator will then place a message into an error "bucket" that is part of the context. Each child is completely ignorant of where it sits in the hierarchy, so it only knows the criteria by which itself is validating against. However, since the respective validator is responsible for placing an error message into bucket the message needs to have some kind of description of where the error came from in the hierarchy.
The easiest way of doing this, I feel, is to somehow obtain some sort of fully qualified "path" to the object -- much like how .GetType().FullName reports the namespace. However, I can't find any reflection mechanism to determine this.
Is this possible or is my approach faulty?
Aucun commentaire:
Enregistrer un commentaire