Example #1
0
    public void ReadXml(XmlReader reader)
    {
        reader.ReadStartElement(); //wrapping element

        this.name = reader.ReadElementContentAsString();
        this.extension = reader.ReadElementContentAsString();

        string tempFileName = Path.GetTempFileName();
        this.streamFileName = tempFileName;
        using (FileStream fs = File.Create(tempFileName))
        {
            byte[] buffer = new byte[1000];
            int bytesRead;
            reader.ReadStartElement();
            do
            {
                bytesRead = reader.ReadContentAsBase64(buffer, 0, buffer.Length);
                fs.Write(buffer, 0, bytesRead);
            } while (bytesRead > 0);

            reader.ReadEndElement();
        }

        reader.ReadEndElement(); //wrapping element
    }
		 void IXmlSerializable.ReadXml(XmlReader r)
		{
			r.MoveToContent();
			r.ReadStartElement("Employee");
			
			 r.ReadStartElement("Name");
			 FirstName = r.ReadElementString("First", ns);
			 LastName = r.ReadElementString("Last", ns);
			r.ReadEndElement();
			r.MoveToContent();
			 ID = Int32.Parse(r.ReadElementString("ID", ns));
			 r.ReadEndElement();
			 
		}
Example #3
0
 public override object ReadObject(XmlReader reader)
 {
     ArrayOfLoanStateCompositeType ArrayOfLoanStateCompositeTypeField = null;
     if (IsParentStartElement(reader, false, true))
     {
         ArrayOfLoanStateCompositeTypeField = new ArrayOfLoanStateCompositeType();
         reader.Read();
         LoanStateCompositeTypeDataContractSerializer LoanStateCompositeTypeDCS = new LoanStateCompositeTypeDataContractSerializer("LoanStateCompositeType", "http://schemas.datacontract.org/2004/07/", "http://schemas.datacontract.org/2004/07/");
         System.Collections.ArrayList LoanStateCompositeType_List = new System.Collections.ArrayList();
         for (int i = 0; (i > -1); i = (i + 1))
         {
             if (!IsChildStartElement(reader, "LoanStateCompositeType", false, false))
             {
                 ArrayOfLoanStateCompositeTypeField.LoanStateCompositeType = new LoanStateCompositeType[LoanStateCompositeType_List.Count];
                 LoanStateCompositeType_List.CopyTo(ArrayOfLoanStateCompositeTypeField.LoanStateCompositeType);
                 break;
             }
             LoanStateCompositeType_List.Add(((LoanStateCompositeType)(LoanStateCompositeTypeDCS.ReadObject(reader))));
         }
         reader.ReadEndElement();
     }
     return ArrayOfLoanStateCompositeTypeField;
 }
Example #4
0
 public string ReadString(XmlReader reader)
 {
     reader.Read();
     string s = reader.ReadString();
     reader.ReadEndElement();
     return s;
 }
Example #5
0
        public override object ReadObject(XmlReader reader)
        {
            ArrayOfstring ArrayOfstringField = null;
            if (IsParentStartElement(reader, false, true))
            {
                ArrayOfstringField = new ArrayOfstring();
                reader.Read();

                System.Collections.ArrayList string_List = new System.Collections.ArrayList();
                for (int i = 0; (i > -1); i = (i + 1))
                {
                    if (!IsChildStartElement(reader, "string", false, false))
                    {
                        ArrayOfstringField.STRING = new string[string_List.Count];
                        string_List.CopyTo(ArrayOfstringField.STRING);
                        break;
                    }
                    string_List.Add(ReadString(reader));
                }
                reader.ReadEndElement();
            }
            return ArrayOfstringField;
        }
Example #6
0
 public override object ReadObject(XmlReader reader)
 {
     UserCompositeType UserCompositeTypeField = null;
     if (IsParentStartElement(reader, false, true))
     {
         UserCompositeTypeField = new UserCompositeType();
         reader.Read();
         if (IsChildStartElement(reader, "Delay", false, false))
         {
             reader.Read();
             UserCompositeTypeField.Delay = XmlConvert.ToBoolean(reader.ReadString());
             reader.ReadEndElement();
         }
         if (IsChildStartElement(reader, "FirstName", true, false))
         {
             reader.Read();
             UserCompositeTypeField.FirstName = reader.ReadString();
             reader.ReadEndElement();
         }
         if (IsChildStartElement(reader, "ID", false, false))
         {
             reader.Read();
             UserCompositeTypeField.ID = XmlConvert.ToInt32(reader.ReadString());
             reader.ReadEndElement();
         }
         if (IsChildStartElement(reader, "LastName", true, false))
         {
             reader.Read();
             UserCompositeTypeField.LastName = reader.ReadString();
             reader.ReadEndElement();
         }
         if (IsChildStartElement(reader, "MaxLoansReached", false, false))
         {
             reader.Read();
             UserCompositeTypeField.MaxLoansReached = XmlConvert.ToBoolean(reader.ReadString());
             reader.ReadEndElement();
         }
         reader.ReadEndElement();
     }
     return UserCompositeTypeField;
 }
