Xml序列化无法正常工作

时间:2013-12-13 18:05:07

标签: c#-4.0 serialization xml-serialization

以下是我的目标的一部分:

var fatura = new WIFatura()
            {
                aliciEtiket = "hglhg ",
                aliciVKN = "111111",
                binaAdi = "",
                binaNo = "",
                cadde = "CEVIZLIDERE CAD",
                duzeltmeAciklama = "",
                eMail = "",
                faks = "",
                faturaNo = "647738",
                faturaTarihi = "2013-09-26",
                faturaTipi = "SATIS",
                faturaninEvrenselTekilNumarasi = "",
                genelMuafiyetSebebiAciklamasi = "",
                gonderenEtiket = "",
                gonderenVKN = "",
                hesaplananKdv = 5277.06,
                hesaplananKdvSpecified = false,
                irsaliyeNo = "D251940+1/5110033534",
                irsaliyeTarihi = "2013-09-26",
                kapiNo = "",
                kasaba = "",
                malHizmetToplam = 3053,

                malHizmetToplamSpecified = false,
                malzemeler = new WIMalzeme[]
                    {

这是我的序列化结果:

   <aliciEtiket>hglhg</aliciEtiket>
  <aliciVKN>111111</aliciVKN>
  <binaAdi />
  <binaNo />
  <cadde>CEVIZLIDERE CAD</cadde>
  <duzeltmeAciklama />
  <eMail />
  <faks />
  <faturaNo>647738</faturaNo>
  <faturaTarihi>2013-09-26</faturaTarihi>
  <faturaTipi>SATIS</faturaTipi>
  <faturaninEvrenselTekilNumarasi />
  <genelMuafiyetSebebiAciklamasi />
  <gonderenEtiket />
  <gonderenVKN />
  <hesaplananKdvSpecified>false</hesaplananKdvSpecified>
  <irsaliyeNo>D251940+1/5110033534</irsaliyeNo>
  <irsaliyeTarihi>2013-09-26</irsaliyeTarihi>
  <kapiNo />
  <kasaba />
  <malHizmetToplamSpecified>false</malHizmetToplamSpecified>
  <malzemeler>
    <birim>NIU</birim>

这是我的序列化代码:

XmlSerializer xsSubmit = new XmlSerializer(typeof(WIFatura));

 StringWriter sww = new StringWriter();
 XmlWriter writer = XmlWriter.Create(sww);
 xsSubmit.Serialize(writer, fatura);
 var xml = sww.ToString(); 

这是类定义和malHizmetToplam属性的一部分

 [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.18408")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://model.common.efatura.teknokent.oytek.com.tr/xsd")]
public partial class WIFatura : object, System.ComponentModel.INotifyPropertyChanged {

    private string aliciEtiketField;

    private string aliciVKNField;

    private string binaAdiField;

    private string binaNoField;

    private string caddeField;

    private string duzeltmeAciklamaField;

    private string eMailField;

    private string faksField;

    private string faturaNoField;

    private string faturaTarihiField;

    private string faturaTipiField;

    private string faturaninEvrenselTekilNumarasiField;

    private string genelMuafiyetSebebiAciklamasiField;

    private string gonderenEtiketField;

    private string gonderenVKNField;

    private double hesaplananKdvField;

    private bool hesaplananKdvFieldSpecified;

    private string irsaliyeNoField;

    private string irsaliyeTarihiField;

    private string kapiNoField;

    private string kasabaField;

    private double malHizmetToplamField;



 /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute(IsNullable = false,Order = 21)]
        public double malHizmetToplam {
            get {
                return this.malHizmetToplamField;
            }
            set {
                this.malHizmetToplamField = value;
                this.RaisePropertyChanged("malHizmetToplam");
            }
        }
/// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(IsNullable = false, Order = 22)]
    public bool malHizmetToplamSpecified {
        get {
            return this.malHizmetToplamFieldSpecified;
        }
        set {
            this.malHizmetToplamFieldSpecified = value;
            this.RaisePropertyChanged("malHizmetToplamSpecified");
        }
    }

正如您所看到的,序列化部分中没有malHizmetToplam标记,但我将其填充到fatura对象中。我该怎么办?

0 个答案:

没有答案