/// <summary> /// Lê o xml. /// </summary> /// <param name="reader"></param> public void ReadXml(System.Xml.XmlReader reader) { if (reader.MoveToAttribute("Success")) { bool success; if (bool.TryParse(reader.ReadContentAsString(), out success)) { Success = success; } } reader.MoveToElement(); reader.MoveToElement(); if (!reader.IsEmptyElement) { reader.ReadStartElement(); var text = reader.ReadElementString("Message"); if (!text.Equals(string.Empty)) { Message = text.GetFormatter(); } reader.ReadEndElement(); } else { reader.Skip(); } }
public void ReadXml(System.Xml.XmlReader reader) { if (reader.IsEmptyElement) { reader.Read(); return; } reader.ReadStartElement("SerializableDictionaryOfStringString"); while (reader.NodeType != System.Xml.XmlNodeType.EndElement) { /* * reader.Read(); * string key = reader.ReadElementContentAsString(); * string value = reader.ReadElementContentAsString(); * reader.ReadEndElement(); * base.Add((TKey)Convert.ChangeType(key, typeof(TKey), CultureInfo.InvariantCulture), (TValue)Convert.ChangeType(value, typeof(TValue), CultureInfo.InvariantCulture));*/ if (reader.HasAttributes) { string key = reader.GetAttribute("Key"); string value = reader.GetAttribute("Value"); l.Debug("key=" + key + " value=" + value); base.Add((TKey)Convert.ChangeType(key, typeof(TKey), CultureInfo.InvariantCulture), (TValue)Convert.ChangeType(value, typeof(TValue), CultureInfo.InvariantCulture)); reader.MoveToElement(); } reader.ReadStartElement("KeyValuePair"); //reader.ReadEndElement(); //reader.MoveToContent(); } reader.ReadEndElement(); }
void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { if (reader.MoveToAttribute("Name")) { _name = reader.ReadContentAsString(); } if (reader.MoveToAttribute("LastWriteTime")) { _lastWriteTime = reader.ReadContentAsDateTime(); } reader.MoveToElement(); if (!reader.IsEmptyElement) { reader.ReadStartElement(); var refs = new List <string>(); while (reader.NodeType != System.Xml.XmlNodeType.EndElement) { if (reader.LocalName == "Reference") { refs.Add(reader.ReadElementString()); } else { reader.Skip(); } } this.References = refs.ToArray(); reader.ReadEndElement(); } else { reader.Skip(); } }
/// <summary> /// Lê um xml e deserializa o objeto /// </summary> /// <param name="reader">objeto leitor</param> void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { if (reader.MoveToAttribute("DefinitionUid")) { DefinitionUid = reader.ReadContentAsInt(); } if (reader.MoveToAttribute("Name")) { Name = reader.ReadContentAsString(); } if (reader.MoveToAttribute("Description")) { Description = reader.ReadContentAsString(); } if (reader.MoveToAttribute("Type") && reader.HasValue) { TypeDefinition = Type.GetType(reader.ReadContentAsString(), true); } reader.MoveToElement(); if (!reader.IsEmptyElement) { this.Value = reader.ReadElementContentAs(TypeDefinition, null); } else { reader.Skip(); } }
void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { if (reader.MoveToAttribute("Uid")) { this._uid = Guid.Parse(reader.ReadContentAsString()); } if (reader.MoveToAttribute("CreateTime")) { this._createTime = reader.ReadContentAsDateTime(); } reader.MoveToElement(); reader.ReadStartElement(); reader.ReadStartElement("AssemblyParts"); while (reader.NodeType != System.Xml.XmlNodeType.EndElement) { if (reader.LocalName == "AssemblyPart") { AssemblyPart part = new AssemblyPart(); ((System.Xml.Serialization.IXmlSerializable)part).ReadXml(reader); this._items.Add(part); } else { reader.Skip(); } } reader.ReadEndElement(); }
void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { if (reader.MoveToAttribute("Left")) { _left = reader.ReadContentAsString(); } if (reader.MoveToAttribute("Right")) { _right = reader.ReadContentAsString(); } if (reader.MoveToAttribute("Type")) { _type = (JoinType)Enum.Parse(typeof(JoinType), reader.ReadContentAsString()); } reader.MoveToElement(); if (!reader.IsEmptyElement) { reader.ReadStartElement(); if (!reader.IsEmptyElement && reader.LocalName == "Conditional") { _conditional = new ConditionalContainer(); ((System.Xml.Serialization.IXmlSerializable)_conditional).ReadXml(reader); } reader.ReadEndElement(); } else { reader.Skip(); } }
/// <summary> /// Lê os dados serializados. /// </summary> /// <param name="reader"></param> void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { if (reader.MoveToAttribute("uid")) { Uid = Guid.Parse(reader.ReadContentAsString()); } if (reader.MoveToAttribute("name")) { Name = reader.ReadContentAsString(); } if (reader.MoveToAttribute("inputValidate")) { var inputValidate = reader.ReadContentAsString(); if (!string.IsNullOrEmpty(inputValidate)) { this.InputValidateUid = Guid.Parse(inputValidate); } } if (reader.MoveToAttribute("parse")) { var parse = reader.ReadContentAsString(); if (!string.IsNullOrEmpty(parse)) { ParseId = int.Parse(parse); } } if (reader.MoveToAttribute("options")) { Options = (InputRulesOptions)Enum.Parse(typeof(InputRulesOptions), reader.ReadContentAsString()); } if (reader.MoveToAttribute("copyValue")) { CopyValue = reader.ReadContentAsBoolean(); } reader.MoveToElement(); if (!reader.IsEmptyElement) { reader.ReadStartElement(); while (reader.NodeType != System.Xml.XmlNodeType.EndElement) { switch (reader.LocalName) { case "Label": Label = reader.ReadElementContentAsString(); break; default: reader.Skip(); break; } } reader.ReadEndElement(); } else { reader.Skip(); } }
void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { if (reader.MoveToAttribute("ColumnName")) { this.ColumnName = reader.ReadContentAsString(); } reader.MoveToElement(); reader.Skip(); }
/// <summary> /// Lê os dados do XML. /// </summary> /// <param name="reader"></param> void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { reader.MoveToAttribute("Name"); _name = reader.ReadContentAsString(); reader.MoveToAttribute("Schema"); _schema = reader.ReadContentAsString(); reader.MoveToElement(); reader.Skip(); }
/// <summary> /// Lê os dados serializados em XML. /// </summary> /// <param name="reader"></param> protected override void ReadXml(System.Xml.XmlReader reader) { reader.MoveToAttribute("Name"); Name = reader.ReadContentAsString(); reader.MoveToAttribute("Owner"); Owner = reader.ReadContentAsString(); reader.MoveToElement(); reader.Skip(); }
public void AllRecordsAreReturnedWhenExecutingExecuteXmlReaderWithSqlCommandTransactionAndWithCallBack() { SqlDatabase db = new DatabaseProviderFactory(base.ConfigurationSource).Create("DefaultSqlAsync") as SqlDatabase; try { DbAsyncState state; DataTable dt = new DataTable(); DbCommand command = new SqlCommand(); DbCommand command1 = new SqlCommand(); AsyncCallback cb = new AsyncCallback(EndExecuteXmlReaderCallBack); int originalCount = 1; int rowCount = 0; using (SqlConnection connection = new SqlConnection(db.ConnectionString)) { connection.Open(); DbTransaction transaction = connection.BeginTransaction(); // Execute the NonQuery insert statement synchronously. command1.CommandType = CommandType.Text; command1.CommandText = InsertCategorySql; db.ExecuteNonQuery(command1, transaction); // Since one row is inserted. originalCount = 1; // Get the data Asynchronously. command.CommandType = CommandType.Text; command.CommandText = GetTestCategoryQuery + " FOR XML AUTO, XMLDATA"; state = BeginExecuteXmlReader(db, command, transaction, cb); using (System.Xml.XmlReader xmlr = (System.Xml.XmlReader)state.State) { while (!xmlr.EOF) { xmlr.Read(); xmlr.MoveToElement(); if (xmlr.Name.Contains("Categories")) { rowCount++; } } } transaction.Commit(); Assert.AreEqual <int>(originalCount, rowCount); Assert.AreEqual <ConnectionState>(ConnectionState.Open, state.AsyncResult.Connection.State); } } finally { db.ExecuteNonQuery(CommandType.Text, DeleteCategoriesSql); } }
/// <summary> /// Lê os dados serializados. /// </summary> /// <param name="reader"></param> void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { if (reader.MoveToAttribute("uid")) { Uid = Guid.Parse(reader.ReadContentAsString()); } if (reader.MoveToAttribute("name")) { Name = reader.ReadContentAsString(); } if (reader.MoveToAttribute("type")) { var type = reader.ReadContentAsString(); if (!string.IsNullOrEmpty(type)) { Type = new Reflection.TypeName(type); } } reader.MoveToElement(); if (!reader.IsEmptyElement) { reader.ReadStartElement(); while (reader.NodeType != System.Xml.XmlNodeType.EndElement) { if (reader.LocalName == "Parameters") { reader.ReadStartElement(); while (reader.NodeType != System.Xml.XmlNodeType.EndElement) { if (reader.LocalName == "ValidationTypeParameter") { var parameter = new ValidationTypeParameter(); ((System.Xml.Serialization.IXmlSerializable)parameter).ReadXml(reader); Parameters.Add(parameter); } else { reader.Skip(); } } reader.ReadEndElement(); } else if (reader.LocalName == "Description") { Description = reader.ReadElementContentAsString(); } } reader.ReadEndElement(); } else { reader.Skip(); } }
private static bool SkipEmptyElement(System.Xml.XmlReader xmlReader) { xmlReader.MoveToElement( ); if (xmlReader.IsEmptyElement) { xmlReader.Skip( ); return(true); } else { return(false); } }
void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { var value = reader.GetAttribute("Take"); if (!string.IsNullOrEmpty(value)) { _take = int.Parse(value); } value = reader.GetAttribute("Skip"); if (!string.IsNullOrEmpty(value)) { _skip = int.Parse(value); } reader.MoveToElement(); reader.Skip(); }
void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { if (reader.MoveToAttribute("Name")) { Name = reader.ReadContentAsString(); } if (reader.MoveToAttribute("Direction")) { Direction = (Colosoft.Query.ParameterDirection)reader.ReadContentAsInt(); } if (reader.MoveToAttribute("Size")) { Size = reader.ReadContentAsInt(); } Type type = null; if (reader.MoveToAttribute("Type")) { var typeString = reader.ReadContentAsString(); if (!string.IsNullOrEmpty(typeString)) { type = Type.GetType(typeString, true); } } reader.MoveToElement(); if (!reader.IsEmptyElement) { if (type == typeof(byte[])) { var content = (string)reader.ReadElementContentAs(typeof(string), null); Value = Convert.FromBase64String(content); } else if (type != null) { Value = reader.ReadElementContentAs(type, null); } else { Value = null; } } else { reader.Skip(); } }
/// <summary> /// Lê os dados serializados. /// </summary> /// <param name="reader"></param> void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { if(reader.MoveToAttribute("name")) Name = reader.ReadContentAsString(); if(reader.MoveToAttribute("isInstance")) IsInstance = reader.ReadContentAsBoolean(); if(reader.MoveToAttribute("type")) { var type = reader.ReadContentAsString(); Type = !string.IsNullOrEmpty(type) ? new Reflection.TypeName(reader.ReadContentAsString()) : null; } if(reader.MoveToAttribute("inputRulesGroup")) { var inputRulesGroupUid = reader.ReadContentAsString(); InputRulesGroupUid = !string.IsNullOrEmpty(inputRulesGroupUid) ? (Guid?)Guid.Parse(inputRulesGroupUid) : null; } reader.MoveToElement(); if(!reader.IsEmptyElement) { reader.ReadStartElement(); while (reader.NodeType != System.Xml.XmlNodeType.EndElement) { if(reader.LocalName == "DefaultLabels" && !reader.IsEmptyElement) { reader.ReadStartElement(); while (reader.NodeType != System.Xml.XmlNodeType.EndElement) { if(reader.LocalName == "PropertyDefaultLabel") { var label = new PropertyDefaultLabel(); ((System.Xml.Serialization.IXmlSerializable)label).ReadXml(reader); DefaultLabels.Add(label); } else reader.Skip(); } reader.ReadEndElement(); } else reader.Skip(); } reader.ReadEndElement(); } else reader.Skip(); }
void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { if (reader.MoveToAttribute("FullName")) { _fullName = reader.ReadContentAsString(); } if (reader.MoveToAttribute("Alias")) { _alias = reader.ReadContentAsString(); } reader.MoveToElement(); if (!reader.IsEmptyElement) { _subQuery = new QueryInfo(); ((System.Xml.Serialization.IXmlSerializable)_subQuery).ReadXml(reader); } else { reader.Skip(); } }