private void CollectionForm_Closing(object sender, CancelEventArgs e)
        {
            // Get Collection Form
            CollectionForm collectionForm = (CollectionForm)sender;

            // Get edited collection object
            object editValue = collectionForm.EditValue;

            // Check if collection edits have been OK'ed or Canceled
            DialogResult dialogResult = collectionForm.DialogResult;

            switch (dialogResult)
            {
            case DialogResult.OK:
                // Get Schema Model
                DiagrammerEnvironment d           = DiagrammerEnvironment.Default;
                SchemaModel           schemaModel = d.SchemaModel;

                // Suspect Model Draws
                schemaModel.Suspend();

                // Get TableItems Collection
                TableItems tableItems = (TableItems)editValue;

                // Store items in new List
                List <TableItem> list = new List <TableItem>();
                foreach (TableItem tableItem in tableItems)
                {
                    list.Add(tableItem);
                }

                // Clear TableItems Collection
                tableItems.Clear();

                // Re-add all items.
                foreach (TableItem tableItem in list)
                {
                    // If the Table property is not set then use TableItems::Add to append the item.
                    // This will ensure that Table, GradientColor, Indent properties are correctly set.
                    // This will also reset the height of the TableItems collection.
                    if (tableItem.Indent == 0f)
                    {
                        tableItems.Add(tableItem);
                    }
                    else
                    {
                        ((IList)tableItems).Add(tableItem);
                    }
                }

                // Refresh Model
                schemaModel.Resume();
                schemaModel.Refresh();

                break;

            case DialogResult.Cancel:
            default:
                // Collection edits are canceled. No need to refresh.
                break;
            }
        }
        //
        // PUBLIC METHODS
        //
        public override void OpenModel()
        {
            List <EsriShape <FeatureClass> > listFeatureClassFrom = new List <EsriShape <FeatureClass> >();
            List <EsriShape <FeatureClass> > listFeatureClassTo   = new List <EsriShape <FeatureClass> >();
            List <EsriShape <Subtype> >      listSubtypeFrom      = new List <EsriShape <Subtype> >();
            List <EsriShape <Subtype> >      listSubtypeTo        = new List <EsriShape <Subtype> >();

            // Exit if invalid
            if (this._geometricNetwork == null)
            {
                return;
            }

            // Suspend Model
            if (ModelSettings.Default.EnableUndoRedo)
            {
                this.UndoList.Suspend();
            }
            this.Suspend();
            this.SuspendEvents = true;

            // Get SchemaModel
            SchemaModel schemaModel = (SchemaModel)this._geometricNetwork.Container;

            // Get Parent FeatureDataset
            Dataset parent = this._geometricNetwork.GetParent();

            if (parent == null)
            {
                return;
            }
            FeatureDataset featureDataset = parent as FeatureDataset;

            if (featureDataset == null)
            {
                return;
            }

            // Add From and To FeatureDatasets
            EsriShape <FeatureDataset> featureDataset1 = new EsriShape <FeatureDataset>(featureDataset);
            EsriShape <FeatureDataset> featureDataset2 = new EsriShape <FeatureDataset>(featureDataset);

            this.Shapes.Add(this.Shapes.CreateKey(), featureDataset1);
            this.Shapes.Add(this.Shapes.CreateKey(), featureDataset2);

            // Add all Child FeatureClasses
            foreach (Dataset dataset in featureDataset.GetChildren())
            {
                if (dataset.GetType() != typeof(FeatureClass))
                {
                    continue;
                }

                // Get FeatureClass
                FeatureClass featureClass = (FeatureClass)dataset;

                // Only allow Simle and Complex Edges
                switch (featureClass.FeatureType)
                {
                case esriFeatureType.esriFTSimpleEdge:
                case esriFeatureType.esriFTComplexEdge:
                case esriFeatureType.esriFTSimpleJunction:
                    break;

                default:
                    continue;
                }

                // Only continue if FeatureClass belongs to the GeometricNetwork
                bool participate = false;
                foreach (ControllerMembership controller in featureClass.ControllerMemberships)
                {
                    if (controller is GeometricNetworkControllerMembership)
                    {
                        GeometricNetworkControllerMembership geometricNetworkControllerMembership = (GeometricNetworkControllerMembership)controller;
                        if (geometricNetworkControllerMembership.GeometricNetworkName == this._geometricNetwork.Name)
                        {
                            participate = true;
                            break;
                        }
                    }
                }
                if (!participate)
                {
                    continue;
                }

                // Get Subtypes
                List <Subtype> subtypes = featureClass.GetSubtypes();

                switch (featureClass.FeatureType)       //  (featureClass.CLSID) {
                {
                case esriFeatureType.esriFTSimpleEdge:  //  EsriRegistry.CLASS_SIMPLEEDGE:
                case esriFeatureType.esriFTComplexEdge: //  EsriRegistry.CLASS_COMPLEXEDGE:
                    // Add From FetaureClasses and Subtypes
                    EsriShape <FeatureClass> featureClass1 = new EsriShape <FeatureClass>(featureClass);
                    this.Shapes.Add(this.Shapes.CreateKey(), featureClass1);
                    listFeatureClassFrom.Add(featureClass1);

                    // Add Line from FeatureDataset to FeatureClass
                    Arrow arrow1 = new Arrow();
                    arrow1.BorderColor    = ModelSettings.Default.DisabledLined;
                    arrow1.DrawBackground = false;
                    Line line1 = new Line(featureDataset1, featureClass1);
                    line1.End.AllowMove   = false;
                    line1.End.Marker      = arrow1;
                    line1.Start.AllowMove = false;
                    line1.BorderColor     = ModelSettings.Default.DisabledLined;
                    this.Lines.Add(this.Lines.CreateKey(), line1);

                    // Add Subtypes and Link to FeatureClass
                    foreach (Subtype subtype in subtypes)
                    {
                        EsriShape <Subtype> sub = new EsriShape <Subtype>(subtype);
                        this.Shapes.Add(this.Shapes.CreateKey(), sub);
                        listSubtypeFrom.Add(sub);
                        Arrow arrow3 = new Arrow();
                        arrow3.BorderColor    = ModelSettings.Default.DisabledLined;
                        arrow3.DrawBackground = false;
                        Line line = new Line(featureClass1, sub);
                        line.End.AllowMove   = false;
                        line.End.Marker      = arrow3;
                        line.Start.AllowMove = false;
                        line.BorderColor     = ModelSettings.Default.DisabledLined;
                        this.Lines.Add(this.Lines.CreateKey(), line);
                    }
                    break;

                case esriFeatureType.esriFTSimpleJunction:     // EsriRegistry.CLASS_SIMPLEJUNCTION:
                    // Add To FetaureClasses and Subtypes
                    EsriShape <FeatureClass> featureClass2 = new EsriShape <FeatureClass>(featureClass);
                    this.Shapes.Add(this.Shapes.CreateKey(), featureClass2);
                    listFeatureClassTo.Add(featureClass2);

                    // Add Line from FeatureDataset to FeatureClass
                    Arrow arrow2 = new Arrow();
                    arrow2.BorderColor    = ModelSettings.Default.DisabledLined;
                    arrow2.DrawBackground = false;
                    Line line2 = new Line(featureClass2, featureDataset2);
                    line2.End.AllowMove   = false;
                    line2.Start.AllowMove = false;
                    line2.Start.Marker    = arrow2;
                    line2.BorderColor     = ModelSettings.Default.DisabledLined;
                    this.Lines.Add(this.Lines.CreateKey(), line2);

                    // Add Subtyes and Link to FeatureClasses
                    foreach (Subtype subtype in subtypes)
                    {
                        EsriShape <Subtype> sub = new EsriShape <Subtype>(subtype);
                        this.Shapes.Add(this.Shapes.CreateKey(), sub);
                        listSubtypeTo.Add(sub);
                        Arrow arrow4 = new Arrow();
                        arrow4.BorderColor    = ModelSettings.Default.DisabledLined;
                        arrow4.DrawBackground = false;
                        Line line = new Line(sub, featureClass2);
                        line.End.AllowMove   = false;
                        line.Start.Marker    = arrow4;
                        line.Start.AllowMove = false;
                        line.BorderColor     = ModelSettings.Default.DisabledLined;
                        this.Lines.Add(this.Lines.CreateKey(), line);
                    }
                    break;
                }
            }

            // Loop Through All Connectivity Rules
            foreach (ConnectivityRule connectivityRule in this._geometricNetwork.ConnectivityRules)
            {
                // Continue only if Edge Connectivity Rule
                if (!(connectivityRule is JunctionConnectivityRule))
                {
                    continue;
                }

                // Get Edge Connectivity Rule
                JunctionConnectivityRule junctionConnectivityRule = (JunctionConnectivityRule)connectivityRule;

                // Origin Table
                EsriTable origin = schemaModel.FindObjectClassOrSubtype(
                    junctionConnectivityRule.EdgeClassID,
                    junctionConnectivityRule.EdgeSubtypeCode);

                // Destination Table
                EsriTable destination = schemaModel.FindObjectClassOrSubtype(
                    junctionConnectivityRule.JunctionClassID,
                    junctionConnectivityRule.SubtypeCode);

                // Origin and Destination Shapes
                Shape shapeOrigin      = null;
                Shape shapeDestiantion = null;

                // Find Origin Shape in Diagram
                foreach (EsriShape <FeatureClass> f in listFeatureClassFrom)
                {
                    if (f.Parent == origin)
                    {
                        shapeOrigin = f;
                        break;
                    }
                }
                if (shapeOrigin == null)
                {
                    foreach (EsriShape <Subtype> s in listSubtypeFrom)
                    {
                        if (s.Parent == origin)
                        {
                            shapeOrigin = s;
                            break;
                        }
                    }
                }

                // Find Destination Shape in Diagram
                foreach (EsriShape <FeatureClass> f in listFeatureClassTo)
                {
                    if (f.Parent == destination)
                    {
                        shapeDestiantion = f;
                        break;
                    }
                }
                if (shapeDestiantion == null)
                {
                    foreach (EsriShape <Subtype> s in listSubtypeTo)
                    {
                        if (s.Parent == destination)
                        {
                            shapeDestiantion = s;
                            break;
                        }
                    }
                }

                // Skip if Origin and Destination Shapes not found
                if (shapeOrigin == null || shapeDestiantion == null)
                {
                    continue;
                }

                EsriLine <JunctionConnectivityRule> line2 = new EsriLine <JunctionConnectivityRule>(junctionConnectivityRule, shapeOrigin, shapeDestiantion);
                this.Lines.Add(this.Lines.CreateKey(), line2);
            }

            // Perform Layout
            this.ExecuteLayout(typeof(HierarchicalLayout), true);

            // Resume and Refresh Model
            this.SuspendEvents = false;
            this.Resume();
            if (ModelSettings.Default.EnableUndoRedo)
            {
                this.UndoList.Resume();
            }
            this.Refresh();
        }
        //
        // PUBLIC METHODS
        //
        public override void OpenModel()
        {
            // Create Origin and Destination Lists
            List <EsriShape <FeatureClass> > listFeatureClassFrom = new List <EsriShape <FeatureClass> >();
            List <EsriShape <FeatureClass> > listFeatureClassTo   = new List <EsriShape <FeatureClass> >();
            List <EsriShape <Subtype> >      listSubtypeFrom      = new List <EsriShape <Subtype> >();
            List <EsriShape <Subtype> >      listSubtypeTo        = new List <EsriShape <Subtype> >();

            // Exit if invalid
            if (this._topology == null)
            {
                return;
            }

            // Suspend Model
            if (ModelSettings.Default.EnableUndoRedo)
            {
                this.UndoList.Suspend();
            }
            this.Suspend();
            this.SuspendEvents = true;

            // Get SchemaModel
            SchemaModel schemaModel = (SchemaModel)this._topology.Container;

            // Get Parent FeatureDataset
            Dataset parent = this._topology.GetParent();

            if (parent == null)
            {
                return;
            }
            FeatureDataset featureDataset = parent as FeatureDataset;

            if (featureDataset == null)
            {
                return;
            }

            // Add From and To FeatureDatasets
            EsriShape <FeatureDataset> featureDataset1 = new EsriShape <FeatureDataset>(featureDataset);
            EsriShape <FeatureDataset> featureDataset2 = new EsriShape <FeatureDataset>(featureDataset);

            this.Shapes.Add(this.Shapes.CreateKey(), featureDataset1);
            this.Shapes.Add(this.Shapes.CreateKey(), featureDataset2);

            // Add all Child FeatureClasses
            foreach (Dataset dataset in featureDataset.GetChildren())
            {
                if (dataset.GetType() != typeof(FeatureClass))
                {
                    continue;
                }

                // Get FeatureClass
                FeatureClass featureClass = (FeatureClass)dataset;

                // Only continue if FeatureClass belongs to the Topology
                bool participate = false;
                foreach (ControllerMembership controller in featureClass.ControllerMemberships)
                {
                    if (controller is TopologyControllerMembership)
                    {
                        TopologyControllerMembership topologyControllerMembership = (TopologyControllerMembership)controller;
                        if (topologyControllerMembership.TopologyName == this._topology.Name)
                        {
                            participate = true;
                            break;
                        }
                    }
                }
                if (!participate)
                {
                    continue;
                }

                // Get Subtypes
                List <Subtype> subtypes = featureClass.GetSubtypes();

                // Add From FetaureClasses and Subtypes
                EsriShape <FeatureClass> featureClass1 = new EsriShape <FeatureClass>(featureClass);
                this.Shapes.Add(this.Shapes.CreateKey(), featureClass1);
                listFeatureClassFrom.Add(featureClass1);

                // Add Line from FeatureDataset to FeatureClass
                Arrow arrow1 = new Arrow();
                arrow1.BorderColor    = ModelSettings.Default.DisabledLined;
                arrow1.DrawBackground = false;
                Line line1 = new Line(featureDataset1, featureClass1);
                line1.End.AllowMove   = false;
                line1.End.Marker      = arrow1;
                line1.Start.AllowMove = false;
                line1.BorderColor     = ModelSettings.Default.DisabledLined;
                this.Lines.Add(this.Lines.CreateKey(), line1);

                // Add Subtypes and Link to FeatureClass
                foreach (Subtype subtype in subtypes)
                {
                    EsriShape <Subtype> sub = new EsriShape <Subtype>(subtype);
                    this.Shapes.Add(this.Shapes.CreateKey(), sub);
                    listSubtypeFrom.Add(sub);
                    Arrow arrow3 = new Arrow();
                    arrow3.BorderColor    = ModelSettings.Default.DisabledLined;
                    arrow3.DrawBackground = false;
                    Line line = new Line(featureClass1, sub);
                    line.End.AllowMove   = false;
                    line.End.Marker      = arrow3;
                    line.Start.AllowMove = false;
                    line.BorderColor     = ModelSettings.Default.DisabledLined;
                    this.Lines.Add(this.Lines.CreateKey(), line);
                }

                // Add To FetaureClasses and Subtypes
                EsriShape <FeatureClass> featureClass2 = new EsriShape <FeatureClass>(featureClass);
                this.Shapes.Add(this.Shapes.CreateKey(), featureClass2);
                listFeatureClassTo.Add(featureClass2);

                // Add Line from FeatureDataset to FeatureClass
                Arrow arrow2 = new Arrow();
                arrow2.BorderColor    = ModelSettings.Default.DisabledLined;
                arrow2.DrawBackground = false;
                Line line2 = new Line(featureClass2, featureDataset2);
                line2.End.AllowMove   = false;
                line2.Start.AllowMove = false;
                line2.Start.Marker    = arrow2;
                line2.BorderColor     = ModelSettings.Default.DisabledLined;
                this.Lines.Add(this.Lines.CreateKey(), line2);

                // Add Subtyes and Link to FeatureClasses
                foreach (Subtype subtype in subtypes)
                {
                    EsriShape <Subtype> sub = new EsriShape <Subtype>(subtype);
                    this.Shapes.Add(this.Shapes.CreateKey(), sub);
                    listSubtypeTo.Add(sub);
                    Arrow arrow4 = new Arrow();
                    arrow4.BorderColor    = ModelSettings.Default.DisabledLined;
                    arrow4.DrawBackground = false;
                    Line line = new Line(sub, featureClass2);
                    line.End.AllowMove   = false;
                    line.Start.Marker    = arrow4;
                    line.Start.AllowMove = false;
                    line.BorderColor     = ModelSettings.Default.DisabledLined;
                    this.Lines.Add(this.Lines.CreateKey(), line);
                }
            }

            // Loop Through All Connectivity Rules
            foreach (TopologyRule topologyRule in this._topology.TopologyRules)
            {
                // Origin Table
                EsriTable origin = null;
                if (topologyRule.AllOriginSubtypes)
                {
                    origin = schemaModel.FindObjectClass(topologyRule.OriginClassId);
                }
                else
                {
                    origin = schemaModel.FindObjectClassOrSubtype(
                        topologyRule.OriginClassId,
                        topologyRule.OriginSubtype);
                }

                // Destination Table
                EsriTable destination = null;
                if (topologyRule.AllDestinationSubtypes)
                {
                    destination = schemaModel.FindObjectClass(topologyRule.DestinationClassId);
                }
                else
                {
                    destination = schemaModel.FindObjectClassOrSubtype(
                        topologyRule.DestinationClassId,
                        topologyRule.DestinationSubtype);
                }

                // Origin and Destination Shapes
                Shape shapeOrigin      = null;
                Shape shapeDestiantion = null;

                // Find Origin Shape in Diagram
                foreach (EsriShape <FeatureClass> f in listFeatureClassFrom)
                {
                    if (f.Parent == origin)
                    {
                        shapeOrigin = f;
                        break;
                    }
                }
                if (shapeOrigin == null)
                {
                    foreach (EsriShape <Subtype> s in listSubtypeFrom)
                    {
                        if (s.Parent == origin)
                        {
                            shapeOrigin = s;
                            break;
                        }
                    }
                }

                // Find Destination Shape in Diagram
                foreach (EsriShape <FeatureClass> f in listFeatureClassTo)
                {
                    if (f.Parent == destination)
                    {
                        shapeDestiantion = f;
                        break;
                    }
                }
                if (shapeDestiantion == null)
                {
                    foreach (EsriShape <Subtype> s in listSubtypeTo)
                    {
                        if (s.Parent == destination)
                        {
                            shapeDestiantion = s;
                            break;
                        }
                    }
                }

                // Skip if Origin and Destination Shapes not found
                if (shapeOrigin == null || shapeDestiantion == null)
                {
                    continue;
                }

                EsriLine <TopologyRule> line2 = new EsriLine <TopologyRule>(topologyRule, shapeOrigin, shapeDestiantion);
                this.Lines.Add(this.Lines.CreateKey(), line2);
            }

            // Perform Layout
            this.ExecuteLayout(typeof(HierarchicalLayout), true);

            // Resume and Refresh Model
            this.SuspendEvents = false;
            this.Resume();
            if (ModelSettings.Default.EnableUndoRedo)
            {
                this.UndoList.Resume();
            }
            this.Refresh();
        }
        public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            if (context == null)
            {
                return(null);
            }
            if (context.Instance == null)
            {
                return(null);
            }

            // RelationshipClass:        OriginClassName, DestinationClassName
            // EdgeConnectivityRule:     DefaultJunctionID, FromClassID, ToClassID
            // JunctionSubtype:          ClassID
            // RelationshipRule:         OriginClass, DestinationClass
            // JunctionConnectivityRule: EdgeClassID, JunctionClassID
            // TopologyRule:             OriginClassId, DestinationClassId
            // NetWeightAssociation:     TableName
            // TerrainDataSource:        FeatureClassName

            // Get Model
            DiagrammerEnvironment diagrammerEnvironment = DiagrammerEnvironment.Default;

            if (diagrammerEnvironment == null)
            {
                return(null);
            }
            SchemaModel schemaModel = diagrammerEnvironment.SchemaModel;

            if (schemaModel == null)
            {
                return(null);
            }

            // Get ObjectClasses
            List <ObjectClass> objectClasses = schemaModel.GetObjectClasses();

            // Create List
            List <string> list = new List <string>();

            if (context.PropertyDescriptor.ComponentType == typeof(RelationshipClass))
            {
                switch (context.PropertyDescriptor.Name)
                {
                case "OriginClassName":
                case "DestinationClassName":
                    foreach (ObjectClass objectClass in objectClasses)
                    {
                        if (objectClass.GetType() == typeof(ObjectClass) ||
                            objectClass.GetType() == typeof(FeatureClass) ||
                            objectClass.GetType() == typeof(RasterCatalog))
                        {
                            list.Add(objectClass.Name);
                        }
                    }
                    break;
                }
            }
            else if (context.PropertyDescriptor.ComponentType == typeof(EdgeConnectivityRule))
            {
                switch (context.PropertyDescriptor.Name)
                {
                case "DefaultJunctionID":
                    foreach (ObjectClass objectClass in objectClasses)
                    {
                        FeatureClass featureClass = objectClass as FeatureClass;
                        if (featureClass == null)
                        {
                            continue;
                        }
                        switch (featureClass.FeatureType)                  //  (objectClass.CLSID) {
                        {
                        case esriFeatureType.esriFTSimpleJunction:         // EsriRegistry.CLASS_SIMPLEJUNCTION:
                            list.Add(objectClass.Name);
                            break;
                        }
                    }
                    break;

                case "FromClassID":
                case "ToClassID":
                    foreach (ObjectClass objectClass in objectClasses)
                    {
                        FeatureClass featureClass = objectClass as FeatureClass;
                        if (featureClass == null)
                        {
                            continue;
                        }
                        switch (featureClass.FeatureType)               // (objectClass.CLSID) {
                        {
                        case esriFeatureType.esriFTComplexEdge:         // EsriRegistry.CLASS_COMPLEXEDGE:
                        case esriFeatureType.esriFTSimpleEdge:          // EsriRegistry.CLASS_SIMPLEEDGE:
                            list.Add(objectClass.Name);
                            break;
                        }
                    }
                    break;
                }
            }
            else if (context.PropertyDescriptor.ComponentType == typeof(JunctionSubtype))
            {
                switch (context.PropertyDescriptor.Name)
                {
                case "ClassID":
                    foreach (ObjectClass objectClass in objectClasses)
                    {
                        FeatureClass featureClass = objectClass as FeatureClass;
                        if (featureClass == null)
                        {
                            continue;
                        }
                        switch (featureClass.FeatureType)                  // (objectClass.CLSID) {
                        {
                        case esriFeatureType.esriFTSimpleJunction:         // EsriRegistry.CLASS_SIMPLEJUNCTION:
                            list.Add(objectClass.Name);
                            break;
                        }
                    }
                    break;
                }
            }
            else if (context.PropertyDescriptor.ComponentType == typeof(RelationshipRule))
            {
                switch (context.PropertyDescriptor.Name)
                {
                case "OriginClass":
                case "DestinationClass":
                    foreach (ObjectClass objectClass in objectClasses)
                    {
                        if (objectClass.GetType() == typeof(ObjectClass) ||
                            objectClass.GetType() == typeof(FeatureClass))
                        {
                            list.Add(objectClass.Name);
                        }
                    }
                    break;
                }
            }
            else if (context.PropertyDescriptor.ComponentType == typeof(JunctionConnectivityRule))
            {
                switch (context.PropertyDescriptor.Name)
                {
                case "EdgeClassID":
                    foreach (ObjectClass objectClass in objectClasses)
                    {
                        FeatureClass featureClass = objectClass as FeatureClass;
                        if (featureClass == null)
                        {
                            continue;
                        }
                        switch (featureClass.FeatureType)               // (objectClass.CLSID) {
                        {
                        case esriFeatureType.esriFTComplexEdge:         // EsriRegistry.CLASS_COMPLEXEDGE:
                        case esriFeatureType.esriFTSimpleEdge:          // EsriRegistry.CLASS_SIMPLEEDGE:
                            list.Add(objectClass.Name);
                            break;
                        }
                    }
                    break;

                case "JunctionClassID":
                    foreach (ObjectClass objectClass in objectClasses)
                    {
                        FeatureClass featureClass = objectClass as FeatureClass;
                        if (featureClass == null)
                        {
                            continue;
                        }
                        switch (featureClass.FeatureType)                  // (objectClass.CLSID) {
                        {
                        case esriFeatureType.esriFTSimpleJunction:         // EsriRegistry.CLASS_SIMPLEJUNCTION:
                            list.Add(objectClass.Name);
                            break;
                        }
                    }
                    break;
                }
            }
            else if (context.PropertyDescriptor.ComponentType == typeof(TopologyRule))
            {
                switch (context.PropertyDescriptor.Name)
                {
                case "OriginClassId":
                case "DestinationClassId":
                    foreach (ObjectClass objectClass in objectClasses)
                    {
                        if (objectClass.GetType() == typeof(FeatureClass))
                        {
                            list.Add(objectClass.Name);
                        }
                    }
                    break;
                }
            }
            else if (context.PropertyDescriptor.ComponentType == typeof(NetWeightAssociation))
            {
                switch (context.PropertyDescriptor.Name)
                {
                case "TableName":
                    foreach (ObjectClass objectClass in objectClasses)
                    {
                        FeatureClass featureClass = objectClass as FeatureClass;
                        if (featureClass == null)
                        {
                            continue;
                        }
                        switch (featureClass.FeatureType)                  // (objectClass.CLSID) {
                        {
                        case esriFeatureType.esriFTComplexEdge:            // EsriRegistry.CLASS_COMPLEXEDGE:
                        case esriFeatureType.esriFTSimpleEdge:             // EsriRegistry.CLASS_SIMPLEEDGE:
                        case esriFeatureType.esriFTSimpleJunction:         // EsriRegistry.CLASS_SIMPLEJUNCTION:
                            list.Add(objectClass.Name);
                            break;
                        }
                    }
                    break;
                }
            }
            else if (context.PropertyDescriptor.ComponentType == typeof(TerrainDataSource))
            {
                switch (context.PropertyDescriptor.Name)
                {
                case "FeatureClassName":
                    TerrainDataSource terrainDataSource = (TerrainDataSource)context.Instance;
                    SchemaModel       model             = DiagrammerEnvironment.Default.SchemaModel;
                    if (model == null)
                    {
                        break;
                    }
                    Terrain        terrain        = model.FindParent(terrainDataSource);
                    FeatureDataset featureDataset = terrain.GetParent() as FeatureDataset;
                    if (featureDataset == null)
                    {
                        break;
                    }
                    foreach (Dataset dataset in featureDataset.GetChildren())
                    {
                        if (dataset.DatasetType == esriDatasetType.esriDTFeatureClass)
                        {
                            list.Add(dataset.Name);
                        }
                    }
                    break;
                }
            }

            // Sort List
            list.Sort();
            list.Insert(0, Resources.TEXT_NONE_BR);

            // Return List
            StandardValuesCollection svc = new StandardValuesCollection(list);

            return(svc);
        }
