public void ReadXml(System.Xml.XmlReader reader)
        {
            reader.MoveToContent();
            Url = reader.GetAttribute("Url");
            ServiceName = reader.GetAttribute("ServiceName");

            Boolean isEmptyElement = reader.IsEmptyElement; // (1)
            
            reader.ReadStartElement();
            
            if (!isEmptyElement) // (1)
            {
                HostedServiceProperties = reader.ReadContentAs(typeof(AzureHostedServiceProperties), null) as AzureHostedServiceProperties;

                reader.ReadEndElement();
            }

            isEmptyElement = reader.IsEmptyElement; // (1)

            reader.ReadStartElement();

            if (!isEmptyElement) // (1)
            {
                Deployments = reader.ReadContentAs(typeof(List<AzureDeployment>), null) as List<AzureDeployment>;

                reader.ReadEndElement();
            }
        }
        public void ReadXml(System.Xml.XmlReader reader)
        {
            // Start to use the reader.
            reader.Read();
            // Read the first element ie root of this object
            reader.ReadStartElement("dictionary");

            // Read all elements
            while (reader.NodeType != XmlNodeType.EndElement) {
                // parsing the item
                reader.ReadStartElement("item");

                // PArsing the key and value
                string key = reader.ReadElementString("key");
                string value = reader.ReadElementString("value");

                // en reading the item.
                reader.ReadEndElement();
                reader.MoveToContent();

                // add the item
                this.Add(key, value);
            }

            // Extremely important to read the node to its end.
            // next call of the reader methods will crash if not called.
            reader.ReadEndElement();
        }
Beispiel #3
0
        /// <summary>
        /// Load object from XML-file
        /// </summary>
        /// <param name="reader">Load object from XML-stream</param>
        public override void ReadXml(System.Xml.XmlReader reader)
        {
            reader.MoveToContent();
            _width = Int32.Parse(reader.GetAttribute("width"));
            _height = Int32.Parse(reader.GetAttribute("height"));
            Boolean isEmptyElement = reader.IsEmptyElement;

            if (isEmptyElement)
                return;

            reader.ReadStartElement("WallTiles");
            reader.ReadStartElement("walls");
            while ((reader.NodeType != System.Xml.XmlNodeType.EndElement) && (reader.NodeType != System.Xml.XmlNodeType.None))
            {
                while (reader.NodeType == System.Xml.XmlNodeType.Whitespace) reader.Read();
                TileObject temp = new TileObject(_content, _width, _height);
                Backend.WallType _type = Backend.WallType.Normal;
                if (reader.GetAttribute("Type") != null)
                    _type = (Backend.WallType)Enum.Parse(typeof(Backend.WallType), reader.GetAttribute("Type").ToString());
                WallDir _id = (WallDir)Enum.Parse(typeof(WallDir), reader.GetAttribute("Direction").ToString());
                _textures[(int)_type * 100 + (int)_id].Clear();
                _textures[(int)_type * 100 + (int)_id].ReadXml(reader);
            }
            reader.ReadEndElement();

            while ((reader.NodeType != System.Xml.XmlNodeType.EndElement) && (reader.NodeType != System.Xml.XmlNodeType.None))
                reader.Read();
            reader.ReadEndElement();
        }
        public void ReadXml(System.Xml.XmlReader reader)
        {
            XmlSerializer keySerializer = Utils.GetXmlSerializer(typeof(string), null);
            XmlSerializer valueSerializer = Utils.GetXmlSerializer(typeof(string), null);
            string KeyValue;
            string value;


            bool wasEmpty = reader.IsEmptyElement;
            reader.Read();

            if (wasEmpty)
                return;
            while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
            {
                reader.ReadStartElement("item");
                reader.ReadStartElement("key");
                KeyValue = (string)keySerializer.Deserialize(reader);
                reader.ReadEndElement();
                reader.ReadStartElement("value");
                value = (string)valueSerializer.Deserialize(reader);
                reader.ReadEndElement();
                this.Add(KeyValue, value);
                reader.ReadEndElement();
                reader.MoveToContent();

            }
            reader.ReadEndElement();
        }
    public void ReadXml(System.Xml.XmlReader reader)
    {
      reader.ReadStartElement("ConnectionData");
      reader.MoveToContent();

      while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
      {
        switch (reader.LocalName)
        {
          case "Authentication":
            Authentication newAuth;
            if (Enum.TryParse<Authentication>(reader.ReadElementString(reader.LocalName), out newAuth))
              this.Authentication = newAuth;
            break;
          case "Color":
            this.Color = FromHex(reader.ReadElementString(reader.LocalName));
            break;
          case "ConnectionName":
            this.ConnectionName = reader.ReadElementString(reader.LocalName);
            break;
          case "Database":
            this.Database = reader.ReadElementString(reader.LocalName);
            break;
          case "Password":
            var encrypted = reader.ReadElementString(reader.LocalName);
            string password;
            var success = TryDecryptWindows(encrypted, out password)
              || TryDecryptStatic(encrypted, out password);
            this.Password = password;
            break;
          case "Url":
            this.Url = reader.ReadElementString(reader.LocalName);
            break;
          case "UserName":
            this.UserName = reader.ReadElementString(reader.LocalName);
            break;
          case "Type":
            ConnectionType newType;
            if (Enum.TryParse<ConnectionType>(reader.ReadElementString(reader.LocalName), out newType))
              this.Type = newType;
            break;
          case "Confirm":
            Boolean newConfirm;
            if (Boolean.TryParse(reader.ReadElementString(reader.LocalName), out newConfirm))
              this.Confirm = newConfirm;
            break;
          default:
            reader.ReadOuterXml();
            reader.MoveToContent();
            break;
        }
      }

      if (this.Color == System.Drawing.Color.Empty)
      {
        var idx = (int)(((long)this.ConnectionName.GetHashCode() - int.MinValue) % _tabColors.Length);
        this.Color = _tabColors[idx];
      }
      reader.ReadEndElement();
    }
