ReadEndElement() public method

public ReadEndElement ( ) : void
return void
 public void ReadXml(XmlReader reader)
 {
     if (reader.IsEmptyElement) return;
     reader.ReadStartElement("CommandCollection");
     reader.ReadStartElement("Commands");
     while(reader.NodeType != XmlNodeType.EndElement)
     {
         var c = new Command();
         switch(reader.Name)
         {
             case "AttackCommand":
                 _mutableSerializer = new XmlSerializer(typeof(AttackCommand));
                 c = (AttackCommand)_mutableSerializer.Deserialize(reader);
                 Commands.Add(c);
                 break;
             case "TimedCommand":
                 _mutableSerializer = new XmlSerializer(typeof(TimedCommand));
                 c = (TimedCommand)_mutableSerializer.Deserialize(reader);
                 Commands.Add(c);
                 break;
         }
     }
     reader.ReadEndElement();
     reader.ReadEndElement();
 }
    public void ReadXml(System.Xml.XmlReader reader)
    {
        XmlSerializer keySerializer   = new XmlSerializer(typeof(TKey));
        XmlSerializer valueSerializer = new XmlSerializer(typeof(TValue));
        bool          wasEmpty        = reader.IsEmptyElement;

        reader.Read();
        if (wasEmpty)
        {
            return;
        }
        while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
        {
            reader.ReadStartElement("item");
            reader.ReadStartElement("key");
            TKey key = (TKey)keySerializer.Deserialize(reader);
            reader.ReadEndElement();
            reader.ReadStartElement("value");
            TValue value = (TValue)valueSerializer.Deserialize(reader);
            reader.ReadEndElement();
            this.Add(key, value);
            reader.ReadEndElement();
            reader.MoveToContent();
        }
        reader.ReadEndElement();
    }
 public override object ReadObject(XmlReader reader)
 {
     OneWayAttachmentRequest OneWayAttachmentRequestField = null;
     if (IsParentStartElement(reader, false, true))
     {
         OneWayAttachmentRequestField = new OneWayAttachmentRequest();
         OneWayAttachmentRequestField.AnyAttr = ReadAnyAttribute(reader);
         reader.Read();
         if (IsChildStartElement(reader, "Param", true, true))
         {
             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();
                 OneWayAttachmentRequestField.Param = GetBodyPartContent(contentID, BodyParts);
             }
             else
             {
                 OneWayAttachmentRequestField.Param = Convert.FromBase64String(reader.ReadString());
                 reader.ReadEndElement();
             }
         }
         OneWayAttachmentRequestField.Any = ReadAnyElement(reader, false);
         reader.ReadEndElement();
     }
     return OneWayAttachmentRequestField;
 }
        public void ReadXml(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
                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 #5
0
        public bool Read(XmlReader reader)
        {
            if(reader.IsStartElement() && reader.Name == "Fixture") {
                Fixture fixture = new Fixture();

                //...Any attributes go here...
                fixture.AllowFrameSkip = bool.Parse(reader.GetAttribute("allowFrameSkip"));
                fixture.Name = reader.GetAttribute("name");
                // This needs to hold off until after channels are loaded.
                string fixtureDefinitionName = reader.GetAttribute("fixtureDefinitionName");

                if(reader.ElementsExistWithin("Fixture")) { // Entity element
                    // Channels
                    if(reader.ElementsExistWithin("Channels")) { // Container element for child entity
                        ChannelReader<OutputChannel> channelReader = new ChannelReader<OutputChannel>();
                        while(channelReader.Read(reader)) {
                            fixture.InsertChannel(channelReader.Channel);
                        }
                        reader.ReadEndElement(); // Channels
                    }

                    // With channels loaded, the fixture template reference can be set.
                    fixture.FixtureDefinitionName = fixtureDefinitionName;

                    reader.ReadEndElement(); // Fixture

                    this.Fixture = fixture;
                }
                return true;
            }
            return false;
        }
		public override void ReadXml(XmlReader reader)
		{
			reader.MoveToContent();
			if (reader.AttributeCount == 0)
				throw new MissingXmlAttributeException(@"Missing XML attribute ""value"".");
			Name = reader["name"];

			if (reader.IsEmptyElement)
			{
				reader.ReadEndElement();
				return;
			}


			if (reader.ReadToDescendant(ChildXmlTag))
			{
				while (reader.MoveToContent() == XmlNodeType.Element && reader.LocalName == ChildXmlTag)
				{
					reader.ReadStartElement();
					reader.MoveToContent();

					IilParameter p = IilParameter.fromString(reader.LocalName);
					p.ReadXml(reader);
					Parameters.Add(p);
					reader.ReadEndElement();
				}
			}
			
            
			reader.ReadEndElement();
			//reader.Read();
		}
 public override object ReadObject(XmlReader reader)
 {
     SimpleEventRequest SimpleEventRequestField = null;
     if (IsParentStartElement(reader, false, true))
     {
         SimpleEventRequestField = new SimpleEventRequest();
         SimpleEventRequestField.AnyAttr = ReadAnyAttribute(reader);
         reader.Read();
         if (IsChildStartElement(reader, "Param", true, true))
         {
             reader.Read();
             string[] Param_List = reader.ReadString().Split();
             if ((this._CompressByteArrays 
                         || ((Param_List.Length == 1) 
                         && (Param_List[0].Length > 2))))
             {
                 SimpleEventRequestField.Param = Convert.FromBase64String(Param_List[0]);
             }
             else
             {
                 SimpleEventRequestField.Param = new byte[Param_List.Length];
                 for (int i = 0; (i < Param_List.Length); i = (i + 1))
                 {
                     SimpleEventRequestField.Param[i] = XmlConvert.ToByte(Param_List[i]);
                 }
             }
             reader.ReadEndElement();
         }
         SimpleEventRequestField.Any = ReadAnyElement(reader, false);
         reader.ReadEndElement();
     }
     return SimpleEventRequestField;
 }
Beispiel #8
0
        public bool FromXml(XmlReader reader)
        {
            if (reader.Name != "Node")
            {
                return false;
            }

            reader.ReadStartElement();

            Rounds = new List<Round>();
            if (reader.Name == "Rounds")
            {
                reader.ReadStartElement();

                Round round;
                while (reader.Name == "Round")
                {
                    round = new Round();
                    if (!round.FromXml(reader))
                    {
                        return false;
                    }
                    Rounds.Add(round);
                }

                if (reader.Name == "Rounds" && reader.NodeType == XmlNodeType.EndElement)
                {
                    reader.ReadEndElement();
                }
            }

            Items = new List<Item>();
            if (reader.Name == "Items")
            {
                reader.ReadStartElement();

                Item item;
                while (reader.Name == "Item")
                {
                    item = new Item();
                    if (!item.FromXml(reader))
                    {
                        return false;
                    }
                    Items.Add(item);
                }

                if (reader.Name == "Items" && reader.NodeType == XmlNodeType.EndElement)
                {
                    reader.ReadEndElement();
                }
            }

            if (reader.Name == "Node" && reader.NodeType == XmlNodeType.EndElement)
            {
                reader.ReadEndElement();
            }
            return true;
        }
 public void ReadXml(XmlReader reader)
 {
     reader.ReadStartElement(typeof(infNFeSupl).Name);
     reader.ReadStartElement("qrCode");
     qrCode = reader.ReadString();
     reader.ReadEndElement();
     reader.ReadEndElement();
 }
Beispiel #10
0
 public override void ReadXml(XmlReader reader)
 {
     reader.ReadStartElement();
     reader.ReadStartElement("X");
     var x = reader.ReadContentAsDouble();
     reader.ReadEndElement();
     reader.ReadStartElement("Y");
     var y = reader.ReadContentAsDouble();
     reader.ReadEndElement();
     Value = new Point(x, y);
     reader.ReadEndElement();
 }
    public void ReadXml(System.Xml.XmlReader reader)
    {
        XmlSerializer keySerializer   = new XmlSerializer(typeof(TKey));
        XmlSerializer valueSerializer = new XmlSerializer(typeof(TValue));

        bool wasEmpty = reader.IsEmptyElement;


        if (wasEmpty)
        {
            return;
        }

        string line = "";

        if ((line = reader.GetAttribute("ItemAlias")) != null)
        {
            itemAlias = line;
        }
        if ((line = reader.GetAttribute("KeyAlias")) != null)
        {
            keyAlias = line;
        }
        if ((line = reader.GetAttribute("ValueAlias")) != null)
        {
            valueAlias = line;
        }

        reader.Read();


        while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
        {
            reader.ReadStartElement(itemAlias);

            reader.ReadStartElement(keyAlias);
            TKey key = (TKey)keySerializer.Deserialize(reader);
            reader.ReadEndElement();

            reader.ReadStartElement(valueAlias);
            TValue value = (TValue)valueSerializer.Deserialize(reader);
            reader.ReadEndElement();

            this.Add(key, value);

            reader.ReadEndElement();
            reader.MoveToContent();
        }

        reader.ReadEndElement();
    }
        /// <summary>
        ///   Reads the next blueprint from the specified reader.
        /// </summary>
        /// <param name="reader">Reader to read the next blueprint from.</param>
        /// <returns>Read blueprint.</returns>
        public Blueprint Read(XmlReader reader)
        {
            reader.Read();
            reader.Read();

            var blueprintId = reader[BlueprintIdAttributeName];
            var blueprint = new Blueprint(blueprintId);

            // Read blueprint id.
            reader.ReadStartElement(BlueprintElementName);
            {
                // Read property values.
                reader.ReadStartElement(PropertyValuesElementName);
                {
                    while (reader.IsStartElement(PropertyElementName))
                    {
                        var key = reader[PropertyKeyAttributeName];
                        var typeName = reader[PropertyTypeAttributeName];
                        var type = Type.GetType(typeName);

                        reader.ReadStartElement(PropertyElementName);
                        {
                            var value =
                                new XmlSerializer(type, new XmlRootAttribute(PropertyValueElementName)).Deserialize(
                                    reader);

                            // Add to blueprint.
                            blueprint.PropertyValues.Add(key, value);
                        }
                        reader.ReadEndElement();
                    }
                }
                reader.ReadEndElement();

                // Read components.
                reader.ReadStartElement(ComponentsElementName);
                {
                    while (reader.IsStartElement(ComponentElementName))
                    {
                        var component = reader.ReadElementContentAsString();

                        // Add to blueprint.
                        blueprint.ComponentTypes.Add(component);
                    }
                }
                reader.ReadEndElement();
            }
            reader.ReadEndElement();

            return blueprint;
        }
 /// <summary>
 /// Generates an object from its XML representation.
 /// </summary>
 /// <param name="reader">The <see cref="T:System.Xml.XmlReader"></see> stream from which the object is deserialized.</param>
 void IXmlSerializable.ReadXml(XmlReader reader)
 {
     reader.Read();
       reader.ReadStartElement("dictionary");
       while (reader.NodeType != XmlNodeType.EndElement) {
     reader.ReadStartElement("item");
     string key = reader.ReadElementString("key");
     string value = reader.ReadElementString("value");
     reader.ReadEndElement();
     reader.MoveToContent();
     this.Add(key, value);
       }
       reader.ReadEndElement();
 }
Beispiel #14
0
    public void ReadXml(System.Xml.XmlReader reader)
    {
        XmlSerializer keySerializer   = new XmlSerializer(typeof(TKey));
        XmlSerializer valueSerializer = new XmlSerializer(typeof(TValue));

        bool wasEmpty = reader.IsEmptyElement;

        reader.Read();

        if (wasEmpty)
        {
            return;
        }

        //bool keyIsString = typeof(TKey) == typeof(string);
        bool keyIsString = typeof(TKey).FindInterfaces((n, k) => n.ToString() == k.ToString(), "System.IConvertible").Length > 0;

        while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
        {
            if (keyIsString)
            {
                /*
                 * var ms = new MemoryStream(Encoding.Unicode.GetBytes(reader.GetAttribute("key")));
                 * TKey key = (TKey)keySerializer.Deserialize(ms);
                 */
                string at  = reader.GetAttribute("key");
                TKey   key = (TKey)Convert.ChangeType(at, typeof(TKey));
                reader.ReadStartElement("item");
                TValue value = (TValue)valueSerializer.Deserialize(reader);
                this.Add(key, value);
            }
            else
            {
                reader.ReadStartElement("item");

                reader.ReadStartElement("key");
                TKey key = (TKey)keySerializer.Deserialize(reader);
                reader.ReadEndElement();

                reader.ReadStartElement("value");
                TValue value = (TValue)valueSerializer.Deserialize(reader);
                reader.ReadEndElement();

                this.Add(key, value);
            }
            reader.ReadEndElement();
            reader.MoveToContent();
        }
        reader.ReadEndElement();
    }
Beispiel #15
0
 public override void ReadXml(XmlReader reader)
 {
     reader.MoveToContent();
     var isEmpty = reader.IsEmptyElement;
     reader.ReadStartElement();
     if (!isEmpty)
     {
         reader.ReadStartElement("Title");
         Title = reader.ReadContentAsString();
         reader.ReadEndElement();
         OnlineResource.ReadXml(reader);
         LogoURL.ReadXml(reader);
         reader.ReadEndElement();
     }
 }
        /// <summary>
        /// Deserializes an ChangedItem from an XML file.
        /// </summary>
        /// <param name="reader">XMLReader where the ChangedItem is.</param>
        /// <returns>ChangedItem.</returns>
        public static ChangedItem Deserialize(XmlReader reader)
        {
            ChangedItem lResult = null;
            if (reader.IsStartElement(DTD.Error.ChangedItems.TagChangedItem))
            {
                lResult = new ChangedItem();
                string stringModelType = reader.GetAttribute(DTD.Error.ChangedItems.ChangedItem.TagType);
                ModelType modelType = Convert.StringTypeToMODELType(stringModelType);

                if (modelType == ModelType.Oid)
                {
                    lResult.Type = Convert.MODELTypeToStringType(ModelType.Oid);
                    lResult.ClassName = stringModelType;
                }
                else
                {
                    lResult.Type = stringModelType;
                    lResult.ClassName = string.Empty;
                }
                lResult.Name = reader.GetAttribute(DTD.Error.ChangedItems.ChangedItem.TagName);

                if (!reader.IsEmptyElement)
                {
                    reader.ReadStartElement();

                    if (reader.IsStartElement(DTD.Error.ChangedItems.ChangedItem.TagChangedItemOldValue))
                    {
                        lResult.OldValue =  XMLChangedItemValueSerializer.Deserialize(reader.ReadSubtree(),lResult.Type, lResult.ClassName);
                        reader.ReadEndElement();
                    }

                    if (reader.IsStartElement(DTD.Error.ChangedItems.ChangedItem.TagChangedItemNewValue))
                    {
                        lResult.NewValue = XMLChangedItemValueSerializer.Deserialize(reader.ReadSubtree(), lResult.Type, lResult.ClassName);
                        reader.ReadEndElement();
                    }
                }
                else
                {
                    reader.Skip();
                }
            }
            else
            {
                throw new ArgumentException("Xml Reader don't have the ChangedItem in Start Element.", "XmlReader reader");
            }
            return lResult;
        }
Beispiel #17
0
 public static int readInt(XmlReader reader, string nodeName)
 {
     reader.ReadStartElement(nodeName);
     int i = reader.ReadContentAsInt();
     reader.ReadEndElement();
     return i;
 }
Beispiel #18
0
    public void ReadXml(System.Xml.XmlReader reader)
    {
        reader.MoveToContent();
        reader.ReadStartElement();
        inputController       = System.Type.GetType(reader.ReadElementString("inputController"));
        inputControllerBackup = System.Type.GetType(reader.ReadElementString("inputControllerBackup"));
        xResolution           = System.Convert.ToInt32(reader.ReadElementString("xResolution"));
        yResolution           = System.Convert.ToInt32(reader.ReadElementString("yResolution"));
        fullscreen            = System.Convert.ToBoolean(reader.ReadElementString("fullscreen"));

        showDebug        = System.Convert.ToBoolean(reader.ReadElementString("showDebug"));
        showConfigurator = System.Convert.ToBoolean(reader.ReadElementString("showConfigurator"));
        projectorBlend   = System.Convert.ToBoolean(reader.ReadElementString("projectorBlend"));
        brakeAxis        = reader.ReadElementString("brakeAxis");
        gasAxis          = reader.ReadElementString("gasAxis");
        minBrake         = System.Convert.ToInt32(reader.ReadElementString("minBrake"));
        maxBrake         = System.Convert.ToInt32(reader.ReadElementString("maxBrake"));
        minGas           = System.Convert.ToInt32(reader.ReadElementString("minGas"));
        maxGas           = System.Convert.ToInt32(reader.ReadElementString("maxGas"));

        minBrakeFanatec = System.Convert.ToInt32(reader.ReadElementString("minBrakeFanatec"));
        maxBrakeFanatec = System.Convert.ToInt32(reader.ReadElementString("maxBrakeFanatec"));
        minGasFanatec   = System.Convert.ToInt32(reader.ReadElementString("minGasFanatec"));
        maxGasFanatec   = System.Convert.ToInt32(reader.ReadElementString("maxGasFanatec"));


        FFBMultiplier = System.Convert.ToSingle(reader.ReadElementString("FFBMultiplier"));
        reader.ReadEndElement();
    }
        public static KeyValuePair<string, Property> ReadXml(XmlReader reader)
        {
            var key = reader.GetAttribute("Key");
            var type = reader.GetAttribute("Type");

            reader.MoveToElement();
            reader.ReadStartElement("PropertyEntry");
            Property value = null;
            try
            {
                var t = Type.GetType(type);
                value = (Property)GetSerializer(t).Deserialize(reader);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Deserialization failed: " + ex.Message);
                Console.WriteLine("Property Key: " + key);
                Console.WriteLine("Property Type Qualified Name: " + type);
                Console.WriteLine("Stacktrace: " + ex.StackTrace);
            }

            reader.ReadEndElement();
            reader.MoveToContent();
            if (value == null)
                throw new Exception();
            return new KeyValuePair<string, Property>(key, value);
        }
        internal static LoggingConfig Load(XmlReader reader)
        {
            if (reader == null)
                throw new ArgumentNullException("reader");

            LoggingConfig result = new LoggingConfig();

            reader.GoToElement();
            if (!reader.IsEmptyElement)
            {
                reader.ReadStartElement();
                while (reader.GoToSibling())
                {
                    switch (reader.LocalName)
                    {
                        default:
                            reader.Skip();
                            break;
                    }
                }
                reader.ReadEndElement();
            }
            else
                reader.Skip();

            return result;
        }
        protected virtual void ReadXml(XmlReader reader, SyndicationFeed result)
        {
            if (result == null)
                throw new ArgumentNullException("result");
            else if (reader == null)
                throw new ArgumentNullException("reader");

            reader.ReadStartElement();              // Read in <RDF>
            reader.ReadStartElement("channel");     // Read in <channel>
            while (reader.IsStartElement())         // Process <channel> children
            {
                if (reader.IsStartElement("title"))
                    result.Title = new TextSyndicationContent(reader.ReadElementString());
                else if (reader.IsStartElement("link"))
                    result.Links.Add(new SyndicationLink(new Uri(reader.ReadElementString())));
                else if (reader.IsStartElement("description"))
                    result.Description = new TextSyndicationContent(reader.ReadElementString());
                else
                    reader.Skip();
            }
            reader.ReadEndElement();                // Read in </channel>

            while (reader.IsStartElement())
            {
                if (reader.IsStartElement("item"))
                {
                    result.Items = this.ReadItems(reader, result);

                    break;
                }
                else
                    reader.Skip();
            }
        }
 protected override object DoDeserializeValue(XmlReader reader, bool isSimpleValue)
 {
   reader.ReadStartElement(); // Read start of enclosing element
   IFilter result = MediaItemQuery.DeserializeFilter(reader);
   reader.ReadEndElement(); // End of enclosing element
   return result;
 }
Beispiel #23
0
 public static string readString(XmlReader reader, string nodeName)
 {
     reader.ReadStartElement(nodeName);
     string s = reader.ReadContentAsString();
     reader.ReadEndElement();
     return s;
 }
Beispiel #24
0
        /// <summary>
        /// Decodes an <see cref="Error"/> object from its XML representation.
        /// </summary>
        public static Error Decode(XmlReader reader)
        {
            if (reader == null) throw new ArgumentNullException("reader");
            if (!reader.IsStartElement()) throw new ArgumentException("Reader is not positioned at the start of an element.", "reader");

            //
            // Read out the attributes that contain the simple
            // typed state.
            //

            var error = new Error();
            ReadXmlAttributes(reader, error);

            //
            // Move past the element. If it's not empty, then
            // read also the inner XML that contains complex
            // types like collections.
            //

            var isEmpty = reader.IsEmptyElement;
            reader.Read();

            if (!isEmpty)
            {
                ReadInnerXml(reader, error);
                reader.ReadEndElement();
            }

            return error;
        }
        internal static WindowsPhoneStoreServiceAppImageNode ParseXml(XmlReader reader)
        {
            var node = new WindowsPhoneStoreServiceAppImageNode();

            if (reader.IsEmptyElement)
            {
                reader.Skip();
            }
            else
            {
                reader.ReadStartElement();

                while (reader.NodeType != XmlNodeType.EndElement)
                {
                    switch (reader.LocalName)
                    {
                        case "id":
                            node.Id = reader.ReadElementContentAsUrn();
                            break;

                        case "orientation":
                            node.Orientation = reader.ReadElementContentAsInt();
                            break;

                        default:
                            reader.Skip();
                            break;
                    }
                }

                reader.ReadEndElement();
            }

            return node;
        }
        protected override SecurityToken ReadTokenCore(XmlReader reader, SecurityTokenResolver tokenResolver)
        {

            if (reader == null) throw new ArgumentNullException("reader");

            if (reader.IsStartElement(Constants.CreditCardTokenName, Constants.CreditCardTokenNamespace))
            {
                string id = reader.GetAttribute(Constants.Id, Constants.WsUtilityNamespace);

                reader.ReadStartElement();

                // read the credit card number
                string creditCardNumber = reader.ReadElementString(Constants.CreditCardNumberElementName, Constants.CreditCardTokenNamespace);

                // read the expiration date
                string expirationTimeString = reader.ReadElementString(Constants.CreditCardExpirationElementName, Constants.CreditCardTokenNamespace);
                DateTime expirationTime = XmlConvert.ToDateTime(expirationTimeString, XmlDateTimeSerializationMode.Utc);

                // read the issuer of the credit card
                string creditCardIssuer = reader.ReadElementString(Constants.CreditCardIssuerElementName, Constants.CreditCardTokenNamespace);
                reader.ReadEndElement();

                CreditCardInfo cardInfo = new CreditCardInfo(creditCardNumber, creditCardIssuer, expirationTime);

                return new CreditCardToken(cardInfo, id);
            }
            else
            {
                return WSSecurityTokenSerializer.DefaultInstance.ReadToken(reader, tokenResolver);
            }
        }
 protected override object DoDeserializeValue(XmlReader reader, bool isSimpleValue)
 {
   reader.ReadStartElement(); // Read start of enclosing element
   MediaItemAspectMetadata result = MediaItemAspectMetadata.Deserialize(reader);
   reader.ReadEndElement(); // End of enclosing element
   return result;
 }
 public override void ReadXml(XmlReader reader)
 {
     reader.ReadStartElement("RemovePortCommand", Context.YttriumNamespace);
     base.ReadXml(reader);
     _isolate = bool.Parse(reader.ReadElementString("Isolate"));
     reader.ReadEndElement();
 }
Beispiel #29
0
 public void ReadXml(XmlReader reader)
 {
     reader.ReadStartElement("PropertyName");
     PropertyName = reader.ReadString();
     reader.ReadEndElement();
     if (!reader.IsEmptyElement)
     {
         reader.ReadStartElement("PropertyValue");
         PropertyValue = reader.ReadString();
         reader.ReadEndElement();
     }
     else
     {
         reader.Read();
     }
 }
 protected override object DoDeserializeValue(XmlReader reader, bool isSimpleValue)
 {
   reader.ReadStartElement();
   PlaylistContents result = PlaylistContents.Deserialize(reader);
   reader.ReadEndElement(); // End of enclosing element
   return result;
 }
        protected override System.IdentityModel.Tokens.SecurityToken ReadTokenCore( XmlReader reader, SecurityTokenResolver tokenResolver )
        {
            if ( reader == null )
                throw new ArgumentNullException( "reader" );

            if ( reader.IsStartElement( Constants.UsernameTokenName, Constants.UsernameTokenNamespace ) )
            {
                //string id = reader.GetAttribute( Constants.IdAttributeName, Constants.WsUtilityNamespace );

                reader.ReadStartElement();

                // read the user name
                string userName = reader.ReadElementString( Constants.UsernameElementName, Constants.UsernameTokenNamespace );

                // read the password hash
                string password = reader.ReadElementString( Constants.PasswordElementName, Constants.UsernameTokenNamespace );

                // read nonce
                string nonce = reader.ReadElementString( Constants.NonceElementName, Constants.UsernameTokenNamespace );

                // read created
                string created = reader.ReadElementString( Constants.CreatedElementName, Constants.WsUtilityNamespace );

                reader.ReadEndElement();

                var info = new Info( userName, password );

                return new SecurityToken( info, nonce, created );
            }

            return DefaultInstance.ReadToken( reader, tokenResolver );
        }
Beispiel #32
0
		/// <summary>
		///		Parses the WDDX element and returns the deserialized
		///		content as a <see cref="Hashtable"/> object, advancing the reader to the next
		///		element.
		/// </summary>
		/// <param name="input">The pre-initialized <see cref="System.Xml.XmlTextReader"/> pointing to the WDDX to be parsed.</param>
		public object ParseElement(XmlReader input)
		{
			Hashtable thisTable = new Hashtable();

			if (input.IsEmptyElement)
			{
				input.Skip();
				return thisTable;
			}

			string elementName;
			object elementValue;
			IWddxElementDeserializer deserializer;
			while (input.Read() && (!(input.Name == "struct" && input.NodeType == XmlNodeType.EndElement)))
			{
				if (input.Name == "var" && input.NodeType != XmlNodeType.EndElement)
				{
					elementName = input.GetAttribute("name");
					input.Read();  // move to contents of <var>
					deserializer = WddxElementDeserializerFactory.GetDeserializer(input.Name);
					elementValue = deserializer.ParseElement(input);
					thisTable.Add(elementName, elementValue);
				}
			}
			input.ReadEndElement();

			return thisTable;
		}
 protected override object DoDeserializeValue(XmlReader reader, bool isSimpleValue)
 {
   reader.ReadStartElement(); // Read start of enclosing element
   UserProfile result = UserProfile.Deserialize(reader);
   reader.ReadEndElement(); // End of enclosing element
   return result;
 }
Beispiel #34
0
        public void ReadXml(XmlReader reader)
        {
            bool isEmpty = reader.IsEmptyElement;

            AddAttributeExtensions(reader);

            reader.ReadStartElement();

            if (!isEmpty)
            {
                while (reader.IsStartElement())
                {
                    if (reader.LocalName == Backlink.ELEMENT_NAME)
                    {
                        if (BacklinkItems == null)
                        {
                            BacklinkItems = new List<Backlink>();
                        }
                        var backlink = new Backlink();
                        backlink.ReadXml(reader);

                        BacklinkItems.Add(backlink);
                    }
                    else
                    {
                        ElementExtensions.Add((XElement)XNode.ReadFrom(reader));
                    }
                }
            }
            reader.ReadEndElement();
        }
Beispiel #35
0
    public void ReadXml(System.Xml.XmlReader reader)
    {
        XmlSerializer keySerializer   = new XmlSerializer(typeof(TKey));
        XmlSerializer valueSerializer = new XmlSerializer(typeof(TValue));

        bool wasEmpty = reader.IsEmptyElement;

        reader.Read();

        if (wasEmpty)
        {
            return;
        }

        var isKeySimpleType = typeof(TKey).IsEnum || typeof(TKey).IsValueType || typeof(TKey) == typeof(string);

        while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
        {
            reader.ReadStartElement("item");

            reader.ReadStartElement("key");
            TKey key = default(TKey);
            if (isKeySimpleType)
            {
                if (typeof(TKey) == typeof(string))
                {
                    Object t = reader.GetAttribute("key_value");
                    key = (TKey)t;
                }
            }
            else
            {
                key = (TKey)valueSerializer.Deserialize(reader);
            }
            reader.ReadEndElement();

            reader.ReadStartElement("value");
            TValue value = (TValue)valueSerializer.Deserialize(reader);
            reader.ReadEndElement();

            this.Add(key, value);

            reader.ReadEndElement();
            reader.MoveToContent();
        }
        reader.ReadEndElement();
    }
Beispiel #36
0
 public void ReadXml(System.Xml.XmlReader reader)
 {
     reader.Read();
     while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
     {
         string key = reader.Name;
         this.Add(key, reader.ReadElementContentAsString());
         reader.MoveToElement();
     }
     reader.ReadEndElement();
 }
    public void ReadXml(System.Xml.XmlReader reader)
    {
        XmlSerializer keySerializer = new XmlSerializer(typeof(TKey));
        // XmlSerializer valueSerializer = new XmlSerializer( typeof( TValue ) );


        bool wasEmpty = reader.IsEmptyElement;

        reader.Read();

        if (wasEmpty)
        {
            return;
        }

        while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
        {
            reader.ReadStartElement("item");

            reader.ReadStartElement("key");
            TKey key = ( TKey )keySerializer.Deserialize(reader);
            reader.ReadEndElement();

            reader.ReadStartElement("value");
            System.Runtime.Serialization.DataContractSerializer serializer =
                new System.Runtime.Serialization.DataContractSerializer(typeof(TValue), null, int.MaxValue, false, false, null, new Microsoft.Xrm.Sdk.KnownTypesResolver());
            TValue value = (TValue)serializer.ReadObject(reader);


            reader.ReadEndElement();

            this.Add(key, value);

            reader.ReadEndElement();
            reader.MoveToContent();
        }
        reader.ReadEndElement();
    }
Beispiel #38
0
    public void ReadXml(System.Xml.XmlReader reader)
    {
        bool wasEmpty = reader.IsEmptyElement;

        reader.Read();

        if (wasEmpty)
        {
            return;
        }

        while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
        {
            string key = reader.Name;
            reader.ReadStartElement();
            string value = reader.ReadContentAsString();
            reader.ReadEndElement();

            this[key] = value;

            reader.MoveToContent();
        }
        reader.ReadEndElement();
    }
Beispiel #39
0
        /// <summary>
        /// Updates an existing <see cref="NameValueCollection" /> object from
        /// its XML representation.
        /// </summary>

        private static void UpcodeTo(XmlReader reader, NameValueCollection collection)
        {
            if (collection == null)
            {
                throw new ArgumentNullException("collection");
            }

            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }

            Debug.Assert(!reader.IsEmptyElement);
            reader.Read();

            //
            // Add entries into the collection as <item> elements
            // with child <value> elements are found.
            //

            while (reader.NodeType != XmlNodeType.EndElement)
            {
                if (reader.IsStartElement("item"))
                {
                    string name   = reader.GetAttribute("name");
                    bool   isNull = reader.IsEmptyElement;

                    reader.Read(); // <item>

                    if (!isNull)
                    {
                        while (reader.NodeType != XmlNodeType.EndElement)
                        {
                            if (reader.IsStartElement("value")) // <value ...>
                            {
                                string value = reader.GetAttribute("string");
                                collection.Add(name, value);
                                if (reader.IsEmptyElement)
                                {
                                    reader.Read();
                                }
                                else
                                {
                                    reader.Read();
                                    while (reader.NodeType != XmlNodeType.EndElement)
                                    {
                                        reader.Skip();
                                    }
                                    reader.ReadEndElement();
                                }
                            }
                            else
                            {
                                reader.Skip();
                            }

                            reader.MoveToContent();
                        }

                        reader.ReadEndElement(); // </item>
                    }
                    else
                    {
                        collection.Add(name, null);
                    }
                }
                else
                {
                    reader.Skip();
                }

                reader.MoveToContent();
            }

            reader.ReadEndElement();
        }