Ejemplo n.º 5
0
        public override void Errors(List <Error> list)
        {
            // Get Model
            DiagrammerEnvironment diagrammerEnvironment = DiagrammerEnvironment.Default;
            SchemaModel           schemaModel           = diagrammerEnvironment.SchemaModel;

            // Domain Name
            if (string.IsNullOrEmpty(this._name))
            {
                // Domain name cannot be null or empty
                list.Add(new ErrorTable(this, "Domain name cannot be empty", ErrorType.Error));
            }
            else
            {
                // Get Validator
                Validator validator = WorkspaceValidator.Default.Validator;

                // Name must not contain invalid characters. Spaces are valid.
                string message = null;
                string name    = this._name.Replace(" ", string.Empty);
                if (validator.ContainsInvalidCharacters(name, out message))
                {
                    list.Add(new ErrorTable(this, message, ErrorType.Error));
                }

                // Domain name must be less thab 255 characters.
                if (this._name.Length > 255)
                {
                    list.Add(new ErrorTable(this, "Domain name is more than 255 characters long", ErrorType.Error));
                }
            }

            // Owner
            if (!string.IsNullOrEmpty(this._owner))
            {
                // Owner must be less than 255 characters.
                if (this._owner.Length > 255)
                {
                    list.Add(new ErrorTable(this, "Owner name is more than 255 characters long", ErrorType.Error));
                }

                // Owner cannot contain spaces.
                if (this._owner.IndexOf(" ") != -1)
                {
                    list.Add(new ErrorTable(this, "Owner name cannot contain spaces", ErrorType.Error));
                }
            }

            // Description must be less than 255 characters.
            if (!string.IsNullOrEmpty(this._description))
            {
                if (this._description.Length > 255)
                {
                    list.Add(new ErrorTable(this, "Description is more than 255 characters long", ErrorType.Error));
                }
            }

            // Is this domain unused?
            if (!string.IsNullOrEmpty(this._name))
            {
                bool used = false;
                List <ObjectClass> objectClasses = schemaModel.GetObjectClasses();
                foreach (ObjectClass objectClass in objectClasses)
                {
                    List <Field> fields = objectClass.GetFields();
                    foreach (Field field in fields)
                    {
                        if (field.Domain == this._name)
                        {
                            used = true;
                            break;
                        }
                    }
                    List <Subtype> subtypes = objectClass.GetSubtypes();
                    foreach (Subtype subtype in subtypes)
                    {
                        List <SubtypeField> subtypeFields = subtype.GetSubtypeFields();
                        foreach (SubtypeField subtypeField in subtypeFields)
                        {
                            if (subtypeField.DomainName == this._name)
                            {
                                used = true;
                                break;
                            }
                        }
                        if (used)
                        {
                            break;
                        }
                    }
                }
                if (!used)
                {
                    string message = string.Format("Domain [{0}] is not used by any Table or FeatureClass", this._name);
                    list.Add(new ErrorTable(this, message, ErrorType.Warning));
                }
            }
        }
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            if (context == null)
            {
                return(null);
            }
            if (context.Instance == null)
            {
                return(null);
            }

            if (value.GetType() == typeof(string))
            {
                string text = Convert.ToString(value);

                if (context.PropertyDescriptor.ComponentType == typeof(RelationshipClass))
                {
                    switch (context.PropertyDescriptor.Name)
                    {
                    case "OriginClassName":
                    case "DestinationClassName":
                        if (text == string.Empty ||
                            text == Resources.TEXT_NONE_BR)
                        {
                            return(string.Empty);
                        }
                        return(text);
                    }
                }
                else if (context.PropertyDescriptor.ComponentType == typeof(EdgeConnectivityRule))
                {
                    switch (context.PropertyDescriptor.Name)
                    {
                    case "DefaultJunctionID":
                    case "FromClassID":
                    case "ToClassID":
                        if (text == string.Empty ||
                            text == Resources.TEXT_NONE_BR)
                        {
                            return(-1);
                        }
                        DiagrammerEnvironment de          = DiagrammerEnvironment.Default;
                        SchemaModel           model       = de.SchemaModel;
                        ObjectClass           objectClass = model.FindObjectClass(text);
                        if (objectClass == null)
                        {
                            return(-1);
                        }
                        return(objectClass.DSID);
                    }
                }
                else if (context.PropertyDescriptor.ComponentType == typeof(JunctionSubtype))
                {
                    switch (context.PropertyDescriptor.Name)
                    {
                    case "ClassID":
                        if (text == string.Empty ||
                            text == Resources.TEXT_NONE_BR)
                        {
                            return(-1);
                        }
                        DiagrammerEnvironment de          = DiagrammerEnvironment.Default;
                        SchemaModel           model       = de.SchemaModel;
                        ObjectClass           objectClass = model.FindObjectClass(text);
                        if (objectClass == null)
                        {
                            return(-1);
                        }
                        return(objectClass.DSID);
                    }
                }
                else if (context.PropertyDescriptor.ComponentType == typeof(RelationshipRule))
                {
                    switch (context.PropertyDescriptor.Name)
                    {
                    case "OriginClass":
                    case "DestinationClass":
                        if (text == string.Empty ||
                            text == Resources.TEXT_NONE_BR)
                        {
                            return(-1);
                        }
                        DiagrammerEnvironment de          = DiagrammerEnvironment.Default;
                        SchemaModel           model       = de.SchemaModel;
                        ObjectClass           objectClass = model.FindObjectClass(text);
                        if (objectClass == null)
                        {
                            return(-1);
                        }
                        return(objectClass.DSID);
                    }
                }
                else if (context.PropertyDescriptor.ComponentType == typeof(JunctionConnectivityRule))
                {
                    switch (context.PropertyDescriptor.Name)
                    {
                    case "EdgeClassID":
                    case "JunctionClassID":
                        if (text == string.Empty ||
                            text == Resources.TEXT_NONE_BR)
                        {
                            return(-1);
                        }
                        DiagrammerEnvironment de          = DiagrammerEnvironment.Default;
                        SchemaModel           model       = de.SchemaModel;
                        ObjectClass           objectClass = model.FindObjectClass(text);
                        if (objectClass == null)
                        {
                            return(-1);
                        }
                        return(objectClass.DSID);
                    }
                }
                else if (context.PropertyDescriptor.ComponentType == typeof(TopologyRule))
                {
                    switch (context.PropertyDescriptor.Name)
                    {
                    case "OriginClassId":
                    case "DestinationClassId":
                        if (text == string.Empty ||
                            text == Resources.TEXT_NONE_BR)
                        {
                            return(-1);
                        }
                        DiagrammerEnvironment de          = DiagrammerEnvironment.Default;
                        SchemaModel           model       = de.SchemaModel;
                        ObjectClass           objectClass = model.FindObjectClass(text);
                        if (objectClass == null)
                        {
                            return(-1);
                        }
                        return(objectClass.DSID);
                    }
                }
                else if (context.PropertyDescriptor.ComponentType == typeof(NetWeightAssociation))
                {
                    switch (context.PropertyDescriptor.Name)
                    {
                    case "TableName":
                        if (text == string.Empty ||
                            text == Resources.TEXT_NONE_BR)
                        {
                            return(string.Empty);
                        }
                        return(text);
                    }
                }
                else if (context.PropertyDescriptor.ComponentType == typeof(TerrainDataSource))
                {
                    switch (context.PropertyDescriptor.Name)
                    {
                    case "FeatureClassName":
                        if (text == string.Empty ||
                            text == Resources.TEXT_NONE_BR)
                        {
                            return(string.Empty);
                        }
                        return(text);
                    }
                }
            }

            return(base.ConvertFrom(context, culture, value));
        }