Beispiel #6
0
    /// <summary>
    /// Generates an object from its XML representation.
    /// </summary>
    /// <param name="reader">The <see cref="XmlReader" /> stream from which the object is deserialized.</param>
    public void ReadXml(System.Xml.XmlReader reader)
    {
      // Read the opening tag of the encapsulating element
      reader.ReadStartElement();

      reader.ReadStartElement("body");
      this.Body = reader.ReadString();
      reader.ReadEndElement();

      reader.ReadStartElement("app-id");
      this.AppId = reader.ReadString();
      reader.ReadEndElement();

      // Read the end tag of the encapsulating element
      reader.ReadEndElement();
    }
		/// <summary>
		/// Generates an object from its XML representation.
		/// </summary>
		/// <param name="reader">The <see cref="T:System.Xml.XmlReader" /> stream from which the object is deserialized.</param>
		public void ReadXml(System.Xml.XmlReader reader)
		{
			reader.ReadStartElement();
			_xmlReading.BeginReading(reader);
			_wrappedObject = _xmlReading.GetValue("WrappedObject", null);
			_xmlReading.EndReading();
			reader.ReadEndElement();
		}
Beispiel #8
0
 public string UnpersistFileName(System.Xml.XmlReader reader)
 {
     // Assumes reader has started the read of element "FileNameValue"
     reader.ReadStartElement(ImportNetworkParamBag._FileName_ParamName);
     string valStr = reader.ReadString();
     reader.ReadEndElement();
     return valStr;
 }
Beispiel #9
0
 /// <summary>
 /// Assumes the reader is right at the start element with the name <paramref name="startElName"/>
 /// and reads in the value and end element and returns it as an integer.  If the element value is invalid then an
 /// exception is thrown there is no default.
 /// </summary>
 /// <param name="reader">System.Xml.XmlReader</param>
 /// <param name="startElName">The name of the element containing a string value to be read</param>
 /// <returns>string</returns>
 public string UnpersistString(System.Xml.XmlReader reader, string startElName)
 {
     // Assumes reader has started the read of element startElName
     reader.ReadStartElement(startElName);
     string valStr = reader.ReadString();
     reader.ReadEndElement();
     return valStr;
 }
