public override void ReadXml(System.Xml.XmlReader reader) { // Attributes while (reader.MoveToNextAttribute()) { switch (reader.Name) { case XmlAttribute_Name: this.Name = reader.Value; break; case XmlAttribute_Columns: this.Columns = reader.Value.Split(new string[] { DatabaseHelper.Separator }, StringSplitOptions.RemoveEmptyEntries); break; } } reader.MoveToContent(); // Element if (!reader.IsEmptyElement) { reader.ReadStartElement(); reader.ReadEndElement(); } else { reader.Read(); } }
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(); }
/// <summary> /// Function to call when deserializing this object from XML /// </summary> /// <param name="reader">The xml reader</param> public virtual void ReadXml(System.Xml.XmlReader reader) { #region read the size of the matrix and assign storage int rows = Int32.Parse(reader.GetAttribute("Rows")); int cols = Int32.Parse(reader.GetAttribute("Cols")); int numberOfChannels = Int32.Parse(reader.GetAttribute("NumberOfChannels")); AllocateData(rows, cols, numberOfChannels); #endregion SerializationCompressionRatio = Int32.Parse(reader.GetAttribute("CompressionRatio")); #region decode the data from Xml and assign the value to the matrix reader.MoveToContent(); reader.ReadToFollowing("Bytes"); int size = _sizeOfElement * ManagedArray.Length; if (SerializationCompressionRatio == 0) { Byte[] bytes = new Byte[size]; reader.ReadElementContentAsBase64(bytes, 0, bytes.Length); Bytes = bytes; } else { int extraHeaderBytes = 20000; Byte[] bytes = new Byte[size + extraHeaderBytes]; int countOfBytesRead = reader.ReadElementContentAsBase64(bytes, 0, bytes.Length); Array.Resize <Byte>(ref bytes, countOfBytesRead); Bytes = bytes; } //reader.MoveToElement(); #endregion }
public void ReadXml(System.Xml.XmlReader reader) { XmlSerializer keySerializer = new XmlSerializer(typeof(string)); XmlSerializer valueSerializer = new XmlSerializer(typeof(string)); bool wasEmpty = reader.IsEmptyElement; reader.Read(); if (wasEmpty) { return; } while (reader.NodeType != System.Xml.XmlNodeType.EndElement) { reader.ReadStartElement("item"); reader.ReadStartElement("key"); string key = (string)keySerializer.Deserialize(reader); reader.ReadEndElement(); reader.ReadStartElement("value"); string value = (string)valueSerializer.Deserialize(reader); reader.ReadEndElement(); Color colorValue = ColorStringToColor(value); this.Add(key, colorValue); reader.ReadEndElement(); reader.MoveToContent(); } reader.ReadEndElement(); }
public string replaceKeys(XElement xsource, string xmlsource) { foreach (XElement xe in xsource.Elements("Replace")) { string varname = xe.Attribute("Key").Value; string tovalue; if (xe.Attribute("Value") != null) { tovalue = xe.Attribute("Value").Value; } else { if (xe.Element("Value") == null) { throw new Exception("No {Value} attribute or element found for ReplaceKey: {\n" + xe.ToString() + "\n}"); } System.Xml.XmlReader xr = xe.Element("Value").CreateReader(); xr.MoveToContent(); tovalue = xr.ReadInnerXml(); } //Generalise key / value replacement (include $ and @@ notation) xmlsource = this.replaceVariables(xmlsource, varname, tovalue); //xmlsource = xmlsource.Replace("$"+varname, tovalue); } return(xmlsource); }
protected override void ReadXmlBase(System.Xml.XmlReader reader) { base.ReadXmlBase(reader); if (reader.LocalName == "accuracy") { // only set accuracy when the value is greater than -1 float accuracyValue = reader.ReadElementContentAsFloat("accuracy", RmXmlSerializer.OpenEhrNamespace); if (accuracyValue < unknownAccuracyValue) { throw new ApplicationException("accuracy must be greater or equal to -1"); } this.accuracy = accuracyValue; } if (reader.LocalName == "accuracy_is_percent") { this.accuracyIsPercent = reader.ReadElementContentAsBoolean("accuracy_is_percent", RmXmlSerializer.OpenEhrNamespace); this.accuracyIsPercentSet = true; } if (!reader.IsStartElement()) { reader.ReadEndElement(); reader.MoveToContent(); } }
void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { if (reader.IsEmptyElement) { return; } if (!reader.Read()) { throw new System.Xml.XmlException("Error in Deserialization of Dictionary"); } while (reader.NodeType != System.Xml.XmlNodeType.EndElement) { reader.ReadStartElement(ItemNodeName); reader.ReadStartElement(KeyNodeName); TKey key = (TKey)KeySerializer.Deserialize(reader); reader.ReadEndElement(); reader.ReadStartElement(ValueNodeName); TVal value = (TVal)ValueSerializer.Deserialize(reader); reader.ReadEndElement(); reader.ReadEndElement(); Add(key, value); reader.MoveToContent(); } 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"); this.Add( GetObject <TKey>(reader, keySerializer, "key"), GetObject <TValue>(reader, valueSerializer, "value")); reader.ReadEndElement(); reader.MoveToContent(); } reader.ReadEndElement(); }
public LayoutInfo ConvertStringToLayoutInfo(string layoutInfo, Store store) { LayoutInfo lInfo = null; Microsoft.VisualStudio.Modeling.SerializationResult serializationResult = new Microsoft.VisualStudio.Modeling.SerializationResult(); DomainXmlSerializerDirectory directory = this.GetDirectory(store); System.Text.Encoding encoding = System.Text.Encoding.GetEncoding("ISO-8859-1"); Microsoft.VisualStudio.Modeling.SerializationContext serializationContext = new SerializationContext(directory, "", serializationResult); this.InitializeSerializationContext(store.DefaultPartition, serializationContext, false); DomainClassXmlSerializer rootSerializer = directory.GetSerializer(LayoutInfo.DomainClassId); using (System.Xml.XmlReader reader = System.Xml.XmlReader.Create(new System.IO.StringReader(layoutInfo))) { reader.Read(); // Move to the first node - will be the XmlDeclaration if there is one. serializationResult.Encoding = encoding; reader.MoveToContent(); lInfo = rootSerializer.TryCreateInstance(serializationContext, reader, store.DefaultPartition) as LayoutInfo; rootSerializer.Read(serializationContext, lInfo, reader); } return(lInfo); }
public void ReadXml(System.Xml.XmlReader reader) { var keySerializer = new XmlSerializer(typeof(string)); var valueSerializer = new XmlSerializer(typeof(string)); var wasEmpty = reader.IsEmptyElement; reader.Read(); if (wasEmpty) { return; } while (reader.NodeType != System.Xml.XmlNodeType.EndElement) { reader.ReadStartElement("item"); reader.ReadStartElement("key"); var key = (string)keySerializer.Deserialize(reader); reader.ReadEndElement(); reader.ReadStartElement("value"); var value = (string)valueSerializer.Deserialize(reader); reader.ReadEndElement(); Add(key, value); reader.ReadEndElement(); reader.MoveToContent(); } reader.ReadEndElement(); }
public void ReadXml(System.Xml.XmlReader reader) { // Attributes while (reader.MoveToNextAttribute()) { } reader.MoveToContent(); // Elements if (!reader.IsEmptyElement) { // Read first element reader.ReadStartElement(); while (reader.NodeType == System.Xml.XmlNodeType.Element) { switch (reader.Name) { case TableModel.XmlElement_Tag: TableModel table = new TableModel(); table.ReadXml(reader); this.Add(table); break; default: throw new InvalidOperationException(reader.Name); } } reader.ReadEndElement(); } else { reader.Read(); } }
public void ReadXml(System.Xml.XmlReader reader) { // Attributes while (reader.MoveToNextAttribute()) { switch (reader.Name) { case XmlAttribute_ColumnName: this.ColumnName = reader.Value; break; case XmlAttribute_Seed: this.Seed = Convert.ToInt64(reader.Value); break; case XmlAttribute_Increment: this.Increment = Convert.ToInt64(reader.Value); break; } } reader.MoveToContent(); // Elements if (!reader.IsEmptyElement) { reader.ReadStartElement(); reader.ReadEndElement(); } else { reader.Read(); } }
public void ReadXml(System.Xml.XmlReader r) { int depth = r.Depth; r.ReadStartElement(); bool hasRead = false; while (r.Depth > depth) { if (r.IsStartElement()) { XmlSerializer ser = XmlTypeAssociator <T> .GetSerializer(r); XMLSerializeManager.Report("Deserializing: " + r.Name); Add((T)ser.Deserialize(r)); r.MoveToContent(); } else { r.Read(); } hasRead = true; } if (hasRead) { r.ReadEndElement(); } }
public virtual void ReadXml(System.Xml.XmlReader reader) { reader.MoveToContent(); if (reader.IsEmptyElement) { reader.Read(); ComputeVisibility(); return; } string localName = reader.LocalName; reader.Read(); while (true) { if (reader.LocalName == localName && reader.NodeType == System.Xml.XmlNodeType.EndElement) { break; } XmlSerializer serializer = null; switch (reader.LocalName) { case "LayoutAnchorablePaneGroup": serializer = XmlSerializerCache.Get <LayoutAnchorablePaneGroup>(); break; case "LayoutAnchorablePane": serializer = XmlSerializerCache.Get <LayoutAnchorablePane>(); break; case "LayoutAnchorable": serializer = XmlSerializerCache.Get <LayoutAnchorable>(); break; case "LayoutDocumentPaneGroup": serializer = XmlSerializerCache.Get <LayoutDocumentPaneGroup>(); break; case "LayoutDocumentPane": serializer = XmlSerializerCache.Get <LayoutDocumentPane>(); break; case "LayoutDocument": serializer = XmlSerializerCache.Get <LayoutDocument>(); break; case "LayoutAnchorGroup": serializer = XmlSerializerCache.Get <LayoutAnchorGroup>(); break; case "LayoutPanel": serializer = XmlSerializerCache.Get <LayoutPanel>(); break; } Children.Add((T)serializer.Deserialize(reader)); } 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) { var keySerializer = TraceLab.Core.Serialization.XmlSerializerFactory.GetSerializer(typeof(TKey), null); var valueSerializer = TraceLab.Core.Serialization.XmlSerializerFactory.GetSerializer(typeof(TValue), null); 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 void ReadXml(System.Xml.XmlReader reader) { // Attributes while (reader.MoveToNextAttribute()) { } reader.MoveToContent(); // Elements if (!reader.IsEmptyElement) { reader.ReadStartElement(); while (reader.NodeType == System.Xml.XmlNodeType.Element) { switch (reader.Name) { case ColumnSortModel.XmlElement_Tag: ColumnSortModel columnSort = new ColumnSortModel(); columnSort.ReadXml(reader); this.Add(columnSort); break; default: throw new InvalidOperationException(reader.Name); } } reader.ReadEndElement(); } else { reader.Read(); } }
public void ReadXml(System.Xml.XmlReader reader) { //AuthDate = null; Omschrijving = null; KortingBedrag = 0.0; reader.MoveToContent(); var datestring = reader.GetAttribute("AuthDate"); DateTime outdatetime; DateTime.TryParse(datestring, out outdatetime); if (outdatetime != null) { AuthDate = outdatetime; } //var date = reader.ReadElementContentAsDateTime(); //AuthDate = date; Omschrijving = reader.GetAttribute("Omschrijving"); double kn; var kortstring = reader.GetAttribute("KortingBedrag"); kortstring = kortstring.Replace(",", System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator); kortstring = kortstring.Replace(".", System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator); double.TryParse(kortstring, out kn); if (kn != null) { KortingBedrag = kn; } }
public void ReadXml(System.Xml.XmlReader reader) { XmlSerializer tSerializer = new XmlSerializer(typeof(T)); bool wasEmpty = reader.IsEmptyElement; reader.Read(); if (wasEmpty) { return; } while (reader.NodeType != System.Xml.XmlNodeType.EndElement) { T t = (T)tSerializer.Deserialize(reader); this.Add(t); reader.MoveToContent(); } reader.ReadEndElement(); this.Sort(); }
public void ReadXml(System.Xml.XmlReader reader) { // Attributes while (reader.MoveToNextAttribute()) { switch (reader.Name) { case XmlAttribute_Column: this.Column = reader.Value; break; case XmlAttribute_Sort: this.Sort = (SortOrder)Enum.Parse(typeof(SortOrder), reader.Value); break; } } reader.MoveToContent(); // Elements if (!reader.IsEmptyElement) { reader.ReadStartElement(); reader.ReadEndElement(); } else { reader.Read(); } }
internal void ReadXml(System.Xml.XmlReader reader) { Check.Require(!reader.IsEmptyElement, reader.LocalName + " element must not be empty."); reader.ReadStartElement(); reader.MoveToContent(); this.ReadXmlBase(reader); DesignByContract.Check.Assert(reader.NodeType == System.Xml.XmlNodeType.EndElement, "Expected endElement after calling ReadXml"); reader.ReadEndElement(); reader.MoveToContent(); this.CheckInvariants(); }
void IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { reader.MoveToContent(); int count = Convert.ToInt32(reader.GetAttribute("Count")); if (count == Count) { for (int i = 0; i < count; i++) { reader.ReadStartElement("Column"); string attr = reader.GetAttribute("DisplayIndex"); if (!string.IsNullOrEmpty(attr)) { this[i].DisplayIndex = Convert.ToInt32(attr); } attr = reader.GetAttribute("Width"); if (!string.IsNullOrEmpty(attr)) { this[i].Width = Convert.ToInt32(attr); } attr = reader.GetAttribute("SortOrder"); if (!string.IsNullOrEmpty(attr)) { this[i].SortOrder = (SortOrder)Enum.Parse(typeof(SortOrder), attr); } reader.ReadEndElement(); } } }
void IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { reader.ReadStartElement("Triggers", TaskDefinition.tns); while (reader.MoveToContent() == System.Xml.XmlNodeType.Element) { switch (reader.LocalName) { case "BootTrigger": XmlSerializationHelper.ReadObject(reader, this.AddNew(TaskTriggerType.Boot)); break; case "IdleTrigger": XmlSerializationHelper.ReadObject(reader, this.AddNew(TaskTriggerType.Idle)); break; case "TimeTrigger": XmlSerializationHelper.ReadObject(reader, this.AddNew(TaskTriggerType.Time)); break; case "LogonTrigger": XmlSerializationHelper.ReadObject(reader, this.AddNew(TaskTriggerType.Logon)); break; case "CalendarTrigger": this.Add(CalendarTrigger.GetTriggerFromXml(reader)); break; default: reader.Skip(); break; } } reader.ReadEndElement(); }
private T DeserializeSimpleValueElement <T>(System.Xml.XmlReader reader) { if (reader.NodeType != System.Xml.XmlNodeType.Element) { throw new System.Configuration.ConfigurationErrorsException("Expected Element node type", reader); } string ElemName = reader.Name; string addValue = reader.GetAttribute("value"); if (addValue == null) { throw new System.Configuration.ConfigurationErrorsException("Value not found for SimpleValueElement '" + ElemName + "' inside element", reader); } T res = Parse <T>(addValue); if (reader.IsEmptyElement) { reader.Read(); } else { reader.Read(); if (reader.MoveToContent() != System.Xml.XmlNodeType.EndElement) { throw new System.Configuration.ConfigurationErrorsException("SimpleValueElement '" + ElemName + "' can't contains any other elements", reader); } reader.ReadEndElement(); } return(res); }
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) { bool wasEmpty = reader.IsEmptyElement; reader.Read(); if (wasEmpty) { return; } while (reader.NodeType != System.Xml.XmlNodeType.EndElement) { reader.ReadStartElement("Item"); reader.ReadStartElement("Key"); TKey k = (TKey)ks.Deserialize(reader); reader.ReadEndElement(); reader.ReadStartElement("Value"); TValue v = (TValue)vs.Deserialize(reader); reader.ReadEndElement(); Add(k, v); reader.ReadEndElement(); reader.MoveToContent(); } reader.ReadEndElement(); }
public XMLPlainLevelEnumerator(System.IO.Stream s, int LevelToFind) { this.LevelToFind = LevelToFind; reader = System.Xml.XmlReader.Create(s); reader.MoveToContent(); iCurrentLevel = 0; }
public virtual void ReadXml(System.Xml.XmlReader reader) { var valueSerializer = new XmlSerializer(typeof(T)); bool wasEmpty = reader.IsEmptyElement; reader.Read(); if (wasEmpty) { return; } while (reader.NodeType != System.Xml.XmlNodeType.EndElement) { reader.ReadStartElement("listItem"); T value = (T)valueSerializer.Deserialize(reader); this.Add(value); reader.ReadEndElement(); reader.MoveToContent(); } reader.ReadEndElement(); }
public SubBatchArray(XElement SubBatch) { if (SubBatch.Attribute("Tag") != null) { this.name = SubBatch.Attribute("Tag").Value; } foreach (XElement vs in SubBatch.Elements("ValueSet")) { string batch_id = "unknown"; if (vs.Attribute("Tag") != null) { batch_id = vs.Attribute("Tag").Value; } this.createNewSet(); this.addEntry(this.name, batch_id); foreach (XElement rxe in vs.Elements("Replace")) { if (rxe.Attribute("Value") != null) { //value assignment via attribute this.addEntry(rxe.Attribute("Key").Value, rxe.Attribute("Value").Value); } else { //value assignment via element System.Xml.XmlReader xr = rxe.Element("Value").CreateReader(); xr.MoveToContent(); // PERFORMING OUTPUT MOVES READER POINTER Console.WriteLine("Assignment via element "+rxe.Attribute("Key")+" ="+xr.ReadInnerXml()); this.addEntry(rxe.Attribute("Key").Value, xr.ReadInnerXml()); } } } }
protected virtual void ReadXmlBase(System.Xml.XmlReader reader) { Check.Assert(reader.LocalName == "contribution", "Expected LocalName is 'contribution' rather than " + reader.LocalName); string contributionType = reader.GetAttribute("type", RmXmlSerializer.XsiNamespace); if (contributionType != null) { this.contribution = OpenEhr.RM.Support.Identification.ObjectRef.GetObjectRefByType(contributionType); } else { this.contribution = new ObjectRef(); } this.contribution.ReadXml(reader); Check.Assert(reader.LocalName == "commit_audit", "Expected LocalName is 'commit_audit' rather than " + reader.LocalName); this.commitAudit = new OpenEhr.RM.Common.Generic.AuditDetails(); this.commitAudit.ReadXml(reader); if (reader.LocalName == "signature") { this.signature = reader.ReadElementString("signature", RmXmlSerializer.OpenEhrNamespace); } reader.MoveToContent(); }
public void ReadXml(System.Xml.XmlReader reader) { var keySerializer = new XmlSerializer(typeof(TKey)); var valueSerializer = new XmlSerializer(typeof(TValue)); var wasEmpty = reader.IsEmptyElement; reader.Read(); if (wasEmpty) { return; } while (reader.NodeType != System.Xml.XmlNodeType.EndElement) { reader.ReadStartElement(ItemElement); reader.ReadStartElement(KeyElement); var key = (TKey)keySerializer.Deserialize(reader); reader.ReadEndElement(); reader.ReadStartElement(ValueElement); var value = (TValue)valueSerializer.Deserialize(reader); reader.ReadEndElement(); Add(key, value); reader.ReadEndElement(); reader.MoveToContent(); } reader.ReadEndElement(); }
public void ReadXml(System.Xml.XmlReader reader) { bool wasEmpty = reader.IsEmptyElement; reader.Read(); if (wasEmpty) { return; } while (reader.NodeType != System.Xml.XmlNodeType.EndElement) { if (reader.IsEmptyElement) { reader.Read(); } else { string key = reader.GetAttribute("key"); reader.ReadStartElement("item"); string value = reader.ReadContentAsString(); reader.ReadEndElement(); this.Add(key, value); reader.MoveToContent(); } } reader.ReadEndElement(); }