internal static MgFeatureSchema ConvertSchema(FeatureSchema source) { MgFeatureSchema fs = new MgFeatureSchema(source.Name, source.Description); MgClassDefinitionCollection classes = fs.GetClasses(); foreach (ClassDefinition cls in source.Classes) { MgClassDefinition clsDef = new MgClassDefinition(); clsDef.SetName(cls.Name); clsDef.SetDescription(cls.Description); clsDef.SetDefaultGeometryPropertyName(cls.DefaultGeometryPropertyName); var clsProps = clsDef.GetProperties(); var idProps = clsDef.GetIdentityProperties(); foreach (PropertyDefinition prop in cls.Properties) { switch (prop.Type) { case PropertyDefinitionType.Data: { var dp = new MgDataPropertyDefinition(prop.Name); var srcDp = (DataPropertyDefinition)prop; dp.SetAutoGeneration(srcDp.IsAutoGenerated); dp.SetDataType((int)srcDp.DataType); if (srcDp.DefaultValue != null) { dp.SetDefaultValue(srcDp.DefaultValue); } if (srcDp.Description != null) { dp.SetDescription(srcDp.Description); } dp.SetLength(srcDp.Length); dp.SetNullable(srcDp.IsNullable); dp.SetPrecision(srcDp.Precision); dp.SetReadOnly(srcDp.IsReadOnly); dp.SetScale(srcDp.Scale); clsProps.Add(dp); if (cls.IdentityProperties.Contains(srcDp)) { idProps.Add(dp); } } break; case PropertyDefinitionType.Geometry: { var gp = new MgGeometricPropertyDefinition(prop.Name); var srcGp = (GeometricPropertyDefinition)prop; if (srcGp.Description != null) { gp.SetDescription(srcGp.Description); } gp.SetGeometryTypes((int)srcGp.GeometricTypes); gp.SetHasElevation(srcGp.HasElevation); gp.SetHasMeasure(srcGp.HasMeasure); gp.SetReadOnly(srcGp.IsReadOnly); if (srcGp.SpatialContextAssociation != null) { gp.SetSpatialContextAssociation(srcGp.SpatialContextAssociation); } clsProps.Add(gp); } break; case PropertyDefinitionType.Raster: { var rp = new MgRasterPropertyDefinition(prop.Name); var srcRp = (RasterPropertyDefinition)prop; rp.SetDefaultImageXSize(srcRp.DefaultImageYSize); rp.SetDefaultImageYSize(srcRp.DefaultImageYSize); if (srcRp.Description != null) { rp.SetDescription(srcRp.Description); } rp.SetNullable(srcRp.IsNullable); rp.SetReadOnly(srcRp.IsReadOnly); if (srcRp.SpatialContextAssociation != null) { rp.SetSpatialContextAssociation(srcRp.SpatialContextAssociation); } clsProps.Add(rp); } break; default: throw new NotSupportedException(); } } classes.Add(clsDef); } return(fs); }