c# - XmlSerializer.Deserialize only specific classes -


this situation. need create new application based off existing object classes i'm not allowed change being used other projects. need use these object in conjunction new objects in new application. in new application, each action have request , response class, serialized/deserilized sent on sockets company. provide xsd company use form response , send xml. need deserialize xml newly created object, in case called getaccountdetailsmessageresponse.

[system.xml.serialization.xmlroot("getaccountdetailsmessageresponse", namespace = "http://test.com.au/")] public class getaccountdetailsmessageresponse  {              public mynewheader header     {          get;          set;      }       public accountsresponse response      {          get;          set;      }  }  //here  existing class structure need use, , cannot  // main class - containing collection of accounts public class accountsresponse : responseheader {     public accountsresponse()     {         accounts = new list<accountresponse>();     }      public list<accountresponse> accounts { get; set; } }  public class accountresponse : responseheader {     public int accountnumber { get; set; }      public string accounttype { get; set; } }  public class responseheader : messageheader {     public string reservedfield1 { get; set; }      public string reservedfield2 { get; set; }      public string textmessage { get; set; }      public string status { get; set; }      public transactstatus transactstatus { get; set; } }  public class messageheader {     public string function { get; set; }      public string messageid { get; set; }      public int customernumber { get; set; }      public string accesscode { get; set; }      public string sessionid { get; set; }      public int flag { get; set; } } 

as can see here, class existing class structure annoying classes derive header. actual entity, accountresponse, represents single account, derives responseheader. soy end responseheaders everywhere.

using xsd.exe tool microsoft, auto-generated xsd created need give other company.

my problem here is, original accountsresponse class derives responseheader, defined own header property in getaccountdetailsmessageresponse property header.

**so here question: how xsd tool, or write c# method serializes object xml, ignore responseheader in accountsresponse class. should serialize in accountsresponse, , ignore derived responseheader.

in end, want xsd.exe tool, or custom c# method, generate xsd, provide xml looks this:

enter image description here

override responseheader/messageheader properties in accountsresponse , attach xmlignore attribute them or alternative attach xmlschemaprovider attribute, defining function delivering schema, class.


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -