.net - c# getting a configurable equatable method -


i've got simple factory that's built in c# instantiates , configures validators built in asp.net , javascript. want way test if i'm accidently trying set validator twice (for example, having 2 requiredvaluevalidators not great idea , cause ui/ux problems) on same control, wish make sure validators use same same building mechanisms, in different way, preserved (such 2 regularexpressionvalidators use different re, not 2 use same re.)

i've tried few different possible techniques i'll detail these answers below- in essence need technique pass description on how compare 2 validators of same base type discern if equal( n.b. 'equal' not 'identical', have different ids (etc) still same job.) that's interpretable @ runtime , accessible other areas of c# .dll run check.

my answers community wiki intent errors/pitfalls fell edited out/corrected/discussed community, rather being merely downvoted being incorrect, others' won't suffer same fate.

one attempt i've had set predicate attribute of method in factory builds validator. accessed using reflection somewhere else , used compare 2 potential validators.

a major flaw in cannot set predicates (or delegates matter) attributes.

a possible work-around give individual property (containing predicate delegate or iequatable<> implementation , retrieve - there lot of different things consider when comparing validators (what type, configurations, rely on other controls etc....) unless can create base class or interface can deal different types of iequatable<validatortype> impossible...


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -