Esempio n. 1
0
        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();
            }
        }
Esempio n. 2
0
 public static void WriteAttribute(this XmlWriter writer, string localName, DateTime value)
 {
     if (value != DateTime.MinValue)
     {
         writer.WriteAttributeString(localName, CremaXmlConvert.ToString(value));
     }
 }
Esempio n. 3
0
 public static void WriteAttribute(this XmlWriter writer, string localName, int value)
 {
     if (value != 0)
     {
         writer.WriteAttributeString(localName, CremaXmlConvert.ToString(value));
     }
 }
Esempio n. 4
0
        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));
        }
Esempio n. 5
0
        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));
        }
Esempio n. 6
0
        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));
        }
Esempio n. 7
0
        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));
        }
Esempio n. 8
0
        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);
        }
Esempio n. 9
0
        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);
        }
Esempio n. 10
0
        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();
            }
        }