Example #7
0
        public override object ReadObject(XmlReader reader)
        {
            LoanStateCompositeType LoanStateCompositeTypeField = null;
            if (IsParentStartElement(reader, false, true))
            {
                LoanStateCompositeTypeField = new LoanStateCompositeType();
                reader.Read();
                if (IsChildStartElement(reader, "BookID", false, false))
                {
                    reader.Read();
                    LoanStateCompositeTypeField.BookID = XmlConvert.ToInt32(reader.ReadString());
                    reader.ReadEndElement();
                }
                if (IsChildStartElement(reader, "Description", true, false))
                {
                    reader.Read();
                    LoanStateCompositeTypeField.Description = reader.ReadString();
                    reader.ReadEndElement();
                }
                if (IsChildStartElement(reader, "ISBN", true, false))
                {
                    reader.Read();
                    LoanStateCompositeTypeField.ISBN = reader.ReadString();
                    reader.ReadEndElement();
                }
                if (IsChildStartElement(reader, "Language", true, false))
                {
                    reader.Read();
                    LoanStateCompositeTypeField.Language = reader.ReadString();
                    reader.ReadEndElement();
                }
                if (IsChildStartElement(reader, "LoanExpirationDate", false, false))
                {
                    reader.Read();
                    // LoanStateCompositeTypeField.LoanExpirationDate = XmlConvert.ToDateTime(reader.ReadString());
                    LoanStateCompositeTypeField.LoanExpirationDate = LibraryTerminal.Utils.Parse(reader.ReadString());

                    reader.ReadEndElement();
                }
                if (IsChildStartElement(reader, "LoanStartDate", false, false))
                {
                    reader.Read();
                    //  LoanStateCompositeTypeField.LoanStartDate = XmlConvert.ToDateTime(reader.ReadString());
                    LoanStateCompositeTypeField.LoanStartDate = LibraryTerminal.Utils.Parse(reader.ReadString());
                    reader.ReadEndElement();
                }
                if (IsChildStartElement(reader, "PublicationDate", false, false))
                {
                    reader.Read();
                   // LoanStateCompositeTypeField.PublicationDate = XmlConvert.ToDateTime(reader.ReadString());
                    LoanStateCompositeTypeField.PublicationDate = LibraryTerminal.Utils.Parse(reader.ReadString());
                    reader.ReadEndElement();
                }
                if (IsChildStartElement(reader, "Publisher", true, false))
                {
                    reader.Read();
                    LoanStateCompositeTypeField.Publisher = reader.ReadString();
                    reader.ReadEndElement();
                }
                if (IsChildStartElement(reader, "Title", true, false))
                {
                    reader.Read();
                    LoanStateCompositeTypeField.Title = reader.ReadString();
                    reader.ReadEndElement();
                }
                reader.ReadEndElement();
            }
            return LoanStateCompositeTypeField;
        }
Example #8
0
 public override object ReadObject(XmlReader reader)
 {
     LoanCompositeType LoanCompositeTypeField = null;
     if (IsParentStartElement(reader, false, true))
     {
         LoanCompositeTypeField = new LoanCompositeType();
         reader.Read();
         if (IsChildStartElement(reader, "BookID", false, false))
         {
             reader.Read();
             LoanCompositeTypeField.BookID = XmlConvert.ToInt32(reader.ReadString());
             reader.ReadEndElement();
         }
         if (IsChildStartElement(reader, "DeliveryDate", true, false))
         {
             reader.Read();
             //LoanCompositeTypeField.DeliveryDate = XmlConvert.ToDateTime(reader.ReadString());
             LoanCompositeTypeField.DeliveryDate = LibraryTerminal.Utils.Parse(reader.ReadString());
             reader.ReadEndElement();
         }
         if (IsChildStartElement(reader, "ExpirationDate", false, false))
         {
             reader.Read();
             //LoanCompositeTypeField.ExpirationDate = XmlConvert.ToDateTime(reader.ReadString());
             LoanCompositeTypeField.ExpirationDate = LibraryTerminal.Utils.Parse(reader.ReadString());
             reader.ReadEndElement();
         }
         if (IsChildStartElement(reader, "StartDate", false, false))
         {
             reader.Read();
             //LoanCompositeTypeField.StartDate = XmlConvert.ToDateTime(reader.ReadString());
             LoanCompositeTypeField.StartDate = LibraryTerminal.Utils.Parse(reader.ReadString());
             reader.ReadEndElement();
         }
         if (IsChildStartElement(reader, "UserID", false, false))
         {
             reader.Read();
             LoanCompositeTypeField.UserID = XmlConvert.ToInt32(reader.ReadString());
             reader.ReadEndElement();
         }
         reader.ReadEndElement();
     }
     return LoanCompositeTypeField;
 }