Beispiel #40
0
        public void ReadXml(System.Xml.XmlReader reader)
        {
            var s = new XmlSerializer(typeof(string));
            var b = new XmlSerializer(typeof(bool));
            var l = new XmlSerializer(typeof(List <AutoAnswer>));

            if (reader.IsEmptyElement || !reader.Read())
            {
                return;
            }
            while (reader.NodeType != XmlNodeType.EndElement)
            {
                reader.ReadStartElement("TaskInfo");

                //taskid
                reader.ReadStartElement("TaskId");
                TaskId = new Guid((string)s.Deserialize(reader));
                reader.ReadEndElement();

                //plugin name
                reader.ReadStartElement("PluginName");
                PluginName = (string)s.Deserialize(reader);
                reader.ReadEndElement();

                //url
                reader.ReadStartElement("Url");
                Url = (string)s.Deserialize(reader);
                reader.ReadEndElement();

                //title
                reader.ReadStartElement("Title");
                Title = (string)s.Deserialize(reader);
                reader.ReadEndElement();

                //Status
                reader.ReadStartElement("Status");
                Status = (DownloadStatus)Enum.Parse(typeof(DownloadStatus), (string)s.Deserialize(reader), true);
                reader.ReadEndElement();

                //createtime
                reader.ReadStartElement("CreateTime");
                CreateTime = DateTime.Parse((string)s.Deserialize(reader));
                reader.ReadEndElement();

                //finishtime
                if (reader.IsStartElement("FinishTime"))
                {
                    reader.ReadStartElement("FinishTime");
                    FinishTime = DateTime.Parse((string)s.Deserialize(reader));
                    reader.ReadEndElement();
                }

                //savedirectory
                reader.ReadStartElement("SaveDirectory");
                SaveDirectory = new DirectoryInfo((string)s.Deserialize(reader));
                reader.ReadEndElement();

                //partcount
                reader.ReadStartElement("PartCount");
                PartCount = Int32.Parse((string)s.Deserialize(reader));
                reader.ReadEndElement();

                //currentpart
                reader.ReadStartElement("CurrentPart");
                CurrentPart = Int32.Parse((string)s.Deserialize(reader));
                reader.ReadEndElement();

                //is be added
                reader.ReadStartElement("IsBeAdded");
                IsBeAdded = (bool)b.Deserialize(reader);
                reader.ReadEndElement();

                //partialfinished
                reader.ReadStartElement("PartialFinished");
                PartialFinished = (bool)b.Deserialize(reader);
                reader.ReadEndElement();

                //partialfinished detail
                reader.ReadStartElement("PartialFinishedDetail");
                PartialFinishedDetail = (string)s.Deserialize(reader);
                reader.ReadEndElement();

                //autoanswer
                reader.ReadStartElement("AutoAnswers");
                this.AutoAnswer = (List <AutoAnswer>)l.Deserialize(reader);
                reader.ReadEndElement();

                //extract cache
                reader.ReadStartElement("ExtractCache");
                ExtractCache = (bool)b.Deserialize(reader);
                reader.ReadEndElement();

                //filepath
                reader.ReadStartElement("Files");
                FilePath = new List <string>();
                while (reader.IsStartElement("File"))
                {
                    reader.ReadStartElement("File");
                    FilePath.Add((string)s.Deserialize(reader));
                    reader.ReadEndElement();
                }
                if (reader.NodeType == XmlNodeType.EndElement)
                {
                    reader.ReadEndElement();
                }

                //subfilepath
                SubFilePath = new List <string>();
                reader.ReadStartElement("SubFiles");

                while (reader.IsStartElement("SubFile"))
                {
                    reader.ReadStartElement("SubFile");
                    SubFilePath.Add((string)s.Deserialize(reader));
                    reader.ReadEndElement();
                }
                if (reader.NodeType == XmlNodeType.EndElement)
                {
                    reader.ReadEndElement();
                }



                //downsub
                reader.ReadStartElement("DownSub");
                DownSub = (DownloadSubtitleType)Enum.Parse(typeof(DownloadSubtitleType), (string)s.Deserialize(reader), true);
                reader.ReadEndElement();

                //proxy
                XmlSerializer sProxy = new XmlSerializer(typeof(AcDownProxy));
                reader.ReadStartElement("Proxy");
                AcDownProxy pxy = (AcDownProxy)sProxy.Deserialize(reader);
                if (pxy.Address == "" && pxy.Port == 0)
                {
                    Proxy = null;
                }
                else
                {
                    Proxy = pxy.ToWebProxy();
                }
                reader.ReadEndElement();

                //sourceUrl
                reader.ReadStartElement("SourceUrl");
                SourceUrl = (string)s.Deserialize(reader);
                reader.ReadEndElement();

                //Comment
                reader.ReadStartElement("Comment");
                Comment = (string)s.Deserialize(reader);
                reader.ReadEndElement();

                //Hash
                reader.ReadStartElement("Hash");
                _hash = (string)s.Deserialize(reader);
                reader.ReadEndElement();

                //Progress
                reader.ReadStartElement("Progress");

                if (!double.TryParse((string)s.Deserialize(reader), out _progress))
                {
                    _progress = 0;
                }
                if (_progress > 1.0)
                {
                    _progress = 1.0;
                }
                if (_progress < 0.0)
                {
                    _progress = 0;
                }
                if (double.IsNaN(_progress))
                {
                    _progress = 0;
                }
                reader.ReadEndElement();

                //settings
                reader.ReadStartElement("Settings");
                if (!reader.IsEmptyElement)
                {
                    XmlSerializer sSettings = new XmlSerializer(typeof(SerializableDictionary <string, string>));
                    Settings = (SerializableDictionary <string, string>)sSettings.Deserialize(reader);
                }
                else
                {
                    Settings = new SerializableDictionary <string, string>();
                    reader.Read();
                }
                reader.ReadEndElement();

                //结束读取
                reader.ReadEndElement();
                reader.MoveToContent();
            }
            reader.ReadEndElement();
        }
