/// <summary>
    /// Applies the transformation from the reader to the writer
    /// </summary>
    /// <param name="reader"></param>
    /// <param name="writer"></param>
    public void Transform(XmlReader reader, XmlWriter writer) {
      Contract.Requires(reader != null);
      Contract.Requires(writer != null);

      while (reader.Read())
        this.WriteNodeSingle(reader, writer);
    }
 void IFlickrParsable.Load(XmlReader reader)
 {
     while (reader.MoveToNextAttribute())
     {
         switch (reader.LocalName)
         {
             case "id":
                 PhotoId = reader.Value;
                 break;
             case "ispublic":
                 IsPublic = reader.Value == "1";
                 break;
             case "iscontact":
                 IsContact = reader.Value == "1";
                 break;
             case "isfamily":
                 IsFamily = reader.Value == "1";
                 break;
             case "isfriend":
                 IsFriend = reader.Value == "1";
                 break;
         }
     }
     reader.Read();
 }
        public override void DeserializeNetwork(XmlReader xmlReader)
        {
            base.DeserializeNetwork(xmlReader);

            var expander = ControlElements[0] as SliderExpanderDouble;
            if (expander == null) return;

            var attribute = xmlReader.GetAttribute("SliderMax");
            if (attribute != null)
                expander.SliderMax = Convert.ToDouble(attribute.Replace(".", ","));

            var attribute1 = xmlReader.GetAttribute("SliderMin");
            if (attribute1 != null)
                expander.SliderMin  = Convert.ToDouble(attribute1.Replace(".", ","));

            var attribute2 = xmlReader.GetAttribute("SliderValue");
            if (attribute2 != null)
                expander.SliderValue = Convert.ToDouble(attribute2.Replace(".", ","));

            var attribute3 = xmlReader.GetAttribute("SliderStep");
            if (attribute3 != null)
                expander.SliderStep = Convert.ToDouble(attribute3.Replace(".", ","));

            var attribute4 = xmlReader.GetAttribute("IsExpanded");
            if (attribute4 != null)
                expander.IsExpanded = Convert.ToBoolean(attribute4.Replace(".", ","));
        }
Example #4
0
 public object TokenizeFromXml(XmlReader reader)
 {
     reader.ReadStartElement();
     Geometry geometry = GmlFormatter.Create().Read<Geometry>(reader);
     reader.SkipInsignificantNodes();
     return geometry;
 }
        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 );
        }
Example #6
0
        public void ReadFromXml(XmlReader reader)
        {
            reader.MoveToContent();
            if (reader.IsEmptyElement) { reader.Read(); return; }

            num = int.Parse(reader.GetAttribute("number"));

            reader.Read();
            while (!reader.EOF)
            {
                if (reader.IsStartElement())
                {
                    if (reader.Name == "class")
                    {
                        var sClass = new ScheduleClass();
                        sClass.ReadFromXml(reader);
                        classes.Add(sClass);
                    }
                    else
                    {
                        reader.Skip();
                    }
                }
                else
                {
                    reader.Read();
                    break;
                }
            }
        }
 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;
 }
        protected void HandleTypeAttribute(XmlReader reader)
        {
            DebugCheck.NotNull(reader);

            string type;
            if (!Utils.GetString(Schema, reader, out type))
            {
                return;
            }

            TypeModifier typeModifier;
            Function.RemoveTypeModifier(ref type, out typeModifier, out _isRefType);

            switch (typeModifier)
            {
                case TypeModifier.Array:
                    _collectionKind = CollectionKind.Bag;
                    break;
                default:
                    Debug.Assert(
                        typeModifier == TypeModifier.None,
                        string.Format(
                            CultureInfo.CurrentCulture,
                            "Type is not valid for property {0}: {1}. The modifier for the type cannot be used in this context.", FQName,
                            reader.Value));
                    break;
            }

            if (!Utils.ValidateDottedName(Schema, reader, type))
            {
                return;
            }

            _unresolvedType = type;
        }
Example #9
0
        protected override void DeserializePropertyElement(XmlReader reader)
        {
            if (reader == null) throw new ArgumentNullException ("reader");

            if (reader.NamespaceURI == Schemas.UpnpSchema) {
                switch (reader.LocalName) {
                case "producer":
                    producer_list.Add (reader.ReadString ());
                    break;
                default:
                    base.DeserializePropertyElement (reader);
                    break;
                }
            } else if (reader.NamespaceURI == Schemas.DublinCoreSchema) {
                switch (reader.LocalName) {
                case "contributor":
                    contributor_list.Add (reader.ReadString ());
                    break;
                case "date":
                    Date = reader.ReadString ();
                    break;
                default:
                    base.DeserializePropertyElement (reader);
                    break;
                }
            } else {
                base.DeserializePropertyElement (reader);
            }
        }