Example #9
0
 public override object ReadObject(XmlReader reader)
 {
     BookCompositeType BookCompositeTypeField = null;
     if (IsParentStartElement(reader, false, true))
     {
         BookCompositeTypeField = new BookCompositeType();
         reader.Read();
         schemas.microsoft.com.Serialization.Arrays.ArrayOfstringDataContractSerializer AuthorsDCS = new schemas.microsoft.com.Serialization.Arrays.ArrayOfstringDataContractSerializer("Authors", "http://schemas.datacontract.org/2004/07/", "http://schemas.microsoft.com/2003/10/Serialization/Arrays");
         AuthorsDCS.BodyParts = this.BodyParts;
         BookCompositeTypeField.Authors = ((schemas.microsoft.com.Serialization.Arrays.ArrayOfstring)(AuthorsDCS.ReadObject(reader)));
         if (IsChildStartElement(reader, "Description", true, false))
         {
             reader.Read();
             BookCompositeTypeField.Description = reader.ReadString();
             reader.ReadEndElement();
         }
         if (IsChildStartElement(reader, "ID", false, false))
         {
             reader.Read();
             BookCompositeTypeField.ID = XmlConvert.ToInt32(reader.ReadString());
             reader.ReadEndElement();
         }
         if (IsChildStartElement(reader, "ISBN", true, false))
         {
             reader.Read();
             BookCompositeTypeField.ISBN = reader.ReadString();
             reader.ReadEndElement();
         }
         if (IsChildStartElement(reader, "Language", true, false))
         {
             reader.Read();
             BookCompositeTypeField.Language = reader.ReadString();
             reader.ReadEndElement();
         }
         if (IsChildStartElement(reader, "PublicationDate", false, false))
         {
             reader.Read();
             //BookCompositeTypeField.PublicationDate = XmlConvert.ToDateTime(reader.ReadString());
             BookCompositeTypeField.PublicationDate = LibraryTerminal.Utils.Parse(reader.ReadString());
             reader.ReadEndElement();
         }
         if (IsChildStartElement(reader, "Publisher", true, false))
         {
             reader.Read();
             BookCompositeTypeField.Publisher = reader.ReadString();
             reader.ReadEndElement();
         }
         schemas.microsoft.com.Serialization.Arrays.ArrayOfstringDataContractSerializer SubjectsDCS = new schemas.microsoft.com.Serialization.Arrays.ArrayOfstringDataContractSerializer("Subjects", "http://schemas.datacontract.org/2004/07/", "http://schemas.microsoft.com/2003/10/Serialization/Arrays");
         SubjectsDCS.BodyParts = this.BodyParts;
         BookCompositeTypeField.Subjects = ((schemas.microsoft.com.Serialization.Arrays.ArrayOfstring)(SubjectsDCS.ReadObject(reader)));
         if (IsChildStartElement(reader, "Title", true, false))
         {
             reader.Read();
             BookCompositeTypeField.Title = reader.ReadString();
             reader.ReadEndElement();
         }
         reader.ReadEndElement();
     }
     return BookCompositeTypeField;
 }
        public static void ReadObject(XmlReader reader, object obj, PropertyConversionHandler handler = null)
        {
            if (obj == null)
                throw new ArgumentNullException("obj");

            reader.MoveToContent();

            if (obj is IXmlSerializable)
            {
                ((IXmlSerializable)obj).ReadXml(reader);
            }
            else
            {
                object oVal = null;
                string oName = GetAttributeValue(obj.GetType(), typeof(XmlRootAttribute), "ElementName", true, ref oVal) ? oVal.ToString() : obj.GetType().Name;
                if (reader.LocalName != oName)
                    throw new XmlException("XML element name does not match object.");

                if (!reader.IsEmptyElement)
                {
                    reader.ReadStartElement();
                    reader.MoveToContent();
                    ReadObjectProperties(reader, obj, handler);
                    reader.ReadEndElement();
                }
                else
                    reader.Skip();
            }
        }
Example #11
0
	/// <summary>
	/// Loads the status.
	/// </summary>
	/// <param name="reader">Reader.</param>
	protected override void LoadStatus (XmlReader reader)
	{
		base.LoadStatus (reader);
		reader.ReadToNextSibling ("Mana");
		mana.value = reader.ReadElementContentAsFloat ();
		Debug.Log("Found Exp field: " + reader.ReadToNextSibling ("Exp"));
		Debug.Log("Found level field: " + reader.ReadToNextSibling ("Level"));

		GetComponent<Inventory> ().LoadInventory (reader);
		reader.ReadEndElement ();
	}
Example #12
0
	/// <summary>
	/// Load an instance using the specified reader.
	/// </summary>
	/// <param name="reader">Reader.</param>
	public override void Load (XmlReader reader)
	{
		reader.ReadToFollowing ("Wizard");
		base.Load (reader);
		reader.ReadEndElement ();
	}
Example #13
0
	protected void LoadPosition(XmlReader reader) {
		reader.ReadToFollowing ("Position");
		reader.ReadToDescendant ("x");
		Vector3 loadedPosition = new Vector3 ();
		loadedPosition.x = reader.ReadElementContentAsFloat ();
		reader.ReadToNextSibling ("y");
		loadedPosition.y = reader.ReadElementContentAsFloat ();
		reader.ReadToNextSibling ("z");
		loadedPosition.z = reader.ReadElementContentAsFloat ();
		transform.position = loadedPosition;
		reader.ReadEndElement ();
	}