Beispiel #41
0
        public void ReadXml(System.Xml.XmlReader reader)
        {
            if (reader.Name == "CameraPosition")
            {
                reader.ReadStartElement();
                Position = new Vector3(reader.ReadElementContentAsFloat("X", ""),
                                       reader.ReadElementContentAsFloat("Y", ""),
                                       reader.ReadElementContentAsFloat("Z", ""));
                reader.ReadEndElement();
            }

            if (reader.Name == "CameraTranslation")
            {
                reader.ReadStartElement();
                Translation = new Vector3(reader.ReadElementContentAsFloat("X", ""),
                                          reader.ReadElementContentAsFloat("Y", ""),
                                          reader.ReadElementContentAsFloat("Z", ""));
                reader.ReadEndElement();
            }

            if (reader.Name == "CameraDirection")
            {
                reader.ReadStartElement();
                Direction = new Vector3(reader.ReadElementContentAsFloat("X", ""),
                                        reader.ReadElementContentAsFloat("Y", ""),
                                        reader.ReadElementContentAsFloat("Z", ""));
                reader.ReadEndElement();
            }

            if (reader.Name == "CameraUp")
            {
                reader.ReadStartElement();
                Up = new Vector3(reader.ReadElementContentAsFloat("X", ""),
                                 reader.ReadElementContentAsFloat("Y", ""),
                                 reader.ReadElementContentAsFloat("Z", ""));
                reader.ReadEndElement();
            }

            if (reader.Name == "CameraTarget")
            {
                reader.ReadStartElement();
                Target = new Vector3(reader.ReadElementContentAsFloat("X", ""),
                                     reader.ReadElementContentAsFloat("Y", ""),
                                     reader.ReadElementContentAsFloat("Z", ""));
                reader.ReadEndElement();
            }

            if (reader.Name == "CameraRight")
            {
                reader.ReadStartElement();
                Right = new Vector3(reader.ReadElementContentAsFloat("X", ""),
                                    reader.ReadElementContentAsFloat("Y", ""),
                                    reader.ReadElementContentAsFloat("Z", ""));
                reader.ReadEndElement();
            }

            FOV   = reader.ReadElementContentAsFloat("FOV", "");
            Ratio = reader.ReadElementContentAsFloat("Ratio", "");
            Near  = reader.ReadElementContentAsFloat("Near", "");
            Far   = reader.ReadElementContentAsFloat("Far", "");

            CreateLookAt();
            CreateProjection();

            base.ReadXml(reader);
        }
