c# - will RegularExpressionAttribute and other validators on Automatic properties work? -


i'm using xsd2code generating classes schema. how ever i'm suspicious auto properties can validate values or not?

because if enable automaticproperties in xsd2code here member regex restriction.

[system.xml.serialization.xmlattributeattribute(datatype="token", attributename="color")] [system.componentmodel.dataannotations.regularexpressionattribute("#[\\da-f]{6}([\\da-f][\\da-f])?")] public string color { get; set; } 

and when automaticproperties disabled

[system.xml.serialization.xmlattributeattribute(datatype="token", attributename="color")] [system.componentmodel.dataannotations.regularexpressionattribute("#[\\da-f]{6}([\\da-f][\\da-f])?")] public string color {         {         return this._color;     }     set     {         system.componentmodel.dataannotations.validationcontext validatorpropcontext = new system.componentmodel.dataannotations.validationcontext(this, null, null);         validatorpropcontext.membername = "color";         validator.validateproperty(value, validatorpropcontext);         this._color = value;     } } 

it seems these not equivalent. think bug in xsd2code or maybe i'm misunderstanding something. whats purpose of second generated code?

i thought regularexpressionattribute validate automatic properties too.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -