private static void WriteField(XmlWriter writer, CremaDataRow dataRow, CremaDataColumn dataColumn, bool ignoreDefaultValue) { var dataType = dataColumn.DataType; var value = dataRow[dataColumn]; if (value == DBNull.Value) { return; } var converter = TypeDescriptor.GetConverter(dataColumn.DataType); var textValue = CremaXmlConvert.ToString(value, dataType); if (object.Equals(value, dataColumn.DefaultValue) == true) { writer.WriteStartElement(dataColumn.ColumnName); writer.WriteEndElement(); } else { writer.WriteStartElement(dataColumn.ColumnName); writer.WriteValue(textValue); writer.WriteEndElement(); } }
public static void WriteAttribute(this XmlWriter writer, string localName, DateTime value) { if (value != DateTime.MinValue) { writer.WriteAttributeString(localName, CremaXmlConvert.ToString(value)); } }
public static void WriteAttribute(this XmlWriter writer, string localName, int value) { if (value != 0) { writer.WriteAttributeString(localName, CremaXmlConvert.ToString(value)); } }
public static DateTime GetAttributeAsDateTime(this XmlReader reader, string name, XmlDateTimeSerializationMode mode) { var text = reader.GetAttribute(name); if (string.IsNullOrEmpty(text) == true) { return(DateTime.MinValue); } return(CremaXmlConvert.ToDateTime(text, mode)); }
public static bool GetAttributeAsBoolean(this XmlReader reader, string name) { var text = reader.GetAttribute(name); if (string.IsNullOrEmpty(text) == true) { return(false); } return(CremaXmlConvert.ToBoolean(text)); }
public static int GetAttributeAsInt32(this XElement element, string name) { var text = element.GetAttribute(name); if (string.IsNullOrEmpty(text) == true) { return(0); } return(CremaXmlConvert.ToInt32(text)); }
public static int GetAttributeAsInt32(this XmlReader reader, string name) { var text = reader.GetAttribute(name); if (string.IsNullOrEmpty(text) == true) { return(0); } return(CremaXmlConvert.ToInt32(text)); }
public static bool TryGetAttributeAsDateTime(this XmlReader reader, string name, XmlDateTimeSerializationMode mode, out DateTime value) { var text = reader.GetAttribute(name); if (string.IsNullOrEmpty(text) == true) { value = new DateTime(); return(false); } value = CremaXmlConvert.ToDateTime(text, mode); return(true); }
public static bool TryGetAttributeAsInt32(this XmlReader reader, string name, out int value) { var text = reader.GetAttribute(name); if (string.IsNullOrEmpty(text) == true) { value = 0; return(false); } value = CremaXmlConvert.ToInt32(text); return(true); }
private void WriteAttribute(XmlWriter writer, InternalDataRow dataRow, InternalAttribute dataColumn) { var field = dataRow[dataColumn]; if (field == DBNull.Value || object.Equals(field, dataColumn.DefaultValue) == true) { return; } var textValue = CremaXmlConvert.ToString(field, dataColumn.DataType); if (string.IsNullOrEmpty(textValue) == false) { writer.WriteStartAttribute(dataColumn.AttributeName); writer.WriteValue(textValue); writer.WriteEndAttribute(); } }