Ejemplo n.º 7
0
        private void Model_ElementInvalid(object sender, ElementEventArgs e)
        {
            // Exit if GeometricNetwork Does not Exist
            if (this._topology == null)
            {
                return;
            }

            // Get Element
            Element element = e.Value;

            if (element == null)
            {
                return;
            }
            EsriLine <TopologyControllerMembership> line = element as EsriLine <TopologyControllerMembership>;

            if (line == null)
            {
                return;
            }

            // Get Controller
            TopologyControllerMembership controller = line.Parent;

            // Suspend Rule Events
            controller.Suspend();

            // Get Start and End Elements
            Element elementStart = line.Start.Shape;
            Element elementEnd   = line.End.Shape;

            // Update GeometricNetwork Name Property
            if (elementStart == null)
            {
                controller.TopologyName = string.Empty;
            }
            else if (elementStart is EsriShape <Topology> )
            {
                EsriShape <Topology> shape    = (EsriShape <Topology>)elementStart;
                Topology             topology = shape.Parent;
                controller.TopologyName = topology.Name;
            }

            //
            DiagrammerEnvironment diagrammerEnvironment = DiagrammerEnvironment.Default;
            SchemaModel           schemaModel           = diagrammerEnvironment.SchemaModel;
            ObjectClass           objectClass           = schemaModel.FindParent(controller);

            if (objectClass != null)
            {
                objectClass.ControllerMemberships.Remove(controller);
            }

            if (elementEnd == null)
            {
            }
            else if (elementEnd is EsriShape <FeatureClass> )
            {
                EsriShape <FeatureClass> es           = (EsriShape <FeatureClass>)elementEnd;
                FeatureClass             featureClass = es.Parent;
                featureClass.ControllerMemberships.Add(controller);
            }

            // Resume Controller Events
            controller.Resume();
        }