Example #10
0
        /// <summary>
        /// Initializes the object with a XML reader.
        /// </summary>
        public XmlDecoder(System.Type systemType, XmlReader reader, ServiceMessageContext context)
        {
            Initialize();

            m_reader  = reader;
            m_context = context;

            string ns = null;
            string name = null;

            if (systemType != null)
            {
                XmlQualifiedName typeName = EncodeableFactory.GetXmlName(systemType);
                ns = typeName.Namespace;
                name = typeName.Name;
            }

            if (ns == null)
            {
                m_reader.MoveToContent();
                ns = m_reader.NamespaceURI;
                name = m_reader.Name;
            }

            int index = name.IndexOf(':');

            if (index != -1)
            {
                name = name.Substring(index + 1);
            }

            PushNamespace(ns);
            BeginField(name, false);
        }      
Example #11
0
 public bool ParseLogs()
 {
     try
     {
         foreach (string f in _root.Files)
         {
             _reader = new XmlTextReader(f);
             Console.WriteLine("Loading Log");
             while (_reader.Read())
             {
                 if (_reader.Name == "State")
                 {
                     Dictionary<String, String> attributes = GetAttributes();
                     _root.States.Add(new Model.PMState(attributes));
                     ParseState(_reader.ReadSubtree());
                 }
             }
         }
     }
     catch
     {
         return false;
     }
     return true;
 }
Example #12
0
        public bool FromXml(XmlReader reader)
        {
            if (reader == null || reader.Name != "Lib")
            {
                return false;
            }

            if (reader.Name == "Order" || reader.ReadToDescendant("Order"))
            {
                Order = reader.ReadElementContentAsInt();
            }
            if (reader.Name == "Id" || reader.ReadToNextSibling("Id"))
            {
                Id = reader.ReadElementContentAsString();
            }
            if (reader.Name == "Name" || reader.ReadToNextSibling("Name"))
            {
                Name = reader.ReadElementContentAsString();
            }
            if (reader.Name == "Text" || reader.ReadToNextSibling("Text"))
            {
                Text = reader.ReadElementContentAsString();
            }
            if (reader.Name == "Memo" || reader.ReadToNextSibling("Memo"))
            {
                Memo = reader.ReadElementContentAsString();
            }
            return true;
        }
        void IFlickrParsable.Load(XmlReader reader)
        {
            if (reader.LocalName != "referrer")
                UtilityMethods.CheckParsingException(reader);

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                    case "url":
                        Url = reader.Value;
                        break;
                    case "searchterm":
                        SearchTerm = reader.Value;
                        break;
                    case "views":
                        Views = int.Parse(reader.Value, NumberFormatInfo.InvariantInfo);
                        break;
                    default:
                        UtilityMethods.CheckParsingException(reader);
                        break;
                }
            }

            reader.Skip();
        }
Example #14
0
 public OrnamentsForm(XmlReader r, PaletteForm paletteForm, IPaletteFormsHostForm acForm, FormStateFunctions fsf)
 {
     _isLoading = true;
     InitializeOrnamentSettingsForm(r, paletteForm, acForm, fsf);
     _fsf.SetSettingsAreSaved(this, M.HasError(_allTextBoxes), ConfirmButton, RevertToSavedButton);
     _isLoading = false;
 }
		/// <summary>
		/// Creates a new PolicyIdReference using the XmlReader instance provided.
		/// </summary>
		/// <param name="reader">The XmlReader positioned at the PolicyIdReference element.</param>
		/// <param name="schemaVersion">The version of the schema that was used to validate.</param>
		public PolicyIdReferenceElementReadWrite( XmlReader reader, XacmlVersion schemaVersion )
			: base( XacmlSchema.Policy, schemaVersion )
		{
            if (reader == null) throw new ArgumentNullException("reader");
			if( reader.LocalName == PolicySchema1.PolicyIdReferenceElement.PolicyIdReference && 
				ValidateSchema( reader, schemaVersion ) )
			{
				if( reader.HasAttributes )
				{
					// Load all the attributes
					while( reader.MoveToNextAttribute() )
					{
						if( reader.LocalName == PolicyReferenceElement.Version )
						{
							_version = reader.GetAttribute( PolicyReferenceElement.Version );
						}
						else if( reader.LocalName == PolicyReferenceElement.EarliestVersion )
						{
							_earliestVersion = reader.GetAttribute( PolicyReferenceElement.EarliestVersion );
						}
						else if( reader.LocalName == PolicyReferenceElement.LatestVersion )
						{
							_latestVersion = reader.GetAttribute( PolicyReferenceElement.LatestVersion );
						}					
					}
					reader.MoveToElement();
				}
				_policyIdReference = reader.ReadElementString();
			}
			else
			{
				throw new Exception( Resource.ResourceManager[ Resource.MessageKey.exc_invalid_node_name, reader.LocalName ] );
			}
		}