Beispiel #42
0
        public void ReadXml(System.Xml.XmlReader reader)
        {
            //  Loop over the XML file
            while (reader.Read())
            {
                //  Here we check the type of the node, in this case we are looking for element
                if (reader.IsStartElement() && reader.NodeType == XmlNodeType.Element)
                {
                    //  If the element is "profile"
                    if (reader.Name == "Key")
                    {
                        Key = reader.ReadElementString("Key");
                        continue;
                    }
                    //  If the element is "profile"
                    if (reader.Name == "ParentNodeKey")
                    {
                        ParentNodeKey = reader.ReadElementString("ParentNodeKey");
                        continue;
                    }

                    ////  If the element is "profile"
                    //if (reader.Name == "TreeContainer")
                    //{
                    //    var otherSer = new XmlSerializer(typeof(TreeContainer));
                    //    var other = (TreeContainer)otherSer.Deserialize(reader);
                    //}

                    //  If the element is "profile"
                    if (reader.Name == "ChildNodes")
                    {
                        var childNodeId    = reader.GetAttribute("Id");
                        var childNodeCount = reader.GetAttribute("count").To <int>(0);

                        var otherSer = new XmlSerializer(typeof(TreeContainer));

                        for (int i = 0; i < childNodeCount; i++)
                        {
                            reader.Read();

                            if (reader.IsStartElement() && reader.NodeType == XmlNodeType.Element && reader.Name == "TreeContainer")
                            {
                                var other = (TreeContainer)otherSer.Deserialize(reader);
                                ChildNodes.Add(other);

                                reader.ReadEndElement();
                            }
                        }

                        //var counter = 0;
                        //while (counter<childNodeCount && reader.Read())
                        //{
                        //    if (reader.IsStartElement() && reader.NodeType == XmlNodeType.Element && reader.Name == "TreeContainer")
                        //    {
                        //        var other = (TreeContainer)otherSer.Deserialize(reader);
                        //        ChildNodes.Add(other);
                        //        counter++;
                        //    }
                        //}
                    }

                    //  If the element is "profile"
                    if (reader.Name == "Items")
                    {
                        var itemCount = reader.GetAttribute("count").To <int>(0);

                        var otherSer = new XmlSerializer(typeof(TreeItem));

                        var counter = 0;

                        while (counter < itemCount && reader.Read())
                        {
                            if (reader.IsStartElement() && reader.NodeType == XmlNodeType.Element && reader.Name == "TreeItem")
                            {
                                var other = (TreeItem)otherSer.Deserialize(reader);
                                Items.Add(other);

                                counter++;
                            }
                        }
                    }
                }
            }
        }
