コード例 #1
0
        /// <summary>
        /// Creates a clone of the specified instance
        /// </summary>
        /// <param name="prop">The instance to clone.</param>
        /// <returns></returns>
        public static PropertyDefinition Clone(PropertyDefinition prop)
        {
            switch (prop.Type)
            {
            case PropertyDefinitionType.Data:
            {
                var source = (DataPropertyDefinition)prop;
                var dp     = new DataPropertyDefinition(prop.Name, prop.Description);

                dp.DataType        = source.DataType;
                dp.DefaultValue    = source.DefaultValue;
                dp.IsAutoGenerated = source.IsAutoGenerated;
                dp.IsNullable      = source.IsNullable;
                dp.IsReadOnly      = source.IsReadOnly;
                dp.Length          = source.Length;
                dp.Precision       = source.Precision;
                dp.Scale           = source.Scale;

                return(dp);
            }

            case PropertyDefinitionType.Geometry:
            {
                var source = (GeometricPropertyDefinition)prop;
                var gp     = new GeometricPropertyDefinition(prop.Name, prop.Description);

                gp.SpecificGeometryTypes     = source.SpecificGeometryTypes;
                gp.HasElevation              = source.HasElevation;
                gp.HasMeasure                = source.HasMeasure;
                gp.IsReadOnly                = source.IsReadOnly;
                gp.SpatialContextAssociation = source.SpatialContextAssociation;

                return(gp);
            }

            case PropertyDefinitionType.Raster:
            {
                var source = (RasterPropertyDefinition)prop;
                var rp     = new RasterPropertyDefinition(prop.Name, prop.Description);

                rp.DefaultImageXSize         = source.DefaultImageXSize;
                rp.DefaultImageYSize         = source.DefaultImageYSize;
                rp.IsNullable                = source.IsNullable;
                rp.IsReadOnly                = source.IsReadOnly;
                rp.SpatialContextAssociation = source.SpatialContextAssociation;

                return(rp);
            }
            }
            throw new ArgumentException();
        }
コード例 #2
0
        /// <summary>
        /// Adds the specified data property, with an option to include it as an identity property
        /// </summary>
        /// <param name="prop"></param>
        /// <param name="identity"></param>
        public void AddProperty(DataPropertyDefinition prop, bool identity)
        {
            if (!_properties.Contains(prop))
            {
                _properties.Add(prop);
            }

            if (identity && !_identity.Contains(prop))
            {
                _identity.Add(prop);
            }

            prop.Parent = this;
        }
コード例 #3
0
        /// <summary>
        /// Parses the specified XML node into a Property Definition
        /// </summary>
        /// <param name="node"></param>
        /// <param name="mgr"></param>
        /// <returns></returns>
        public static PropertyDefinition Parse(System.Xml.XmlNode node, System.Xml.XmlNamespaceManager mgr)
        {
            PropertyDefinition prop = null;
            var nn    = node.Attributes["name"];      //NOXLATE
            var nulln = node.Attributes["minOccurs"]; //NOXLATE

            string name = Utility.DecodeFDOName(nn.Value);
            string desc = string.Empty;

            //Description
            var docNode = node.SelectSingleNode("xs:annotation/xs:documentation", mgr); //NOXLATE

            if (docNode != null)
            {
                desc = docNode.InnerText;
            }

            if (node.Attributes["type"] != null && node.Attributes["type"].Value == "gml:AbstractGeometryType") //NOXLATE
            {
                prop = new GeometricPropertyDefinition(name, desc);
            }
            else if (node["xs:simpleType"] == null) //NOXLATE
            {
                prop = new RasterPropertyDefinition(name, desc);
            }
            else
            {
                if (node["xs:simpleType"] != null) //NOXLATE
                {
                    prop = new DataPropertyDefinition(name, desc);
                }
            }

            if (prop != null)
            {
                prop.ReadXml(node, mgr);
            }
            else
            {
                throw new NotSupportedException(Strings.ErrorUnsupporteFdoSchemaXml);
            }

            return(prop);
        }