Ejemplo n.º 8
0
        protected override void WriteInnerXml(XmlWriter writer)
        {
            // Write Base Inner Xml
            base.WriteInnerXml(writer);

            // Get Model
            SchemaModel model = (SchemaModel)base.Container;

            // <HasOID></HasOID>
            bool hasOID = !(string.IsNullOrEmpty(this._oidFieldName));

            writer.WriteStartElement("HasOID");
            writer.WriteValue(hasOID);
            writer.WriteEndElement();

            // <OIDFieldName></OIDFieldName>
            writer.WriteStartElement("OIDFieldName");
            if (hasOID)
            {
                writer.WriteValue(this._oidFieldName);
            }
            writer.WriteEndElement();

            // <Fields>
            TableGroup tableGroupField = (TableGroup)this.Groups[0];

            writer.WriteStartElement("Fields");
            writer.WriteAttributeString(Xml._XSI, Xml._TYPE, null, "esri:Fields");

            // <FieldArray>
            writer.WriteStartElement("FieldArray");
            writer.WriteAttributeString(Xml._XSI, Xml._TYPE, null, "esri:ArrayOfField");

            // <Field></Field>
            foreach (Field field in tableGroupField.Rows)
            {
                field.WriteXml(writer);
            }

            // </FieldArray>
            writer.WriteEndElement();

            // </Fields>
            writer.WriteEndElement();

            // <Indexes>
            TableGroup tableGroupIndex = (TableGroup)this.Groups[1];

            writer.WriteStartElement("Indexes");
            writer.WriteAttributeString(Xml._XSI, Xml._TYPE, null, "esri:Indexes");

            // <IndexArray>
            writer.WriteStartElement("IndexArray");
            writer.WriteAttributeString(Xml._XSI, Xml._TYPE, null, "esri:ArrayOfIndex");

            // <Index>
            foreach (Index index in tableGroupIndex.Groups)
            {
                index.WriteXml(writer);
            }

            // </IndexArray>
            writer.WriteEndElement();

            // </Indexes>
            writer.WriteEndElement();

            // <CLSID></CLSID>
            writer.WriteStartElement("CLSID");
            writer.WriteValue(this._clsid);
            writer.WriteEndElement();

            // <EXTCLSID></EXTCLSID>
            writer.WriteStartElement("EXTCLSID");
            if (!string.IsNullOrEmpty(this._extClsid))
            {
                writer.WriteValue(this._extClsid);
            }
            writer.WriteEndElement();

            // <RelationshipClassNames>
            writer.WriteStartElement("RelationshipClassNames");
            writer.WriteAttributeString(Xml._XSI, Xml._TYPE, null, "esri:Names");

            // <Name></Name>
            List <Dataset> datasets = model.GetDatasets(new Type[] { typeof(RelationshipClass) });

            foreach (RelationshipClass relationshipClass in datasets)
            {
                if (relationshipClass.OriginClassName == this.Name ||
                    relationshipClass.DestinationClassName == this.Name)
                {
                    // <Name></Name>
                    writer.WriteStartElement("Name");
                    writer.WriteValue(relationshipClass.Name);
                    writer.WriteEndElement();
                }
            }

            // </RelationshipClassNames>
            writer.WriteEndElement();

            // <AliasName></AliasName>
            writer.WriteStartElement("AliasName");
            writer.WriteValue(this._aliasName);
            writer.WriteEndElement();

            // <ModelName></ModelName>
            writer.WriteStartElement("ModelName");
            if (!string.IsNullOrEmpty(this._modelName))
            {
                writer.WriteValue(this._modelName);
            }
            writer.WriteEndElement();

            // <HasGlobalID></HasGlobalID>
            bool hasGlobalID = !(string.IsNullOrEmpty(this._globalIDFieldName));

            writer.WriteStartElement("HasGlobalID");
            writer.WriteValue(hasGlobalID);
            writer.WriteEndElement();

            // <GlobalIDFieldName></GlobalIDFieldName>
            writer.WriteStartElement("GlobalIDFieldName");
            if (hasGlobalID)
            {
                writer.WriteValue(this._globalIDFieldName);
            }
            writer.WriteEndElement();

            // <RasterFieldName></RasterFieldName>
            writer.WriteStartElement("RasterFieldName");
            if (!string.IsNullOrEmpty(this._rasterFieldName))
            {
                writer.WriteValue(this._rasterFieldName);
            }
            writer.WriteEndElement();

            // <ExtensionProperties>
            writer.WriteStartElement("ExtensionProperties");
            writer.WriteAttributeString(Xml._XSI, Xml._TYPE, null, "esri:PropertySet");

            // <PropertyArray>
            writer.WriteStartElement("PropertyArray");
            writer.WriteAttributeString(Xml._XSI, Xml._TYPE, null, "esri:ArrayOfPropertySetProperty");

            foreach (Property property in this._extensionProperties)
            {
                // <PropertySetProperty></PropertySetProperty>
                property.WriteXml(writer);
            }

            // </PropertyArray>
            writer.WriteEndElement();

            // </ExtensionProperties>
            writer.WriteEndElement();

            // Check if there are any subtypes
            List <Subtype> subtypes = this.GetSubtypes();

            // Validate Subtypes
            int defaultSubtypeCode = -1;

            foreach (Subtype subtype in subtypes)
            {
                if (subtype.Default)
                {
                    defaultSubtypeCode = subtype.SubtypeCode;
                }
            }

            // Write Subtypes
            if (subtypes.Count > 0)
            {
                // <SubtypeFieldName>
                writer.WriteStartElement("SubtypeFieldName");
                writer.WriteValue(this._subtypeFieldName);
                writer.WriteEndElement();

                // <DefaultSubtypeCode>
                writer.WriteStartElement("DefaultSubtypeCode");
                writer.WriteValue(defaultSubtypeCode);
                writer.WriteEndElement();

                // <Subtypes>
                writer.WriteStartElement("Subtypes");
                writer.WriteAttributeString(Xml._XSI, Xml._TYPE, null, "esri:ArrayOfSubtype");

                // <Subtype></Subtype>
                foreach (Subtype subtype in subtypes)
                {
                    subtype.WriteXml(writer);
                }

                // </Subtypes>
                writer.WriteEndElement();
            }

            // <ControllerMemberships>
            writer.WriteStartElement("ControllerMemberships");
            writer.WriteAttributeString(Xml._XSI, Xml._TYPE, null, "esri:ArrayOfControllerMembership");

            // <ControllerMembership></ControllerMembership>
            foreach (ControllerMembership controllerMembership in this._controllerMemberships)
            {
                controllerMembership.WriteXml(writer);
            }

            // </ControllerMemberships>
            writer.WriteEndElement();
        }
