Пример #1
0
        public static Schema FromCursor(ICursor cursor, ISchemaProvider schemaProvider)
        {
            if (cursor == null || cursor.IsNull)
            {
                return(null);
            }

            var schema = new Schema();

            schema.Id = cursor.GoTo("Id").Get <int>();

            schema.DataType    = (DataType)cursor.GoTo("DataType").Get();
            schema.Name        = cursor.GoTo("Name").Get <string>();
            schema.Description = cursor.GoTo("Description").Get <string>();

            schema.DeclarationItem = cursor.GoTo("DeclarationItem");
            if (schema.DeclarationItem.IsNull)
            {
                schema.DeclarationItem = null;
            }

            var fieldList = cursor.GoTo("Fields");

            if (!fieldList.IsNull)
            {
                schema.fields = fieldList.Children.Select(x => Field.FromCursor(x, schemaProvider)).ToArray();
            }

            schema.UpdateLayout();
            return(schema);
        }
Пример #2
0
        public Schema ToSchema()
        {
            var s = new Schema()
            {
                Name            = this.Name,
                DataType        = this.DataType,
                declarationItem = this.DeclarationItem,
                fields          = this.fieldList.Count > 0 ? this.fieldList.ToArray() : null
            };

            s.UpdateLayout();
            return(s);
        }