asp.net - Convert true and false to 1 and 0 in XmlElement in C# -


i working soap web service third party. have generated objects using xsd.exe tool. problem need send xmlelement i'm serialising. service throwing error because expects boolean values represented 1 , 0 instead of true , false.

i know can use custom serializers such this: ixmlserializable interface or this: making xmlserializer output alternate values simple types involve me changing code generated xsd.exe tool , difficult maintain every time there upgrade.

am missing or there way achieve i'm looking for?

you make object ignore bool value instead use different variable show it. example:

    [ignoredatamember, xmlignore]     public bool boolprop  { get; set; }      /// <summary>     ///     xml serialized boolprop      /// </summary>     [datamember(name = "boolprop"]     [xmlelement(elementname = "boolprop"]     public int formattedboolprop      {         {              return boolprop ? 1 : 0;         }         set { boolprop = value==1 }     } 

this make xml parser ignore real property, instead use formatted function.

you remove setter if not need parse it.


Comments

Popular posts from this blog

How to use SUM() in MySQL for calculated values -

loops - Spock: How to use test data with @Stepwise -