Ejemplo n.º 9
0
        //
        // PROTECTED METHODS
        //
        protected override void WriteInnerXml(XmlWriter writer)
        {
            //
            base.WriteInnerXml(writer);

            // Get Model
            SchemaModel model = DiagrammerEnvironment.Default.SchemaModel;

            // <Name></Name>
            writer.WriteStartElement("Name");
            writer.WriteValue(this._name);
            writer.WriteEndElement();

            // <Type></Type>
            writer.WriteStartElement("Type");
            writer.WriteValue(this._fieldType.ToString());
            writer.WriteEndElement();

            // <IsNullable></IsNullable>
            writer.WriteStartElement("IsNullable");
            writer.WriteValue(this._isNullable);
            writer.WriteEndElement();

            // <Length></Length>
            writer.WriteStartElement("Length");
            writer.WriteValue(this._length);
            writer.WriteEndElement();

            // <Precision></Precision>
            writer.WriteStartElement("Precision");
            writer.WriteValue(this._precision);
            writer.WriteEndElement();

            // <Scale></Scale>
            writer.WriteStartElement("Scale");
            writer.WriteValue(this._scale);
            writer.WriteEndElement();

            // <Required></Required>
            if (this._required)
            {
                writer.WriteStartElement("Required");
                writer.WriteValue(this._required);
                writer.WriteEndElement();
            }

            // <Editable></Editable>
            if (!this._editable)
            {
                writer.WriteStartElement("Editable");
                writer.WriteValue(this._editable);
                writer.WriteEndElement();
            }

            // <DomainFixed></DomainFixed>
            if (this._domainFixed)
            {
                writer.WriteStartElement("DomainFixed");
                writer.WriteValue(this._domainFixed);
                writer.WriteEndElement();
            }

            // <GeometryDef></GeometryDef>
            if (this._geometryDef != null)
            {
                this._geometryDef.WriteXml(writer);
            }

            // <AliasName></AliasName>
            if (!string.IsNullOrEmpty(this._aliasName))
            {
                writer.WriteStartElement("AliasName");
                writer.WriteValue(this._aliasName);
                writer.WriteEndElement();
            }

            // <ModelName></ModelName>
            if (!string.IsNullOrEmpty(this._modelName))
            {
                writer.WriteStartElement("ModelName");
                writer.WriteValue(this._modelName);
                writer.WriteEndElement();
            }

            // <DefaultValue></DefaultValue>
            if (!string.IsNullOrEmpty(this._defaultValue))
            {
                writer.WriteStartElement("DefaultValue");
                switch (this._fieldType)
                {
                case esriFieldType.esriFieldTypeSmallInteger:
                    writer.WriteAttributeString(Xml._XSI, Xml._TYPE, null, "xs:short");
                    break;

                case esriFieldType.esriFieldTypeInteger:
                    writer.WriteAttributeString(Xml._XSI, Xml._TYPE, null, "xs:int");
                    break;

                case esriFieldType.esriFieldTypeSingle:
                    writer.WriteAttributeString(Xml._XSI, Xml._TYPE, null, "xs:float");
                    break;

                case esriFieldType.esriFieldTypeDouble:
                    writer.WriteAttributeString(Xml._XSI, Xml._TYPE, null, "xs:double");
                    break;

                case esriFieldType.esriFieldTypeDate:
                    writer.WriteAttributeString(Xml._XSI, Xml._TYPE, null, "xs:dateTime");
                    break;

                case esriFieldType.esriFieldTypeString:
                    writer.WriteAttributeString(Xml._XSI, Xml._TYPE, null, "xs:string");
                    break;

                default:
                    break;
                }
                writer.WriteValue(this._defaultValue);
                writer.WriteEndElement();
            }

            // <Domain></Domain>
            if (!string.IsNullOrEmpty(this._domain))
            {
                //SchemaModel model = (SchemaModel)this.Table.Container;
                Domain domain = model.FindDomain(this._domain);
                if (domain != null)
                {
                    domain.WriteXml(writer);
                }
            }

            // <RasterDef></RasterDef>
            if (this._rasterDef != null)
            {
                this._rasterDef.WriteXml(writer);
            }
        }