Beispiel #10
0
 public bool UnpersistExportEdgeAttributes(System.Xml.XmlReader reader)
 {
     // Assumes reader has started the read of element "ExportEdgeAttributes"
     reader.ReadStartElement(ExportNetworkParamBag._ExportEdgeAttributes_ParamName);
     string valStr = reader.ReadString();
     reader.ReadEndElement();
     return XmlConvert.ToBoolean(valStr);
 }
Beispiel #11
0
 public bool UnpersistDisableDataConversions(System.Xml.XmlReader reader)
 {
     // Assumes reader has started the read of element "DisableDataConversions"
     reader.ReadStartElement(ImportNetworkParamBag._DisableDataConversions_ParamName);
     string valStr = reader.ReadString();
     reader.ReadEndElement();
     bool val = bool.Parse(valStr);
     return val;
 }
Beispiel #12
0
 public int UnpersistK(System.Xml.XmlReader reader)
 {
     // Assumes reader has started the read of element "K"
     reader.ReadStartElement("K");
     string valStr = reader.ReadString();
     reader.ReadEndElement();
     int val = int.Parse(valStr);
     return val;
 }
Beispiel #13
0
 public bool UnpersistAllowSelfLoops(System.Xml.XmlReader reader)
 {
     // Assumes reader has started the read of element "AllowSelfLoops"
     reader.ReadStartElement("AllowSelfLoops");
     string valStr = reader.ReadString();
     reader.ReadEndElement();
     bool val = bool.Parse(valStr);
     return val;
 }
Beispiel #14
0
        internal void ReadXml(System.Xml.XmlReader reader)
        {
            if (!reader.IsEmptyElement)
            {
                reader.ReadStartElement();
                reader.MoveToContent();

                this.ReadXmlBase(reader);

                reader.ReadEndElement();
                reader.MoveToContent();
            }
            else
            {
                reader.ReadStartElement();
                reader.MoveToContent();
            }
        }
 public void ReadXml(System.Xml.XmlReader reader)
 {
     reader.MoveToContent();
       var isEmptyElement = reader.IsEmptyElement;
       reader.ReadStartElement();
       if (!isEmptyElement) // (1)
       {
     ReadProperties(reader);
     reader.ReadEndElement();
       }
 }
Beispiel #16
0
        public override void ReadXml(System.Xml.XmlReader reader)
        {
            reader.ReadStartElement();

            while (reader.IsStartElement())
            {
                reader.Read();
            }

            reader.Read();
        }
Beispiel #17
0
 /// <summary>
 /// Deserializes the FilePattern in the XmlReader.<br/>
 /// ReadXml is part of the IXmlSerializable interface.
 /// </summary>
 public void ReadXml(System.Xml.XmlReader reader)
 {
     Pattern = reader.ReadString();
     if (!reader.IsEmptyElement)
     {
         reader.ReadEndElement();
     }
     else
     {
         reader.ReadStartElement();
     }
 }
Beispiel #18
0
        public void ReadXml(System.Xml.XmlReader reader)
        {
            while (!reader.IsStartElement("BlockCache") && !reader.EOF)
                reader.Read();

            if (reader.EOF)
                return;

            if (reader.IsEmptyElement && reader.Name == "BlockCache")
            {
                reader.ReadStartElement("BlockCache");
                BlockCache = new SerializableDictionary<IPAddr, BlockedIP>();
            }
            else
            {
                reader.ReadStartElement("BlockCache");
                BlockCache = (SerializableDictionary<IPAddr, BlockedIP>)new XmlSerializer(typeof(SerializableDictionary<IPAddr, BlockedIP>)).Deserialize(reader);
                reader.ReadEndElement();
            }

            while (!reader.IsStartElement("dos_threshold") && !reader.EOF)
                reader.Read();

            if (reader.EOF)
                return;

            reader.ReadStartElement("dos_threshold");
            dos_threshold = (int)new XmlSerializer(typeof(int)).Deserialize(reader);
            reader.ReadEndElement();

            while (!reader.IsStartElement("Save") && !reader.EOF)
                reader.Read();

            if (reader.EOF)
                return;

            reader.ReadStartElement("Save");
            Save = (bool)new XmlSerializer(typeof(bool)).Deserialize(reader);
            reader.ReadEndElement();
        }
