コード例 #1
0
        public void TestCloneClass()
        {
            ClassDefinition        c1   = new FeatureClass("Test", "Test Feature Class");
            DataPropertyDefinition id   = new DataPropertyDefinition("ID", "");
            DataPropertyDefinition name = new DataPropertyDefinition("Name", "");

            id.DataType        = DataType.DataType_Int32;
            id.IsAutoGenerated = true;
            id.ReadOnly        = true;
            id.Nullable        = false;

            name.DataType = DataType.DataType_String;
            name.Length   = 255;
            name.Nullable = true;

            GeometricPropertyDefinition geom = new GeometricPropertyDefinition("Geometry", "");

            geom.GeometryTypes = (int)GeometryType.GeometryType_Polygon;
            geom.ReadOnly      = false;

            c1.Properties.Add(id);
            c1.Properties.Add(name);
            c1.Properties.Add(geom);
            c1.IdentityProperties.Add(id);

            ((FeatureClass)c1).GeometryProperty = geom;

            ClassDefinition cd = FdoSchemaUtil.CloneClass(c1);

            Assert.IsNotNull(cd);
            FeatureClass fc = cd as FeatureClass;

            Assert.IsNotNull(fc);
            Assert.AreEqual(cd.Name, c1.Name);
            Assert.AreEqual(cd.ClassType, c1.ClassType);
            Assert.IsNotNull(fc.GeometryProperty);
            Assert.IsNotNull(((FeatureClass)c1).GeometryProperty);
            Assert.AreEqual(fc.GeometryProperty.Name, ((FeatureClass)c1).GeometryProperty.Name);
            Assert.AreEqual(cd.Description, c1.Description);
            Assert.AreEqual(cd.Properties.Count, c1.Properties.Count);
            Assert.AreEqual(cd.IdentityProperties.Count, c1.IdentityProperties.Count);

            c1.Dispose();
            c1   = new Class("TestClass", "Test Class");
            id   = new DataPropertyDefinition("ID", "");
            name = new DataPropertyDefinition("Name", "");

            id.DataType        = DataType.DataType_Int32;
            id.IsAutoGenerated = true;
            id.ReadOnly        = true;
            id.Nullable        = false;

            name.DataType = DataType.DataType_String;
            name.Length   = 255;
            name.Nullable = true;

            cd = FdoSchemaUtil.CloneClass(c1);
            Assert.IsNotNull(cd);
            Assert.AreEqual(cd.Name, c1.Name);
            Assert.AreEqual(cd.Description, c1.Description);
            Assert.AreEqual(cd.Properties.Count, c1.Properties.Count);
            Assert.AreEqual(cd.IdentityProperties.Count, c1.IdentityProperties.Count);
        }
コード例 #2
0
 public void TearDown()
 {
     _geodatabase?.Dispose();
     _issuePoints?.Dispose();
 }
コード例 #3
0
        public void TestCloneClass()
        {
            ClassDefinition c1 = new FeatureClass("Test", "Test Feature Class");
            DataPropertyDefinition id = new DataPropertyDefinition("ID", "");
            DataPropertyDefinition name = new DataPropertyDefinition("Name", "");
            id.DataType = DataType.DataType_Int32;
            id.IsAutoGenerated = true;
            id.ReadOnly = true;
            id.Nullable = false;

            name.DataType = DataType.DataType_String;
            name.Length = 255;
            name.Nullable = true;

            GeometricPropertyDefinition geom = new GeometricPropertyDefinition("Geometry", "");
            geom.GeometryTypes = (int)GeometryType.GeometryType_Polygon;
            geom.ReadOnly = false;

            c1.Properties.Add(id);
            c1.Properties.Add(name);
            c1.Properties.Add(geom);
            c1.IdentityProperties.Add(id);

            ((FeatureClass)c1).GeometryProperty = geom;

            ClassDefinition cd = FdoSchemaUtil.CloneClass(c1);
            Assert.IsNotNull(cd);
            FeatureClass fc = cd as FeatureClass;
            Assert.IsNotNull(fc);
            Assert.AreEqual(cd.Name, c1.Name);
            Assert.AreEqual(cd.ClassType, c1.ClassType);
            Assert.IsNotNull(fc.GeometryProperty);
            Assert.IsNotNull(((FeatureClass)c1).GeometryProperty);
            Assert.AreEqual(fc.GeometryProperty.Name, ((FeatureClass)c1).GeometryProperty.Name);
            Assert.AreEqual(cd.Description, c1.Description);
            Assert.AreEqual(cd.Properties.Count, c1.Properties.Count);
            Assert.AreEqual(cd.IdentityProperties.Count, c1.IdentityProperties.Count);

            c1.Dispose();
            c1 = new Class("TestClass", "Test Class");
            id = new DataPropertyDefinition("ID", "");
            name = new DataPropertyDefinition("Name", "");

            id.DataType = DataType.DataType_Int32;
            id.IsAutoGenerated = true;
            id.ReadOnly = true;
            id.Nullable = false;

            name.DataType = DataType.DataType_String;
            name.Length = 255;
            name.Nullable = true;

            cd = FdoSchemaUtil.CloneClass(c1);
            Assert.IsNotNull(cd);
            Assert.AreEqual(cd.Name, c1.Name);
            Assert.AreEqual(cd.Description, c1.Description);
            Assert.AreEqual(cd.Properties.Count, c1.Properties.Count);
            Assert.AreEqual(cd.IdentityProperties.Count, c1.IdentityProperties.Count);
        }