Exemplo n.º 1
0
        public override object ReadObject(XmlReader reader)
        {
            NestedClass NestedClassField = null;

            if (IsParentStartElement(reader, false, true))
            {
                NestedClassField = new NestedClass();
                reader.Read();
                MtomDataDataContractSerializer MTDataDCS = new MtomDataDataContractSerializer("MTData", "http://schemas.datacontract.org/2004/07/WcfMtomService", "http://schemas.datacontract.org/2004/07/WcfMtomService");
                MTDataDCS.BodyParts     = this.BodyParts;
                NestedClassField.MTData = ((MtomData)(MTDataDCS.ReadObject(reader)));
                if (IsChildStartElement(reader, "MyData", true, false))
                {
                    reader.Read();
                    if (IsAttribute(reader, "href"))
                    {
                        string contentID;
                        contentID = reader.Value;
                        reader.MoveToElement();
                        reader.ReadStartElement("Include", "http://www.w3.org/2004/08/xop/include");
                        reader.ReadEndElement();
                        NestedClassField.MyData = GetBodyPartContent(contentID, BodyParts);
                    }
                    else
                    {
                        NestedClassField.MyData = ConvertBase64.FromBase64String(reader.ReadString());
                        reader.ReadEndElement();
                    }
                }
                reader.ReadEndElement();
            }
            return(NestedClassField);
        }
Exemplo n.º 2
0
        public override void WriteObject(XmlWriter writer, object graph)
        {
            NestedClass NestedClassField = ((NestedClass)(graph));

            if (WriteParentElement(writer, true, true, graph))
            {
                MtomDataDataContractSerializer MTDataDCS = new MtomDataDataContractSerializer("MTData", "http://schemas.datacontract.org/2004/07/WcfMtomService", "http://schemas.datacontract.org/2004/07/WcfMtomService");
                MTDataDCS.BodyParts = this.BodyParts;
                MTDataDCS.WriteObject(writer, NestedClassField.MTData);
                if (WriteChildElement(writer, "MyData", true, false, NestedClassField.MyData))
                {
                    BodyParts.Add(CreateNewBodyPart(NestedClassField.MyData, "<2@body>"));
                    writer.WriteStartElement("xop", "Include", "http://www.w3.org/2004/08/xop/include");
                    writer.WriteAttributeString(null, "href", null, "cid:2@body");
                    writer.WriteEndElement();
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();
            }
            return;
        }
Exemplo n.º 3
0
 public override object ReadObject(XmlReader reader)
 {
     NestedClass NestedClassField = null;
     if (IsParentStartElement(reader, false, true))
     {
         NestedClassField = new NestedClass();
         reader.Read();
         MtomDataDataContractSerializer MTDataDCS = new MtomDataDataContractSerializer("MTData", "http://schemas.datacontract.org/2004/07/WcfMtomService", "http://schemas.datacontract.org/2004/07/WcfMtomService");
         MTDataDCS.BodyParts = this.BodyParts;
         NestedClassField.MTData = ((MtomData)(MTDataDCS.ReadObject(reader)));
         if (IsChildStartElement(reader, "MyData", true, false))
         {
             reader.Read();
             if (IsAttribute(reader, "href"))
             {
                 string contentID;
                 contentID = reader.Value;
                 reader.MoveToElement();
                 reader.ReadStartElement("Include", "http://www.w3.org/2004/08/xop/include");
                 reader.ReadEndElement();
                 NestedClassField.MyData = GetBodyPartContent(contentID, BodyParts);
             }
             else
             {
                 NestedClassField.MyData = Convert.FromBase64String(reader.ReadString());
                 reader.ReadEndElement();
             }
         }
         reader.ReadEndElement();
     }
     return NestedClassField;
 }