Beispiel #19
0
        public void ReadXml(System.Xml.XmlReader reader)
        {
            reader.MoveToContent();

            Minimum = reader.GetAttribute("Minimum");
            Maximum = reader.GetAttribute("Maximum");

            var isEmptyElement = reader.IsEmptyElement;
            reader.ReadStartElement();
            if (!isEmptyElement) {
                reader.ReadEndElement();
            }
        }
    /// <summary>
    /// Generates an object from its XML representation.
    /// </summary>
    /// <param name="reader">The <see cref="XmlReader" /> stream from which the object is deserialized.</param>
    public void ReadXml(System.Xml.XmlReader reader)
    {
      // Read the opening tag of the encapsulating element
      reader.ReadStartElement();

      reader.ReadStartElement(CodeElementName);
      string codeString = reader.ReadString();
      switch (codeString)
      {
        case "anyone":
          this.Code = VisibilityCode.Anyone;
          break;
        case "connections-only":
          this.Code = VisibilityCode.ConnectionsOnly;
          break;
      }

      reader.ReadEndElement();

      // Read the end tag of the encapsulating element
      reader.ReadEndElement();
    }
Beispiel #21
0
 void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader)
 {
     reader.ReadStartElement();
     try
     {
         _color = Color.FromArgb(Convert.ToInt32(reader.ReadString()));
     }
     catch
     {
         _color = Color.Black;
     }
     reader.ReadEndElement();
 }
Beispiel #22
0
        public void ReadXml(System.Xml.XmlReader reader)
        {
            reader.MoveToContent();
            this.Name = reader.GetAttribute("Name");

            this.Won = bool.Parse(reader.GetAttribute("Won"));

            reader.ReadStartElement();
            // players
            int playerCount = int.Parse(reader.GetAttribute("Count"));
            for (int i = 0; i < playerCount; i++)
            {
                // opponent
                if (i == 0)
                {
                    reader.ReadStartElement();
                }
                PlayerRecord player = new PlayerRecord();
                this.Players.Add(player);

                player.Name = reader.GetAttribute("Name");
                player.Score = int.Parse(reader.GetAttribute("Score"));

                // deck
                reader.ReadStartElement();
                player.Deck = reader.ReadElementContentAsString();
                reader.ReadEndElement();
            }
            reader.ReadEndElement();

            // turns
            int turnCount = int.Parse(reader.GetAttribute("Count"));
            reader.ReadStartElement();
            for (int i = 0; i < turnCount; i++)
            {
                this.Log.Add(reader.ReadElementContentAsString());
            }
        }
Beispiel #23
0
        public virtual void ReadXml(System.Xml.XmlReader reader)
        {
            reader.MoveToContent();

            Id = reader.GetAttribute(ElementAttributes.Id.ToString());

            ItemId = reader.GetAttribute(ElementAttributes.ItemId.ToString());

            bool isDraggable;
            bool.TryParse(reader.GetAttribute(ElementAttributes.IsDraggable.ToString()), out isDraggable);
            IsDraggable = isDraggable;

            reader.ReadStartElement();
        }
Beispiel #24
0
 public void ReadXml(System.Xml.XmlReader reader)
 {
     m_stairMapping = new Dictionary<Guid, Point>();
     reader.ReadStartElement();
     int count = reader.ReadElementContentAsInt();
     for (int i = 0; i < count; ++i)
     {
         Guid g = new Guid(reader.ReadElementContentAsString());
         Point destination = new Point();
         destination = destination.ReadXml(reader);
         m_stairMapping[g] = destination;
     }
     reader.ReadEndElement();
 }
