Reputation: 6060
I'm wanting to roll a couple of different customer [Compare()]
attributes to use in an MVC4 application. The part I'm having issues with is the public string OtherPropertyDisplayName { get; internal set; }
that Microsoft implements. How are they getting the information to populate this field? I'm assuming it's through reflection...and my reflection foo is weak so does anyone have pointers for this?
I have made my own custom attributes before, but never one that needed knowledge of the "other" field.
Upvotes: 0
Views: 2207
Reputation: 4732
Here is how you do it: Property Matching With Data Annotations
Essentially, they define Match
attribute rather than Compare
, but this is only a different word for the same thing, Just use that example to see what they do and do the same in your case. It isn't hard at all.
Good luck & please let me know if that was of help.
Upvotes: 1