void IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { this.Clear(); var serializer = new XmlSerializer(typeof(List <Entry>)); reader.Read(); var list = (List <Entry>)serializer.Deserialize(reader); foreach (var entry in list) { this.Add(entry.Key, entry.Value); } reader.ReadEndElement(); }
void IFlickrParsable.Load(System.Xml.XmlReader reader) { Tags = new Collection <string>(); while (reader.MoveToNextAttribute()) { switch (reader.LocalName) { case "total": TotalTags = reader.ReadContentAsInt(); break; } } reader.Read(); while (reader.LocalName == "tag") { Tags.Add(reader.ReadElementContentAsString()); } reader.Read(); }
public void ReadXml(System.Xml.XmlReader reader) { // Attributes while (reader.MoveToNextAttribute()) { switch (reader.Name) { case XmlAttribute_Schema: this.Schema = reader.Value; break; case XmlAttribute_Name: this.Name = reader.Value; break; } } reader.MoveToContent(); // Element if (!reader.IsEmptyElement) { reader.ReadStartElement(); while (reader.NodeType == System.Xml.XmlNodeType.Element) { switch (reader.Name) { case ColumnModelCollection.XmlElement_Tag: this.Columns.ReadXml(reader); break; case ConstraintModelCollection.XmlElement_Tag: this.Constraints.ReadXml(reader); break; case IndexModelCollection.XmlElement_Tag: this.Indexes.ReadXml(reader); break; default: throw new InvalidOperationException(reader.Name); } } reader.ReadEndElement(); } else { reader.Read(); } }
//! noted the response must be jsonformat {"key":"value"} void ReadyRead(System.Xml.XmlReader JSONBuffer) { JSONBuffer.MoveToContent(); while (JSONBuffer.Read()) { if (JSONBuffer.IsStartElement("details")) { JSONBuffer.Read(); response.details = JSONBuffer.Value.Length >= 0 ? JSONBuffer.Value.Split(',') : new string[] { }; } if (JSONBuffer.IsStartElement("success")) { JSONBuffer.Read(); bool.TryParse(JSONBuffer.Value.Trim(), out response.status); } if (JSONBuffer.IsStartElement("message")) { JSONBuffer.Read(); response.message = JSONBuffer.Value.Trim(); } } }
protected override bool ReadAnInnerElement(System.Xml.XmlReader reader, XmlReaderContext context) { bool b; if (this.IsElementMatch(XmlHelper.LeftOperand, reader, context) && !reader.IsEmptyElement && reader.Read()) { this.Left = this.ReadNextInnerClause(XmlHelper.LeftOperand, reader, context); b = reader.Read(); } else if (this.IsElementMatch(XmlHelper.RightOperand, reader, context) && !reader.IsEmptyElement && reader.Read()) { this.Right = this.ReadNextInnerClause(XmlHelper.RightOperand, reader, context); b = reader.Read(); } else { b = base.ReadAnInnerElement(reader, context); } return(b); }
protected override bool ReadAnInnerElement(System.Xml.XmlReader reader, XmlReaderContext context) { if (IsElementMatch(XmlHelper.ColumnList, reader, context)) { reader.Read(); DBColumnList all = new DBColumnList(); all.ReadXml(XmlHelper.ColumnList, reader, context); this.Columns = all; return(true); } else if (IsElementMatch(XmlHelper.ConstraintList, reader, context)) { reader.Read(); DBConstraintList list = new DBConstraintList(); list.ReadXml(XmlHelper.ConstraintList, reader, context); this.ConstraintList = list; return(true); } else { return(base.ReadAnInnerElement(reader, context)); } }
/// <summary> /// Reads a ColumnConfig from an XML reader /// </summary> /// <param name="reader">xml reader</param> public void ReadXml(System.Xml.XmlReader reader) { reader.MoveToContent(); try { _insert = (reader.GetAttribute("Insert") == "True"); _update = (reader.GetAttribute("Update") == "True"); _key = (reader.GetAttribute("Key") == "True"); _inputColumnName = reader.GetAttribute("InputColumnName"); _outputColumnName = reader.GetAttribute("OutputColumnName"); _default = reader.GetAttribute("Default"); _function = reader.GetAttribute("Function"); _dataTypeInput = reader.GetAttribute("DataTypeInput"); _dataTypeOutput = reader.GetAttribute("DataTypeOutput"); _dataTypeOutputNet = reader.GetAttribute("DataTypeOutputNet"); _isOutputPrimaryKey = (reader.GetAttribute("IsOutputPrimaryKey") == "True"); _allowOutputDbNull = (reader.GetAttribute("AllowOutputDbNull") == "True"); _isOutputAutoId = (reader.GetAttribute("IsOutputAutoId") == "True"); _inputColumnId = Int32.Parse(reader.GetAttribute("InputColumnId")); _customId = reader.GetAttribute("CustomId"); IsScdColumn = reader.GetAttribute("IsScdColumn") == "True"; ScdTable = reader.GetAttribute("ScdTable"); IsScdValidFrom = reader.GetAttribute("IsScdValidFrom") == "True"; try { ScdTimeStampGranularity = (ScdTimeStampGranularityType)Enum.Parse(typeof(ScdTimeStampGranularityType), reader.GetAttribute("ScdTimeStampGranularity")); } catch (Exception) { ScdTimeStampGranularity = IsScdValidFrom ? ScdTimeStampGranularityType.YYYYMMDD : ScdTimeStampGranularityType.None; } reader.Read(); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.ToString()); throw; } }
/// <summary> /// /// </summary> /// <param name="reader"></param> public override void ReadXml(System.Xml.XmlReader reader) { reader.Read(); while (!reader.EOF) { if (reader.IsEmptyElement && !reader.HasAttributes) { reader.Read(); continue; } switch (reader.Name) { case RedmineKeys.ID: Id = reader.ReadElementContentAsInt(); break; case RedmineKeys.NAME: Name = reader.ReadElementContentAsString(); break; case RedmineKeys.PERMISSIONS: Permissions = reader.ReadElementContentAsCollection <Permission>(); break; default: reader.Read(); break; } } }
public static object ExecuteXMLScalar(string procedureName, System.Data.SqlClient.SqlParameter[] parameters) { string connString = ConnectionString; object retVal = null; SqlConnection conn = null; TransactionOptions option = new TransactionOptions(); option.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted; option.Timeout = new TimeSpan(0, 2, 0); try { using (TransactionScope trn = new TransactionScope(TransactionScopeOption.Required, option)) { using (conn = new SqlConnection(connString)) { conn.Open(); System.Data.SqlClient.SqlCommand sc = new System.Data.SqlClient.SqlCommand(procedureName, conn); sc.CommandType = CommandType.StoredProcedure; sc.Parameters.AddRange(parameters); System.Xml.XmlReader xr = sc.ExecuteXmlReader(); if (xr.Read()) { retVal = xr.ReadOuterXml(); } sc.Parameters.Clear(); } trn.Complete(); return(retVal); } } catch (Exception ex) { throw ex; } finally { if (conn != null && conn.State != ConnectionState.Broken && conn.State != ConnectionState.Closed) { conn.Close(); } } //return retVal; }
/// <summary> /// /// </summary> /// <param name="reader"></param> public void ReadXml(System.Xml.XmlReader reader) { Id = System.Convert.ToInt32(reader.GetAttribute(RedmineKeys.ID)); reader.Read(); while (!reader.EOF) { if (reader.IsEmptyElement && !reader.HasAttributes) { reader.Read(); continue; } switch (reader.Name) { case RedmineKeys.TRACKER: Tracker = new IdentifiableName(reader); break; case RedmineKeys.SUBJECT: Subject = reader.ReadElementContentAsString(); break; default: reader.Read(); break; } } }
void IFlickrParsable.Load(System.Xml.XmlReader reader) { if (reader.LocalName != "category") { UtilityMethods.CheckParsingException(reader); } while (reader.MoveToNextAttribute()) { switch (reader.LocalName) { case "name": CategoryName = reader.Value; break; case "path": Path = reader.Value; break; case "pathids": PathIds = reader.Value; break; default: UtilityMethods.CheckParsingException(reader); break; } } reader.Read(); while (reader.LocalName == "subcat" || reader.LocalName == "group") { if (reader.LocalName == "subcat") { Subcategory c = new Subcategory(); ((IFlickrParsable)c).Load(reader); Subcategories.Add(c); } else { Group s = new Group(); ((IFlickrParsable)s).Load(reader); Groups.Add(s); } } // Skip to next element (if any) reader.Skip(); }
/// <summary> /// Applies a protocol-buffer from an XmlReader to an existing instance. /// </summary> /// <typeparam name="T">The type being merged.</typeparam> /// <param name="instance">The existing instance to be modified (cannot be null).</param> /// <param name="reader">The XmlReader containing the data to apply to the instance (cannot be null).</param> public static void Merge <T>(System.Xml.XmlReader reader, T instance) where T : System.Xml.Serialization.IXmlSerializable { if (reader == null) { throw new ArgumentNullException("reader"); } if (instance == null) { throw new ArgumentNullException("instance"); } const int LEN = 4096; byte[] buffer = new byte[LEN]; int read; using (MemoryStream ms = new MemoryStream()) { int depth = reader.Depth; while (reader.Read() && reader.Depth > depth) { if (reader.NodeType == System.Xml.XmlNodeType.Text) { while ((read = reader.ReadContentAsBase64(buffer, 0, LEN)) > 0) { ms.Write(buffer, 0, read); } if (reader.Depth <= depth) { break; } } } ms.Position = 0; Serializer.Merge(ms, instance); } }
/// <summary> /// Reads any inner elements /// </summary> /// <param name="reader"></param> /// <param name="context"></param> /// <returns></returns> protected override bool ReadAnInnerElement(System.Xml.XmlReader reader, XmlReaderContext context) { if (IsElementMatch(XmlHelper.HintParameter, reader, context)) { reader.Read(); DBClause clause = this.ReadNextInnerClause(XmlHelper.HintParameter, reader, context); this.Clause = clause; return(true); } else { return(base.ReadAnInnerElement(reader, context)); } }
public override void ReadXml(System.Xml.XmlReader reader) { //only read attributes in GraphicObject IXmlReader implementation base.ReadXml(reader); using (System.Xml.XmlReader subTree = reader.ReadSubtree()) { subTree.Read(); //skip current node subTree.Read(); //read first child if (!subTree.IsStartElement()) { return; } Type t = Type.GetType("Crow." + subTree.Name); if (t == null) { Assembly a = Assembly.GetEntryAssembly(); foreach (Type expT in a.GetExportedTypes()) { if (expT.Name == subTree.Name) { t = expT; } } } GraphicObject go = (GraphicObject)Activator.CreateInstance(t); (go as IXmlSerializable).ReadXml(subTree); SetChild(go); subTree.Read();//closing tag } }
/// <summary> /// Generates an object from its XML representation. /// </summary> /// <param name="reader">The <see cref="XmlReader" /> stream from which the object is deserialized.</param> public void ReadXml(System.Xml.XmlReader reader) { int initialDepth = reader.Depth; while (reader.Read() && reader.Depth >= initialDepth) { while (reader.IsStartElement()) { switch (reader.Name) { case IdElementName: this.Id = reader.ReadString(); break; case SequenceNumberElementName: this.SequenceNumber = int.Parse(reader.ReadString()); break; case CommentElementName: this.Comment = reader.ReadString(); break; case PersonElementName: this.Person = Utility.Utilities.DeserializeXml <Person>(string.Format("<person>{0}</person>", reader.ReadInnerXml())); break; case TimestampElementName: this.Timestamp = long.Parse(reader.ReadString()); break; default: reader.Read(); break; } } } }
/// <summary> /// /// </summary> /// <param name="reader"></param> public override void ReadXml(System.Xml.XmlReader reader) { reader.Read(); while (!reader.EOF) { if (reader.IsEmptyElement && !reader.HasAttributes) { reader.Read(); continue; } switch (reader.Name) { case RedmineKeys.ID: Id = reader.ReadElementContentAsInt(); break; case RedmineKeys.NAME: Name = reader.ReadElementContentAsString(); break; case RedmineKeys.PROJECT: Project = new IdentifiableName(reader); break; case RedmineKeys.DESCRIPTION: Description = reader.ReadElementContentAsString(); break; case RedmineKeys.STATUS: Status = (VersionStatus)System.Enum.Parse(typeof(VersionStatus), reader.ReadElementContentAsString(), true); break; case RedmineKeys.DUE_DATE: DueDate = reader.ReadElementContentAsNullableDateTime(); break; case RedmineKeys.SHARING: Sharing = (VersionSharing)System.Enum.Parse(typeof(VersionSharing), reader.ReadElementContentAsString(), true); break; case RedmineKeys.CREATED_ON: CreatedOn = reader.ReadElementContentAsNullableDateTime(); break; case RedmineKeys.UPDATED_ON: UpdatedOn = reader.ReadElementContentAsNullableDateTime(); break; case RedmineKeys.CUSTOM_FIELDS: CustomFields = reader.ReadElementContentAsCollection <IssueCustomField>(); break; default: reader.Read(); break; } } }
void ITwentyThreeParsable.Load(System.Xml.XmlReader reader) { while (reader.MoveToNextAttribute()) { switch (reader.LocalName) { case "usage": Usage = reader.ReadContentAsInt(); break; case "predicate": PredicateName = reader.Value; break; case "namespace": NamespaceName = reader.Value; break; case "first_added": DateFirstAdded = UtilityMethods.UnixTimestampToDate(reader.Value); break; case "last_added": DateLastUsed = UtilityMethods.UnixTimestampToDate(reader.Value); break; } } reader.Read(); if (reader.NodeType == System.Xml.XmlNodeType.Text) { ValueText = reader.ReadContentAsString(); } reader.Read(); }
/// <summary> /// Reads Xml when the <see cref="ConsoleForm">ConsoleForm</see> is to be deserialized /// from a stream.</summary> /// <param name="reader">The stream from which the object will be deserialized.</param> void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { // Read the name of the form. _name = reader.GetAttribute("Name"); // Get the width and height of the form, if they're specified. if (reader.GetAttribute("Width") != null) { _width = int.Parse(reader.GetAttribute("Width")); } if (reader.GetAttribute("Height") != null) { _height = int.Parse(reader.GetAttribute("Height")); } // Move to the node after the <ConsoleForm> node. reader.Read(); // Expect to see a node of Line objects. if (reader.Name == "Lines") { ((IXmlSerializable)_lines).ReadXml(reader); } else { throw new InvalidOperationException("<Lines> element missing from form definition."); } // Now expect to see a node containing the Label objects. if (reader.Name == "Labels") { ((IXmlSerializable)_labels).ReadXml(reader); } else { throw new InvalidOperationException("<Labels> element missing from form definition."); } // Finally, we expect to see the node containing the Textbox objects. if (reader.Name == "Textboxes") { ((IXmlSerializable)_textboxes).ReadXml(reader); } else { throw new InvalidOperationException("<Textboxes> element missing from form definition."); } }
public void ReadXml(System.Xml.XmlReader reader) { XmlSerializer valueSerializer = new XmlSerializer(typeof(ColorRampValueList)); bool wasEmpty = reader.IsEmptyElement; reader.Read(); if (wasEmpty) { return; } while (reader.NodeType != System.Xml.XmlNodeType.EndElement) { reader.ReadStartElement("ColorRamp"); reader.ReadStartElement("Name"); string key = reader.ReadString(); reader.ReadEndElement(); ColorRampValueList value = (ColorRampValueList)valueSerializer.Deserialize(reader); value.Text = key; this.Add(key, value); reader.ReadEndElement(); reader.MoveToContent(); } reader.ReadEndElement(); // add extended elements ColorRampValueList valueList; if (!this.ContainsKey("Random values")) { this.Add("Random values", ColorRampValueList.Random); } if (!this.ContainsKey("Empty")) { this.Add("Empty", ColorRampValueList.Empty); } if (!this.ContainsKey("New color ramp ...")) { valueList = new ColorRampValueList(); valueList.Text = "New color ramp ..."; this.Add(valueList.Text, valueList); } }
void ITwentyThreeParsable.Load(System.Xml.XmlReader reader) { if (reader.LocalName != "photo") { UtilityMethods.CheckParsingException(reader); } while (reader.MoveToNextAttribute()) { switch (reader.LocalName) { case "id": PhotoId = reader.Value; break; case "secret": Secret = reader.Value; break; case "server": Server = reader.Value; break; case "farm": Farm = reader.Value; break; case "camera": Camera = reader.Value; break; default: UtilityMethods.CheckParsingException(reader); break; } } reader.Read(); while (reader.LocalName == "exif") { var tag = new ExifTag(); ((ITwentyThreeParsable)tag).Load(reader); Add(tag); } // Skip to next element (if any) reader.Skip(); }
public bool MoveNext() { if (_source == null) { return(false); } if (_reader == null) { OpenReader(); } if (_reader == null) { return(false); } if (_rowCache.Count > 0) { _current = _rowCache[0]; _rowCache.RemoveAt(0); return(true); } bool valid = false; while (!valid) { if (!_reader.Read()) { return(false); } _rowCache.AddRange(ParseNextNode()); if (_rowCache.Count > 0) { valid = true; } } if (_rowCache.Count > 0) { _current = _rowCache[0]; _rowCache.RemoveAt(0); return(true); } return(false); }
/// <summary> /// Fills dictionary 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) { bool wasEmpty = reader.IsEmptyElement; reader.Read(); if (wasEmpty) { return; } while (reader.NodeType != System.Xml.XmlNodeType.EndElement) { reader.MoveToAttribute(0); string key = reader.Value; reader.MoveToAttribute(1); string value = reader.Value; reader.MoveToElement(); this.Add(key, value); reader.Read(); } reader.ReadEndElement(); }
internal void ReadXml(string p, System.Xml.XmlReader reader, XmlReaderContext context) { while (reader.Read()) { if (reader.NodeType == System.Xml.XmlNodeType.Element) { DBColumn c = (DBColumn)context.Factory.Read(reader.LocalName, reader, context); this.Add(c); } else if (reader.NodeType == System.Xml.XmlNodeType.EndElement && string.Equals(reader.LocalName, p)) { break; } } }
void IXmlExportable.FromXml(XmlReader r) { if (r == null) throw new ArgumentNullException("reader"); if (this.IsReadOnly) throw new InvalidOperationException("Object is read-only."); r.Read(); // Add entries into the collection as <item> elements // with child <value> elements are found. while (r.IsStartElement("item")) { string name = r.GetAttribute("name"); bool isNull = r.IsEmptyElement; r.Read(); // <item> if (!isNull) { while (r.IsStartElement("value")) // <value ...> { string value = r.GetAttribute("string"); Add(name, value); r.Read(); } r.ReadEndElement(); // </item> } else { Add(name, null); } } r.ReadEndElement(); }
protected override bool ReadAnInnerElement(System.Xml.XmlReader reader, XmlReaderContext context) { if (this.IsElementMatch(XmlHelper.IndexColumns, reader, context)) { reader.Read(); DBOrderList list = new DBOrderList(); list.ReadXml(XmlHelper.IndexColumns, reader, context); this.ColumnOrders = list; return(true); } else { return(base.ReadAnInnerElement(reader, context)); } }
public void ReadXml(System.Xml.XmlReader reader) { while (reader.Read() && !(reader.NodeType == System.Xml.XmlNodeType.EndElement && reader.LocalName == this.GetType().Name)) { var name = reader["Name"]; if (name == null) { throw new FormatException(); } var value = reader["Value"]; this[name] = value; } }
public void ReadXmlComponentImplements(System.Xml.XmlReader reader, DanuComponent comp) { reader.Read(); while (reader.Read()) { if (reader.Name.Equals("Interface")) { DanuInterfaceObject io = GetInterface(reader.ReadElementString()); DanuSocket so = new DanuSocket(comp, io); AddSocket(so); foreach (DanuComponent checkComp in Components) { if (checkComp.Interfaces.Contains(io)) { io.Eshu.Parent = checkComp.Specification.Classes.FirstOrDefault(); io.Eshu.ImplementingParents.Add(checkComp.Specification.Classes.FirstOrDefault()); } } } } reader.Close(); }
public void ReadXml(System.Xml.XmlReader reader) { reader.ReadStartElement("Item"); do { switch (reader.Name) { case "ItemHeader": Attr1 = reader.GetAttribute("Attr1"); reader.Read(); break; case "ItemDetails": Attr5 = reader.GetAttribute("Attr5"); reader.Read(); break; default: throw new XmlException(String.Format("{0} was not expected", reader.Name)); } } while (reader.Name != "Item"); reader.ReadEndElement(); }
void IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { if (reader.MoveToContent() == System.Xml.XmlNodeType.Element && reader.LocalName == "Value") { Name = reader.GetAttribute("name"); Value = reader.ReadString(); reader.Read(); } else { reader.ReadStartElement(); XmlSerializationHelper.ReadObjectProperties(reader, this); reader.ReadEndElement(); } }
internal RandomBackgroundMusicList(System.Xml.XmlReader reader) : base(reader) { if (reader.IsEmptyElement) { XmlHelpers.ThrowException(StringResources.ExpectedContent, reader); } reader.Read(); m_FirstContainer = DataModule.TheElementFactory.CreateSequentialContainer(reader); m_SequentialElement = m_FirstContainer.GetElements()[0]; m_SecondContainer = (IElementContainer <IParallelElement>)((SequentialElement)m_SequentialElement).InnerElement; m_ParallelElement = m_SecondContainer.GetElements()[0]; m_ThirdContainer = (IElementContainer <IChoiceElement>)((ParallelElement)m_ParallelElement).InnerElement; reader.ReadEndElement(); }
public void ReadXml(System.Xml.XmlReader reader) { XmlSerializer methodSerializer = new XmlSerializer(typeof(EshuMethod)); System.Xml.XmlReader methodReader; Name = reader["Name"]; reader.Read(); methodReader = reader.ReadSubtree(); while (methodReader.ReadToFollowing("EshuMethod")) { signature.Add((EshuMethod)methodSerializer.Deserialize(methodReader)); } methodReader.Close(); }