Example #16
0
        public void ReadXml(XmlReader reader)
        {
            var s = reader.ReadOuterXml();
            var x = XDocument.Parse(s);
            if (x.Root == null) return;

            foreach (var e in x.Root.Elements())
            {
                var name = e.Name.ToString();
                switch (name)
                {
                    case "List":
                        foreach (var ee in e.Elements())
                            _list.Add(Util.DeSerialize<OnlineRegPersonModel>(ee.ToString()));
                        break;
                    case "History":
                        foreach (var ee in e.Elements())
                            _history.Add(ee.Value);
                        break;
                    default:
                        Util.SetPropertyFromText(this, name, e.Value);
                        break;
                }
            }
        }
Example #17
0
		void DoSetUp(XmlReader reader, string endElement)
		{
			Stack<ICondition> conditionStack = new Stack<ICondition>();
			List<Codon> innerCodons = new List<Codon>();
			while (reader.Read()) {
				switch (reader.NodeType) {
					case XmlNodeType.EndElement:
						if (reader.LocalName == "Condition" || reader.LocalName == "ComplexCondition") {
							conditionStack.Pop();
						} else if (reader.LocalName == endElement) {
							if (innerCodons.Count > 0)
								this.codons.Add(innerCodons);
							return;
						}
						break;
					case XmlNodeType.Element:
						string elementName = reader.LocalName;
						if (elementName == "Condition") {
							conditionStack.Push(Condition.Read(reader));
						} else if (elementName == "ComplexCondition") {
							conditionStack.Push(Condition.ReadComplexCondition(reader));
						} else {
							Codon newCodon = new Codon(this.AddIn, elementName, Properties.ReadFromAttributes(reader), conditionStack.ToArray());
							innerCodons.Add(newCodon);
							if (!reader.IsEmptyElement) {
								ExtensionPath subPath = this.AddIn.GetExtensionPath(this.Name + "/" + newCodon.Id);
								subPath.DoSetUp(reader, elementName);
							}
						}
						break;
				}
			}
			if (innerCodons.Count > 0)
				this.codons.Add(innerCodons);
		}
 public static XmlNode[] ReadNodes(XmlReader xmlReader)
 {
     if (xmlReader == null)
         throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("xmlReader");
     XmlDocument doc = new XmlDocument();
     List<XmlNode> nodeList = new List<XmlNode>();
     if (xmlReader.MoveToFirstAttribute())
     {
         do
         {
             if (IsValidAttribute(xmlReader))
             {
                 XmlNode node = doc.ReadNode(xmlReader);
                 if (node == null)
                     throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.GetString(SR.UnexpectedEndOfFile)));
                 nodeList.Add(node);
             }
         } while (xmlReader.MoveToNextAttribute());
     }
     xmlReader.MoveToElement();
     if (!xmlReader.IsEmptyElement)
     {
         int startDepth = xmlReader.Depth;
         xmlReader.Read();
         while (xmlReader.Depth > startDepth && xmlReader.NodeType != XmlNodeType.EndElement)
         {
             XmlNode node = doc.ReadNode(xmlReader);
             if (node == null)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.GetString(SR.UnexpectedEndOfFile)));
             nodeList.Add(node);
         }
     }
     return nodeList.ToArray();
 }
Example #19
0
File: User.cs Project: liquidboy/X
        void IFlickrParsable.Load(XmlReader reader)
        {
            if (reader.LocalName != "user")
                UtilityMethods.CheckParsingException(reader);

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                    case "nsid":
                    case "id":
                        UserId = reader.Value;
                        break;
                    case "username":
                        UserName = reader.Value;
                        break;
                    case "fullname":
                        FullName = reader.Value;
                        break;
                    default:
                        UtilityMethods.CheckParsingException(reader);
                        break;
                }
            }

            reader.Read();

            if (reader.NodeType != XmlNodeType.EndElement)
            {
                UserName = reader.ReadElementContentAsString();
                reader.Skip();
            }
        }
 private static bool IsValidAttribute(XmlReader xmlReader)
 {
     return xmlReader.NamespaceURI != Globals.SerializationNamespace &&
                            xmlReader.NamespaceURI != Globals.SchemaInstanceNamespace &&
                            xmlReader.Prefix != "xmlns" &&
                            xmlReader.LocalName != "xmlns";
 }