コード例 #4
0
ファイル: ClassDefinition.cs プロジェクト: kanbang/Colt
        /// <summary>
        /// Adds the specified data property, with an option to include it as an identity property
        /// </summary>
        /// <param name="prop"></param>
        /// <param name="identity"></param>
        public void AddProperty(DataPropertyDefinition prop, bool identity)
        {
            if (!_properties.Contains(prop))
                _properties.Add(prop);

            if (identity && !_identity.Contains(prop))
                _identity.Add(prop);

            prop.Parent = this;
        }
コード例 #5
0
ファイル: PropertyDefinition.cs プロジェクト: kanbang/Colt
        /// <summary>
        /// Parses the specified XML node into a Property Definition
        /// </summary>
        /// <param name="node"></param>
        /// <param name="mgr"></param>
        /// <returns></returns>
        public static PropertyDefinition Parse(System.Xml.XmlNode node, System.Xml.XmlNamespaceManager mgr)
        {
            PropertyDefinition prop = null;
            var nn = node.Attributes["name"]; //NOXLATE
            var nulln = node.Attributes["minOccurs"]; //NOXLATE

            string name = Utility.DecodeFDOName(nn.Value);
            string desc = string.Empty;

            //Description
            var docNode = node.SelectSingleNode("xs:annotation/xs:documentation", mgr); //NOXLATE
            if (docNode != null)
                desc = docNode.InnerText;

            if (node.Attributes["type"] != null && node.Attributes["type"].Value == "gml:AbstractGeometryType") //NOXLATE
            {
                prop = new GeometricPropertyDefinition(name, desc);
            }
            else if (node["xs:simpleType"] == null) //NOXLATE
            {
                prop = new RasterPropertyDefinition(name, desc);
            }
            else
            {
                if (node["xs:simpleType"] != null) //NOXLATE
                    prop = new DataPropertyDefinition(name, desc);
            }

            if (prop != null)
                prop.ReadXml(node, mgr);
            else
                throw new NotSupportedException(Strings.ErrorUnsupporteFdoSchemaXml);

            return prop;
        }
コード例 #6
0
ファイル: PropertyDefinition.cs プロジェクト: kanbang/Colt
        /// <summary>
        /// Creates a clone of the specified instance
        /// </summary>
        /// <param name="prop">The instance to clone.</param>
        /// <returns></returns>
        public static PropertyDefinition Clone(PropertyDefinition prop)
        {
            switch (prop.Type)
            {
                case PropertyDefinitionType.Data:
                    {
                        var source = (DataPropertyDefinition)prop;
                        var dp = new DataPropertyDefinition(prop.Name, prop.Description);

                        dp.DataType = source.DataType;
                        dp.DefaultValue = source.DefaultValue;
                        dp.IsAutoGenerated = source.IsAutoGenerated;
                        dp.IsNullable = source.IsNullable;
                        dp.IsReadOnly = source.IsReadOnly;
                        dp.Length = source.Length;
                        dp.Precision = source.Precision;
                        dp.Scale = source.Scale;

                        return dp;
                    }
                case PropertyDefinitionType.Geometry:
                    {
                        var source = (GeometricPropertyDefinition)prop;
                        var gp = new GeometricPropertyDefinition(prop.Name, prop.Description);

                        gp.SpecificGeometryTypes = source.SpecificGeometryTypes;
                        gp.HasElevation = source.HasElevation;
                        gp.HasMeasure = source.HasMeasure;
                        gp.IsReadOnly = source.IsReadOnly;
                        gp.SpatialContextAssociation = source.SpatialContextAssociation;

                        return gp;
                    }
                case PropertyDefinitionType.Raster:
                    {
                        var source = (RasterPropertyDefinition)prop;
                        var rp = new RasterPropertyDefinition(prop.Name, prop.Description);

                        rp.DefaultImageXSize = source.DefaultImageXSize;
                        rp.DefaultImageYSize = source.DefaultImageYSize;
                        rp.IsNullable = source.IsNullable;
                        rp.IsReadOnly = source.IsReadOnly;
                        rp.SpatialContextAssociation = source.SpatialContextAssociation;

                        return rp;
                    }
            }
            throw new ArgumentException();
        }
