internal 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)); } }
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(); } }