Beispiel #43
0
 public override void ReadEndElement()
 {
     CheckAsync();
     _coreReader.ReadEndElement();
 }
        public void ReadXml(System.Xml.XmlReader reader)
        {
            reader.MoveToContent();
            reader.ReadStartElement();

            Name     = reader.ReadElementString("Name", "");
            MyEffect = ResourceManager.Instance.LoadEffect(reader.ReadElementString("EffectPath", ""));

            uint      normColor  = 0xFFFF0F0F;
            uint      blackColor = 0xFF000000;
            Texture2D defDiff    = null;

            if (!ResourceManager.Instance.Textures.TryGetValue("DefaultDiffuse", out defDiff))
            {
                defDiff = new Texture2D(TrashSoupGame.Instance.GraphicsDevice, 1, 1, false, SurfaceFormat.Color);
                defDiff.SetData <uint>(new uint[] { blackColor });
                ResourceManager.Instance.Textures.Add("DefaultDiffuse", defDiff);
            }
            Texture2D defNrm = null;

            if (!ResourceManager.Instance.Textures.TryGetValue("DefaultNormal", out defNrm))
            {
                defNrm = new Texture2D(TrashSoupGame.Instance.GraphicsDevice, 1, 1, false, SurfaceFormat.Color);
                defNrm.SetData <uint>(new uint[] { normColor });
                ResourceManager.Instance.Textures.Add("DefaultNormal", defNrm);
            }
            TextureCube defCbc = null;

            if (!ResourceManager.Instance.TexturesCube.TryGetValue("DefaultCube", out defCbc))
            {
                defCbc = new TextureCube(TrashSoupGame.Instance.GraphicsDevice, 1, false, SurfaceFormat.Color);
                defCbc.SetData <uint>(CubeMapFace.NegativeX, new uint[] { blackColor });
                defCbc.SetData <uint>(CubeMapFace.PositiveX, new uint[] { blackColor });
                defCbc.SetData <uint>(CubeMapFace.NegativeY, new uint[] { blackColor });
                defCbc.SetData <uint>(CubeMapFace.PositiveY, new uint[] { blackColor });
                defCbc.SetData <uint>(CubeMapFace.NegativeZ, new uint[] { blackColor });
                defCbc.SetData <uint>(CubeMapFace.PositiveZ, new uint[] { blackColor });
                ResourceManager.Instance.TexturesCube.Add("DefaultCube", defCbc);
            }

            DiffuseMap = ResourceManager.Instance.LoadTexture(reader.ReadElementString("DiffusePath", ""));
            if (reader.Name == "NormalPath")
            {
                NormalMap = ResourceManager.Instance.LoadTexture(reader.ReadElementString("NormalPath", ""));
            }
            if (reader.Name == "CubePath")
            {
                CubeMap = ResourceManager.Instance.LoadTextureCube(reader.ReadElementString("CubePath", ""));
            }

            reader.ReadStartElement("DiffuseColor");
            DiffuseColor = new Vector3(reader.ReadElementContentAsFloat("X", ""),
                                       reader.ReadElementContentAsFloat("Y", ""),
                                       reader.ReadElementContentAsFloat("Z", ""));
            reader.ReadEndElement();

            reader.ReadStartElement("SpecularColor");
            SpecularColor = new Vector3(reader.ReadElementContentAsFloat("X", ""),
                                        reader.ReadElementContentAsFloat("Y", ""),
                                        reader.ReadElementContentAsFloat("Z", ""));
            reader.ReadEndElement();

            Glossiness = reader.ReadElementContentAsFloat("Glossiness", "");

            reader.ReadStartElement("ReflectivityColor");
            ReflectivityColor = new Vector3(reader.ReadElementContentAsFloat("X", ""),
                                            reader.ReadElementContentAsFloat("Y", ""),
                                            reader.ReadElementContentAsFloat("Z", ""));
            reader.ReadEndElement();

            ReflectivityBias = reader.ReadElementContentAsFloat("ReflectivityBias", "");
            Transparency     = reader.ReadElementContentAsFloat("Transparency", "");
            PerPixelLighting = reader.ReadElementContentAsBoolean("PerPixelLighting", "");
            RecieveShadows   = reader.ReadElementContentAsBoolean("ReceiveShadows", "");
            Unlit            = reader.ReadElementContentAsBoolean("Unlit", "");

            AssignParamsInitialize();

            if (this.GetType() == typeof(Material))
            {
                reader.ReadEndElement();
            }
        }
        public void ReadXml(System.Xml.XmlReader reader)
        {
            try
            {
                string objectType = reader.GetAttribute("type");
                if (objectType != null && objectType.Trim().Length > 0)
                {
                    if (objectType == "MixedCollection")
                    {
                        int index = 0;
                        reader.Read();
                        while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
                        {
                            if (reader.IsStartElement("Item"))
                            {
                                objectType = reader.GetAttribute("type");
                                Type type = ChoType.GetType(objectType);
                                if (type == null)
                                {
                                    throw new ApplicationException(String.Format("Can't find {0} class.", objectType));
                                }

                                reader.ReadStartElement("Item");

                                try
                                {
                                    index++;
                                    //XmlSerializer xmlSerializer = new XmlSerializer(type);
                                    XmlSerializer xmlSerializer = XmlSerializer.FromTypes(new[] { type }).GetNValue(0);
                                    Add(xmlSerializer.Deserialize(reader));
                                }
                                catch (Exception ex)
                                {
                                    throw new XmlException(String.Format("Failed to deserialize {0} array item.", index), ex);
                                }

                                reader.ReadEndElement();
                            }
                        }
                        reader.ReadEndElement();
                    }
                    else
                    {
                        Type type = ChoType.GetType(objectType);

                        if (type == null)
                        {
                            throw new ApplicationException(String.Format("Can't find {0} class.", objectType));
                        }

                        reader.Read();
                        while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
                        {
                            //if (reader.IsStartElement(type.Name))
                            //{
                            //XmlSerializer xmlSerializer = new XmlSerializer(ChoType.GetType(objectType));
                            XmlSerializer xmlSerializer = XmlSerializer.FromTypes(new[] { ChoType.GetType(objectType) }).GetNValue(0);
                            Add(xmlSerializer.Deserialize(reader));
                            //}
                        }
                        reader.ReadEndElement();
                    }
                }
                else
                {
                    reader.Skip();
                }
            }
            catch (Exception)
            {
                //ChoStreamProfile.WriteLine(ChoReservedFileName.SerializationIssues.ToString(), ChoApplicationException.ToString(ex));
                throw;
            }
        }
