Пример #1
0
        private void WriteAttribute(XmlSchema schema, XmlSchemaComplexType complexType, CremaAttribute attribute)
        {
            var schemaAttribute = new XmlSchemaAttribute()
            {
                Name           = attribute.AttributeName,
                SchemaTypeName = GetSystemQualifiedName(attribute.DataType, schema.TargetNamespace)
            };

            if (attribute.AllowDBNull == false)
            {
                if (attribute.DefaultValue == DBNull.Value)
                {
                    schemaAttribute.Use = XmlSchemaUse.Required;
                }
                else
                {
                    schemaAttribute.Use = XmlSchemaUse.Optional;
                }
            }

            var defaultValue = attribute.DefaultValue;

            if (defaultValue != DBNull.Value)
            {
                schemaAttribute.DefaultValue = CremaXmlConvert.ToString(defaultValue, attribute.DataType);
            }

            schemaAttribute.WriteAppInfo(CremaSchema.AttributeInfo, CremaSchema.AutoIncrement, attribute.AutoIncrement, schema.TargetNamespace);
            schemaAttribute.WriteAppInfo(CremaSchema.AttributeInfo, CremaSchema.Comment, attribute.Comment, schema.TargetNamespace);

            complexType.Attributes.Add(schemaAttribute);
        }
Пример #2
0
        internal static void WriteFields(XmlWriter writer, string propertyName, object[] fields)
        {
            writer.WriteStartElement(propertyName);

            if (fields != null)
            {
                foreach (var item in fields)
                {
                    writer.WriteStartElement("item");
                    if (item is DBNull)
                    {
                        writer.WriteAttributeString("type", nameof(DBNull));
                    }
                    else if (item != null)
                    {
                        if (item is Guid)
                        {
                            writer.WriteAttributeString("type", nameof(Guid));
                        }
                        else
                        {
                            writer.WriteAttributeString("type", item.GetType().GetTypeName());
                        }
                        writer.WriteString(CremaXmlConvert.ToString(item));
                    }
                    writer.WriteEndElement();
                }
            }

            writer.WriteEndElement();
        }
Пример #3
0
        private void WriteElement(XmlSchema schema, XmlSchemaSequence sequence, CremaDataColumn dataColumn)
        {
            var element = new XmlSchemaElement()
            {
                Name           = dataColumn.ColumnName,
                SchemaTypeName = this.GetXmlQualifiedName(schema, dataColumn)
            };
            var defaultValue = CremaXmlConvert.ToString(dataColumn.DefaultValue, dataColumn.DataType);

            if (string.IsNullOrEmpty(defaultValue) == false)
            {
                element.DefaultValue = defaultValue;
            }
            if (dataColumn.AllowDBNull == true && dataColumn.IsKey == false)
            {
                element.MinOccursString = "0";
            }

            element.WriteAppInfo(CremaSchema.ColumnInfo, CremaSchema.Creator, dataColumn.CreationInfo.ID, schema.TargetNamespace);
            element.WriteAppInfo(CremaSchema.ColumnInfo, CremaSchema.CreatedDateTime, dataColumn.CreationInfo.DateTime, schema.TargetNamespace);
            element.WriteAppInfo(CremaSchema.ColumnInfo, CremaSchema.Modifier, dataColumn.ModificationInfo.ID, schema.TargetNamespace);
            element.WriteAppInfo(CremaSchema.ColumnInfo, CremaSchema.ModifiedDateTime, dataColumn.ModificationInfo.DateTime, schema.TargetNamespace);
            element.WriteAppInfo(CremaSchema.ColumnInfo, CremaSchema.AutoIncrement, dataColumn.AutoIncrement, schema.TargetNamespace);
            element.WriteAppInfo(CremaSchema.ColumnInfo, CremaSchema.ID, dataColumn.ColumnID, schema.TargetNamespace);
            element.WriteAppInfo(CremaSchema.ColumnInfo, CremaSchema.Tags, dataColumn.Tags, schema.TargetNamespace);
            element.WriteAppInfo(CremaSchema.ColumnInfo, CremaSchema.ReadOnly, dataColumn.ReadOnly, schema.TargetNamespace);

            element.WriteDescription(dataColumn.Comment);
            sequence.Items.Add(element);
        }
Пример #4
0
 public DomainFieldInfo(object field)
 {
     if (field is DBNull)
     {
         this.Type  = nameof(DBNull);
         this.Value = null;
     }
     else if (field != null)
     {
         if (field is Guid)
         {
             this.Type = nameof(Guid);
         }
         else
         {
             this.Type = field.GetType().GetTypeName();
         }
         this.Value = CremaXmlConvert.ToString(field);
     }
     else
     {
         this.Type  = null;
         this.Value = null;
     }
 }
Пример #5
0
 internal static void WriteAppInfo(this XmlSchemaAnnotated annotated, string nodeName, string attributeName, Guid value, string ns, Guid defaultValue)
 {
     WriteAppInfo(annotated, nodeName, attributeName, CremaXmlConvert.ToString(value), ns, CremaXmlConvert.ToString(defaultValue));
 }