Beispiel #25
0
        public override void ReadXml(System.Xml.XmlReader reader)
        {
            reader.ReadStartElement();

            while (reader.IsStartElement())
            {
                if (reader.Name == "Name")
                {
                    Name = reader.ReadElementContentAsString();
                }
                else if (reader.Name == "Contents")
                {
                    reader.ReadStartElement();
                    ReadContents(reader);
                    reader.ReadEndElement();
                }
                else
                {
                    reader.Read();
                }
            }

            reader.Read();
        }
        /// <summary>
        /// Generates a serializable continuation token from its XML representation.
        /// </summary>
        /// <param name="reader">The <see cref="T:System.Xml.XmlReader"/> stream from which the continuation token is deserialized.</param>
        public void ReadXml(System.Xml.XmlReader reader)
        {
            CommonUtils.AssertNotNull("reader", reader);

            reader.MoveToContent();

            bool isEmptyElement = reader.IsEmptyElement;
            reader.ReadStartElement();

            if (!isEmptyElement)
            {
                while (reader.NodeType == XmlNodeType.Element && !reader.IsEmptyElement)
                {
                    if (!reader.IsEmptyElement)
                    {
                        switch (reader.Name)
                        {
                            case Constants.ContinuationConstants.VersionElement:
                                string version = reader.ReadElementContentAsString();

                                // For future versioning
                                break;
                            case Constants.ContinuationConstants.NextMarkerElement:
                                this.NextMarker = reader.ReadElementContentAsString();
                                break;
                            case Constants.ContinuationConstants.TypeElement:
                                string continuationType = reader.ReadElementContentAsString();
                                if ("Queue" != continuationType)
                                {
                                    throw new System.Xml.XmlException(SR.UnexpectedContinuationType);
                                }

                                break;
                            default:
                                throw new XmlException(string.Format(SR.UnexpectedElement, reader.Name));
                        }
                    }
                    else
                    {
                        throw new XmlException(string.Format(SR.UnexpectedEmptyElement, reader.Name));
                    }
                }

                reader.ReadEndElement();
            }
        }
Beispiel #27
0
 void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader)
 {
     reader.ReadStartElement();
     try
     {
         int a;
         if (Int32.TryParse(reader.ReadString(), System.Globalization.NumberStyles.AllowHexSpecifier, CultureInfo.InvariantCulture, out a))
             this.mColor = Color.FromArgb(a);
         else
             this.mColor = Color.Black;
     }
     catch
     {
         this.mColor = Color.Black;
     }
     reader.ReadEndElement();
 }
Beispiel #28
0
        public virtual void ReadXml(System.Xml.XmlReader reader)
        {
            reader.ReadStartElement();

            while (reader.IsStartElement())
            {
                if (reader.Name == "Name")
                {
                    Name = reader.ReadElementContentAsString();
                }
                else
                {
                    reader.Read();
                }
            }

            reader.ReadEndElement();
        }
Beispiel #29
0
 /// <summary>
 /// Reads the body of an object
 /// </summary>
 public override object ReadObject(System.Xml.XmlDictionaryReader reader, bool verifyObjectName)
 {
     if (reader.GetAttribute("nil") == "true") return null;
     reader.ReadStartElement(PROTO_ELEMENT);
     try
     {
         using (MemoryStream ms = new MemoryStream(reader.ReadContentAsBase64()))
         {
             using (ProtoReader protoReader = new ProtoReader(ms, model, null))
             {
                 return model.Deserialize(key, null, protoReader);
             }
         }
     }
     finally
     {
         reader.ReadEndElement();
     }
 }
 protected override void ReadProperties(System.Xml.XmlReader reader)
 {
   base.ReadProperties(reader);
   reader.MoveToContent();
   var isEmptyElement = reader.IsEmptyElement;
   reader.ReadStartElement("Paths");
   if (!isEmptyElement)
   {
     reader.MoveToContent();
     var paths = new List<string>();
     while (reader.LocalName == "Path")
     {
       paths.Add(reader.ReadElementString("Path"));
       reader.MoveToContent();
     }
     reader.ReadEndElement();
     _paths = paths;
   }
 }