Beispiel #46
0
        public void ReadXml(System.Xml.XmlReader reader)
        {
            if (reader.ReadToFollowing(this.GetType().Name))
            {
                String s = reader.GetAttribute(Orientation.GetType().Name);
                m_orientation = (Orientation)(Enum.Parse(Orientation.GetType(), s));
                switch (m_orientation)
                {
                case Orientation.Horizontal:
                    if (reader.ReadToDescendant("Column"))
                    {
                        RowDefinitions.Add(NewRowDefinition(new GridLength(1, GridUnitType.Star), m_minGridSize.Height));
                        do
                        {
                            double      width  = double.Parse(reader.GetAttribute("Width"), CultureInfo.InvariantCulture);
                            IDockLayout layout = null;
                            reader.ReadStartElement();
                            if (reader.LocalName == typeof(DockedWindow).Name)
                            {
                                DockedWindow dockedWindow = new DockedWindow(Root, reader.ReadSubtree());
                                layout = dockedWindow.DockedContent.Children.Count != 0 ? dockedWindow : null;
                                reader.ReadEndElement();
                            }
                            else if (reader.LocalName == typeof(GridLayout).Name)
                            {
                                GridLayout gridLayout = new GridLayout(Root, reader.ReadSubtree());
                                layout = gridLayout.Layouts.Count > 0 ? gridLayout : null;
                                reader.ReadEndElement();
                            }
                            if (layout != null)
                            {
                                if (Children.Count > 0)
                                {
                                    ColumnDefinitions.Add(NewColumnDefinition(new GridLength(1, GridUnitType.Auto), 0));
                                    Children.Add(NewGridSplitter(Orientation));
                                }
                                ColumnDefinitions.Add(NewColumnDefinition(new GridLength(width, GridUnitType.Star), m_minGridSize.Width));
                                m_children.Add(layout);
                                Children.Add((FrameworkElement)layout);
                            }
                        } while (reader.ReadToNextSibling("Column"));
                    }
                    break;

                case Orientation.Vertical:
                    if (reader.ReadToDescendant("Row"))
                    {
                        ColumnDefinitions.Add(NewColumnDefinition(new GridLength(1, GridUnitType.Star), m_minGridSize.Width));
                        do
                        {
                            double      height = double.Parse(reader.GetAttribute("Height"), CultureInfo.InvariantCulture);
                            IDockLayout layout = null;
                            reader.ReadStartElement();
                            if (reader.LocalName == typeof(DockedWindow).Name)
                            {
                                DockedWindow dockedWindow = new DockedWindow(Root, reader.ReadSubtree());
                                layout = dockedWindow.DockedContent.Children.Count != 0 ? dockedWindow : null;
                                reader.ReadEndElement();
                            }
                            else if (reader.LocalName == typeof(GridLayout).Name)
                            {
                                GridLayout gridLayout = new GridLayout(Root, reader.ReadSubtree());
                                layout = gridLayout.Layouts.Count > 0 ? gridLayout : null;
                                reader.ReadEndElement();
                            }
                            if (layout != null)
                            {
                                if (Children.Count > 0)
                                {
                                    RowDefinitions.Add(NewRowDefinition(new GridLength(1, GridUnitType.Auto), 0));
                                    Children.Add(NewGridSplitter(Orientation));
                                }
                                RowDefinitions.Add(NewRowDefinition(new GridLength(height, GridUnitType.Star), m_minGridSize.Height));
                                m_children.Add(layout);
                                Children.Add((FrameworkElement)layout);
                            }
                        } while (reader.ReadToNextSibling("Row"));
                    }
                    break;
                }
                for (int i = 0; i < Children.Count; i++)
                {
                    Grid.SetColumn(Children[i], Orientation == Orientation.Horizontal ? i : 0);
                    Grid.SetRow(Children[i], Orientation == Orientation.Vertical ? i : 0);
                }
                reader.ReadEndElement();
            }
        }