Example #21
0
 /// <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 override void ReadXml(XmlReader reader)
 {
     reader.MoveToContent();
     reader.ReadStartElement();
     Descriptor = Xml.Read<Descriptor>(reader);
     Root = Xml.Read<Measure>(reader);
 }
        public void ReadXml(XmlReader reader)
        {
            //This method is not implemented because
            //this class is never deserialized by the client

            throw new NotImplementedException();
        }
        protected override bool HandleAttribute(XmlReader reader)
        {
            if (base.HandleAttribute(reader))
            {
                return true;
            }
            else if (CanHandleAttribute(reader, XmlConstants.Relationship))
            {
                HandleAssociationAttribute(reader);
                return true;
            }
            else if (CanHandleAttribute(reader, XmlConstants.FromRole))
            {
                HandleFromRoleAttribute(reader);
                return true;
            }
            else if (CanHandleAttribute(reader, XmlConstants.ToRole))
            {
                HandleToRoleAttribute(reader);
                return true;
            }
            else if (CanHandleAttribute(reader, XmlConstants.ContainsTarget))
            {
                // EF does not support this EDM 3.0 attribute, so ignore it.
                return true;
            }

            return false;
        }
Example #24
0
		/// <summary>
		/// Create <see cref="NewFolding"/>s for the specified document.
		/// </summary>
		public IEnumerable<NewFolding> CreateNewFoldings(TextDocument document, XmlReader reader, out int firstErrorOffset)
		{
			Stack<XmlFoldStart> stack = new Stack<XmlFoldStart>();
			List<NewFolding> foldMarkers = new List<NewFolding>();
			try {
				while (reader.Read()) {
					switch (reader.NodeType) {
						case XmlNodeType.Element:
							if (!reader.IsEmptyElement) {
								XmlFoldStart newFoldStart = CreateElementFoldStart(document, reader);
								stack.Push(newFoldStart);
							}
							break;
							
						case XmlNodeType.EndElement:
							XmlFoldStart foldStart = stack.Pop();
							CreateElementFold(document, foldMarkers, reader, foldStart);
							break;
							
						case XmlNodeType.Comment:
							CreateCommentFold(document, foldMarkers, reader);
							break;
					}
				}
				firstErrorOffset = -1;
			} catch (XmlException ex) {
				// ignore errors
				firstErrorOffset = document.GetOffset(ex.LineNumber, ex.LinePosition);
			}
			foldMarkers.Sort((a,b) => a.StartOffset.CompareTo(b.StartOffset));
			return foldMarkers;
		}
Example #25
0
        public override void ReadXml(XmlReader reader)
        {
            if (CheckEmptyNode(reader, "DataURL", Namespace))
                return;

            while (!reader.EOF)
            {
                if (reader.IsStartElement())
                {
                    switch (reader.LocalName)
                    {
                        case "Format":
                            Format = reader.ReadElementContentAsString();
                            break;
                        case "OnlineResource":
                            OnlineResource = new OnlineResource();
                            OnlineResource.ReadXml(reader);
                            break;
                        default:
                            reader.Skip();
                            break;
                    }
                }
                else
                {
                    reader.Read();
                }
            }
        }
Example #26
0
 public void RetrievePartyMessage(XmlReader reader, Party party)
 {
     while (reader.Name != "Message" && reader.Read())
     {
     }
     party.Message = reader.ReadElementContentAsString();
 }
        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);
        }
Example #28
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;
        }
        protected override bool HandleAttribute(XmlReader reader)
        {
            if (base.HandleAttribute(reader))
            {
                return true;
            }
            else if (CanHandleAttribute(reader, XmlConstants.MinimumAttribute))
            {
                HandleMinimumAttribute(reader);
                return true;
            }
            else if (CanHandleAttribute(reader, XmlConstants.MaximumAttribute))
            {
                HandleMaximumAttribute(reader);
                return true;
            }
            else if (CanHandleAttribute(reader, XmlConstants.DefaultValueAttribute))
            {
                HandleDefaultAttribute(reader);
                return true;
            }
            else if (CanHandleAttribute(reader, XmlConstants.ConstantAttribute))
            {
                HandleConstantAttribute(reader);
                return true;
            }

            return false;
        }
Example #30
0
 public Reflexive(Map Map, string Label, int Count,int Base, int Offset, int Size,XmlReader Reader)
 {
     this.Map = Map;
     this.Label = Label;
     this.Count = Count;
     this.Base = Base;
     this.Offset = Offset;
     this.ChunkSize = Size;
     this.Reader = Reader;
     if (Base != 0)
     {
         Map.Reader.BaseStream.Position = ((Offset + Base) - Map.Index.SecondaryMagic) + 4;
         this.RawTranslation = Map.Reader.ReadInt32();
     }
     else
         this.RawTranslation = 0;
     InitializeComponent();
     for (int i = 0; i < Count; i++)
         comboBox1.Items.Add(i.ToString());
     label1.Text = Label;
     ReadControls();
     if (Count == 0)
     {
         button1.Text = "+";
         panel1.Hide();
         hidden = true;
     }
     else
     {
         comboBox1.SelectedIndex = 0;
         this.Height += panel1.Height;
     }
 }