Example #1
0
        private void ReadColumn(XmlSchemaElement element, CremaDataTable dataTable)
        {
            var dataColumn = new CremaDataColumn()
            {
                InternalColumnName = element.Name,
                InternalComment    = element.ReadDescription(),
            };

            this.ReadColumnDataType(element.ElementSchemaType as XmlSchemaSimpleType, dataColumn);

            if (element.MinOccursString == null)
            {
                dataColumn.InternalAllowDBNull = false;
            }

            if (string.IsNullOrEmpty(element.DefaultValue) == false)
            {
                dataColumn.InternalDefaultValue = CremaXmlConvert.ToValue(element.DefaultValue, dataColumn.DataType);
            }

            if (this.version.Major == CremaSchema.MajorVersion)
            {
                this.ReadColumnInfo(element, dataColumn);
            }
            else
            {
                this.ReadColumnInfoVersion2(element, dataColumn);
            }

            dataTable.Columns.Add(dataColumn);
        }
Example #2
0
        private void ReadAttribute(XmlSchemaAttribute schemaAttribute, CremaDataTable dataTable)
        {
            if (schemaAttribute.Name == CremaSchema.RelationID)
            {
                return;
            }

            var attributeName = schemaAttribute.Name == CremaSchemaObsolete.DataLocation ? CremaSchema.Tags : schemaAttribute.Name;
            var attribute     = dataTable.Attributes[attributeName];

            if (attribute == null)
            {
                attribute = dataTable.Attributes.Add(attributeName);
            }

            if (schemaAttribute.Use == XmlSchemaUse.Required)
            {
                attribute.AllowDBNull = false;
            }

            if (string.IsNullOrEmpty(schemaAttribute.DefaultValue) == false)
            {
                attribute.DefaultValue = CremaXmlConvert.ToValue(schemaAttribute.DefaultValue, attribute.DataType);
            }

            attribute.AutoIncrement = schemaAttribute.ReadAppInfoAsBoolean(CremaSchema.AttributeInfo, CremaSchema.AutoIncrement);
            attribute.Comment       = schemaAttribute.ReadAppInfoAsString(CremaSchema.AttributeInfo, CremaSchema.Comment);
        }
Example #3
0
        protected override void OnReadXml(XmlReader reader)
        {
            var value1 = reader.ReadElementContentAsString();

            this.value = (T)CremaXmlConvert.ToValue(value1, typeof(T));
            reader.MoveToContent();
            var value2 = reader.ReadElementContentAsString();

            this.operatorType = (OperatorType)Enum.Parse(typeof(OperatorType), value2);
        }
Example #4
0
 public object ToValue()
 {
     if (this.Value != null)
     {
         var type = this.Type == nameof(Guid) ? typeof(Guid) : CremaDataTypeUtility.GetType(this.Type);
         return(CremaXmlConvert.ToValue(this.Value, type));
     }
     else if (this.Type == nameof(DBNull))
     {
         return(DBNull.Value);
     }
     else
     {
         return(null);
     }
 }
Example #5
0
        internal static object[] ReadFields(XmlReader reader, string propertyName)
        {
            reader.MoveToContent();
            if (reader.IsEmptyElement == false)
            {
                var fieldList = new List <object>();
                reader.ReadStartElement(propertyName);

                while (reader.MoveToContent() == XmlNodeType.Element)
                {
                    var attr = reader.GetAttribute("type");
                    if (reader.IsEmptyElement == false)
                    {
                        var text  = reader.ReadElementContentAsString();
                        var type  = attr == nameof(Guid) ? typeof(Guid) : CremaDataTypeUtility.GetType(attr);
                        var field = CremaXmlConvert.ToValue(text, type);
                        fieldList.Add(field);
                    }
                    else if (attr == nameof(DBNull))
                    {
                        fieldList.Add(DBNull.Value);
                        reader.Skip();
                    }
                    else
                    {
                        fieldList.Add(null);
                        reader.Skip();
                    }
                }
                reader.ReadEndElement();
                return(fieldList.ToArray());
            }
            else
            {
                reader.Skip();
                return(null);
            }
        }