コード例 #7
0
ファイル: Utility.cs プロジェクト: kanbang/Colt
        private static DataPropertyDefinition ConvertDataProperty(MgDataPropertyDefinition dataProp)
        {
            var dp = new DataPropertyDefinition(dataProp.Name, dataProp.Description);
            dp.DataType = (DataPropertyType)dataProp.DataType;
            dp.DefaultValue = dataProp.DefaultValue;
            dp.Description = dataProp.Description;
            dp.IsAutoGenerated = dataProp.IsAutoGenerated();
            dp.IsNullable = dataProp.Nullable;
            dp.IsReadOnly = dataProp.ReadOnly;
            dp.Length = dataProp.Length;
            dp.Precision = dataProp.Precision;
            dp.Scale = dataProp.Scale;

            return dp;
        }
コード例 #8
0
ファイル: SchemaTests.cs プロジェクト: kanbang/Colt
        public void TestCreate()
        {
            var schema = new FeatureSchema("Default", "Default Schema");
            Assert.AreEqual("Default", schema.Name);
            Assert.AreEqual("Default Schema", schema.Description);

            var cls = new ClassDefinition("Class1", "My Class");
            Assert.AreEqual("Class1", cls.Name);
            Assert.AreEqual("My Class", cls.Description);
            Assert.IsTrue(string.IsNullOrEmpty(cls.DefaultGeometryPropertyName));
            Assert.AreEqual(0, cls.Properties.Count);
            Assert.AreEqual(0, cls.IdentityProperties.Count);

            var prop = new DataPropertyDefinition("ID", "identity");
            Assert.AreEqual("ID", prop.Name);
            Assert.AreEqual("identity", prop.Description);
            Assert.AreEqual(false, prop.IsAutoGenerated);
            Assert.AreEqual(false, prop.IsReadOnly);
            Assert.IsTrue(string.IsNullOrEmpty(prop.DefaultValue));

            prop.DataType = DataPropertyType.Int32;
            Assert.AreEqual(DataPropertyType.Int32, prop.DataType);

            prop.IsAutoGenerated = true;
            Assert.IsTrue(prop.IsAutoGenerated);

            prop.IsReadOnly = true;
            Assert.IsTrue(prop.IsReadOnly);

            cls.AddProperty(prop, true);
            Assert.AreEqual(1, cls.Properties.Count);
            Assert.AreEqual(1, cls.IdentityProperties.Count);
            Assert.AreEqual(cls, prop.Parent);
            Assert.NotNull(cls.FindProperty(prop.Name));

            cls.RemoveProperty(prop);
            Assert.AreEqual(0, cls.Properties.Count);
            Assert.AreEqual(0, cls.Properties.Count);
            Assert.IsNull(prop.Parent);
            Assert.IsNull(cls.FindProperty(prop.Name));

            cls.AddProperty(prop, true);
            Assert.AreEqual(1, cls.Properties.Count);
            Assert.AreEqual(1, cls.IdentityProperties.Count);
            Assert.AreEqual(cls, prop.Parent);
            Assert.NotNull(cls.FindProperty(prop.Name));

            cls.AddProperty(new DataPropertyDefinition("Name", "")
            {
                DataType = DataPropertyType.String,
                Length = 255,
                IsNullable = true
            });

            Assert.AreEqual(2, cls.Properties.Count);
            Assert.AreEqual(1, cls.IdentityProperties.Count);

            cls.AddProperty(new GeometricPropertyDefinition("Geom", "")
            {
                HasMeasure = false,
                HasElevation = false,
                GeometricTypes = FeatureGeometricType.All,
                SpecificGeometryTypes = (SpecificGeometryType[])Enum.GetValues(typeof(SpecificGeometryType))
            });
            Assert.AreEqual(3, cls.Properties.Count);
            Assert.AreEqual(1, cls.IdentityProperties.Count);
            Assert.IsTrue(string.IsNullOrEmpty(cls.DefaultGeometryPropertyName));

            var geom = cls.FindProperty("Geom");
            Assert.NotNull(geom);

            cls.DefaultGeometryPropertyName = geom.Name;
            Assert.IsNotNullOrEmpty(cls.DefaultGeometryPropertyName);

            schema.AddClass(cls);
            Assert.AreEqual(schema, cls.Parent);
        }