Ejemplo n.º 10
0
        public override void Errors(List <Error> list)
        {
            // Get Parent ObjectClass
            ObjectClass objectClass = (ObjectClass)this.Table;

            // Get ObjectClass Fields
            List <Field> fields = objectClass.GetFields();

            // Get Schema Model
            SchemaModel model = (SchemaModel)objectClass.Container;

            // Add GeometryDef Errors
            if (this._geometryDef != null)
            {
                this._geometryDef.Errors(list, (EsriTable)this.Table);
            }

            // GeometryDef only valid for Geometry Fields
            switch (this._fieldType)
            {
            case esriFieldType.esriFieldTypeGeometry:
                if (this._geometryDef == null)
                {
                    list.Add(new ErrorTableRow(this, "Geometry Fields Must have a GeometryDef defined.", ErrorType.Error));
                }
                break;

            case esriFieldType.esriFieldTypeBlob:
            case esriFieldType.esriFieldTypeDate:
            case esriFieldType.esriFieldTypeDouble:
            case esriFieldType.esriFieldTypeGlobalID:
            case esriFieldType.esriFieldTypeGUID:
            case esriFieldType.esriFieldTypeInteger:
            case esriFieldType.esriFieldTypeOID:
            case esriFieldType.esriFieldTypeRaster:
            case esriFieldType.esriFieldTypeSingle:
            case esriFieldType.esriFieldTypeSmallInteger:
            case esriFieldType.esriFieldTypeString:
            case esriFieldType.esriFieldTypeXML:
                if (this._geometryDef != null)
                {
                    list.Add(new ErrorTableRow(this, "Only Geometry Fields can have a GeometryDef defined.", ErrorType.Error));
                }
                break;
            }

            // Raster Fields can have a RasterDef
            switch (this._fieldType)
            {
            case esriFieldType.esriFieldTypeRaster:
                if (this._rasterDef == null)
                {
                    string message = string.Format("The raster field [{0}] does not have a RasterDef assigned", this._name);
                    list.Add(new ErrorTableRow(this, message, ErrorType.Error));
                }
                break;

            case esriFieldType.esriFieldTypeBlob:
            case esriFieldType.esriFieldTypeDate:
            case esriFieldType.esriFieldTypeDouble:
            case esriFieldType.esriFieldTypeGeometry:
            case esriFieldType.esriFieldTypeGUID:
            case esriFieldType.esriFieldTypeInteger:
            case esriFieldType.esriFieldTypeOID:
            case esriFieldType.esriFieldTypeSingle:
            case esriFieldType.esriFieldTypeSmallInteger:
            case esriFieldType.esriFieldTypeString:
            case esriFieldType.esriFieldTypeGlobalID:
            case esriFieldType.esriFieldTypeXML:
                if (this._rasterDef != null)
                {
                    string message = string.Format("The field [{0}] is invalid. Only raster fields can have a RasterDef", this._name);
                    list.Add(new ErrorTableRow(this, message, ErrorType.Error));
                }
                break;
            }

            // Field Name Null or Empty
            if (string.IsNullOrEmpty(this._name))
            {
                list.Add(new ErrorTableRow(this, "Field names cannot be empty", ErrorType.Error));
            }

            // Validate Field Name
            if (!string.IsNullOrEmpty(this._name))
            {
                // Get Validator
                Validator validator = WorkspaceValidator.Default.Validator;
                string    message   = null;
                if (!validator.ValidateFieldName(this._name, out message))
                {
                    string message2 = string.Format("Field [{0}] {1}", this._name, message);
                    list.Add(new ErrorTableRow(this, message2, ErrorType.Error));
                }
            }

            // Alias name more than 255 characters long
            if (!string.IsNullOrEmpty(this._aliasName))
            {
                if (this._aliasName.Length > 255)
                {
                    string message = string.Format("Field [{0}]. Alias name cannot be longer than 255 characters", this._name);
                    list.Add(new ErrorTableRow(this, message, ErrorType.Error));
                }
            }

            // Find Domain
            Domain domain = null;

            if (!string.IsNullOrEmpty(this._domain))
            {
                domain = model.FindDomain(this._domain);

                if (domain == null)
                {
                    // Domain does not exit
                    string message = string.Format("The domain [{0}] for field [{1}] does not exist", this._domain, this._name);
                    list.Add(new ErrorTableRow(this, message, ErrorType.Error));
                }
                else
                {
                    // Compare domain and field types
                    if (this._fieldType != domain.FieldType)
                    {
                        string message = string.Format("The field [{0}] and assigned domain [{1}] do not have matching field types", this._name, this._domain);
                        list.Add(new ErrorTableRow(this, message, ErrorType.Error));
                    }

                    // Check Default Value
                    if (!string.IsNullOrEmpty(this._defaultValue))
                    {
                        string message = null;
                        if (!domain.IsValid(this._defaultValue, out message))
                        {
                            list.Add(new ErrorTableRow(this, message, ErrorType.Warning));
                        }
                    }

                    // Check if a domain value is too long for the text field
                    if (this._fieldType == esriFieldType.esriFieldTypeString &&
                        domain.FieldType == esriFieldType.esriFieldTypeString &&
                        domain.GetType() == typeof(DomainCodedValue))
                    {
                        DomainCodedValue domain2 = (DomainCodedValue)domain;
                        foreach (DomainCodedValueRow x in domain2.CodedValues)
                        {
                            if (string.IsNullOrEmpty(x.Code))
                            {
                                continue;
                            }
                            if (x.Code.Length > this._length)
                            {
                                string message = string.Format("The domain [{0}] has a value [{1}] that is too long for the field [{2}]", this._domain, x, this._name);
                                list.Add(new ErrorTableRow(this, message, ErrorType.Error));
                            }
                        }
                    }
                }
            }

            // Check validity of default value against field type
            if (!string.IsNullOrEmpty(this._defaultValue))
            {
                string message;
                if (!GeodatabaseUtility.IsValidateValue(this._fieldType, this._defaultValue, out message))
                {
                    string message2 = string.Format("Default value '{0}' {1}", this._defaultValue, message);
                    list.Add(new ErrorTableRow(this, message2, ErrorType.Error));
                }
            }

            // Check for unsupported field types
            switch (this._fieldType)
            {
            case esriFieldType.esriFieldTypeBlob:
            case esriFieldType.esriFieldTypeDate:
            case esriFieldType.esriFieldTypeDouble:
            case esriFieldType.esriFieldTypeGeometry:
            case esriFieldType.esriFieldTypeGUID:
            case esriFieldType.esriFieldTypeInteger:
            case esriFieldType.esriFieldTypeOID:
            case esriFieldType.esriFieldTypeRaster:
            case esriFieldType.esriFieldTypeSingle:
            case esriFieldType.esriFieldTypeSmallInteger:
            case esriFieldType.esriFieldTypeString:
            case esriFieldType.esriFieldTypeGlobalID:
                break;

            case esriFieldType.esriFieldTypeXML:
                string message = string.Format("Field type '{0}' is unsupported", this._fieldType.ToString());
                list.Add(new ErrorTableRow(this, message, ErrorType.Error));
                break;
            }

            // Length must be > 0
            if (this._length < 0)
            {
                list.Add(new ErrorTableRow(this, "Field length cannot be less than zero", ErrorType.Error));
            }

            // ModelName cannot be longer than 255 characters
            if (!(string.IsNullOrEmpty(this._modelName)))
            {
                if (this._modelName.Length > 255)
                {
                    list.Add(new ErrorTableRow(this, "Model name cannot be greater than 255 characters long", ErrorType.Error));
                }
            }

            // Precision must be > 0
            if (this._precision < 0)
            {
                list.Add(new ErrorTableRow(this, "Field precision cannot be less than zero", ErrorType.Error));
            }

            // Scale must be > 0
            if (this._scale < 0)
            {
                list.Add(new ErrorTableRow(this, "Field scake cannot be less than zero", ErrorType.Error));
            }

            // IsNullable
            if (this._isNullable)
            {
                switch (this._fieldType)
                {
                case esriFieldType.esriFieldTypeBlob:
                case esriFieldType.esriFieldTypeDate:
                case esriFieldType.esriFieldTypeDouble:
                case esriFieldType.esriFieldTypeGeometry:
                case esriFieldType.esriFieldTypeGUID:
                case esriFieldType.esriFieldTypeInteger:
                case esriFieldType.esriFieldTypeRaster:
                case esriFieldType.esriFieldTypeSingle:
                case esriFieldType.esriFieldTypeSmallInteger:
                case esriFieldType.esriFieldTypeString:
                case esriFieldType.esriFieldTypeXML:
                    break;

                case esriFieldType.esriFieldTypeGlobalID:
                case esriFieldType.esriFieldTypeOID:
                    string message = string.Format("Field type '{0}' cannot have IsNullable = True", this._fieldType.ToString());
                    list.Add(new ErrorTableRow(this, message, ErrorType.Error));
                    break;
                }
            }
        }