c# - Check for any of the property is null -


i deserializing xml class model , want check if there xml nodes not deserialized correctly.

my class looks this:

class {     public a1 pop1;     public a2 prop2;      // n number of classes } class  a1 {     public string item1{get;set;}     public string item2{get;set;}     public string item3{get;set;}      // n number of classes }  class a2 {     public string item1{get;set;}     public string item2{get;set;}     public string item3{get;set;}      // n number of classes } 

is there way check if of objects a1, a2, etc null , of properties inside object null or empty? if true deserialization failed.

you use reflection walk on classes , values.

what in case though make custom method called validate in interface ivalidateable. let every class implement interface , write method validation inside. makes easier deviate 'all properties can't null' rule have now.


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -