コード例 #1
0
        public override void Errors(List <Error> list)
        {
            // Field Name
            if (string.IsNullOrEmpty(this._name))
            {
                list.Add(new ErrorTableRow(this, "Index Field names can not be empty", ErrorType.Error));
            }
            else
            {
                // Get Parent Index
                Index index = (Index)base.Parent;

                // Get Sibling IndexFields
                List <IndexField> indexFields = index.GetIndexFields();

                // Check for duplicate IndexField names
                foreach (IndexField indexField in indexFields)
                {
                    if (indexField == this)
                    {
                        continue;
                    }
                    if (indexField.Name == this._name)
                    {
                        // Duplicate IndexField Name found
                        string message = string.Format(
                            "Index Field name '{0}' is duplicated in Index {1}",
                            this._name,
                            index.Name);
                        list.Add(new ErrorTableRow(this, message, ErrorType.Error));
                        break;
                    }
                }

                // Find Field
                Field field = null;
                if (this.Table is ObjectClass)
                {
                    ObjectClass objectClass = (ObjectClass)this.Table;
                    field = objectClass.FindField(this._name);
                }
                else if (this.Table is RasterBand)
                {
                    RasterBand rasterBand = (RasterBand)this.Table;
                    field = rasterBand.FindField(this._name);
                }

                // Error if Field not found
                if (field == null)
                {
                    // Field cannot be found in parent ObjectClass/RasterBand
                    string message = string.Format("Index Field '{0}' is missing from parent dataset", this._name);
                    list.Add(new ErrorTableRow(this, message, ErrorType.Error));
                }
            }
        }
コード例 #2
0
        public override void WriteXml(XmlWriter writer)
        {
            Field field = null;

            if (this.Table is ObjectClass)
            {
                ObjectClass objectClass = (ObjectClass)this.Table;
                field = objectClass.FindField(this._name);
            }
            else if (this.Table is RasterBand)
            {
                RasterBand rasterBand = (RasterBand)this.Table;
                field = rasterBand.FindField(this._name);
            }
            if (field == null)
            {
                return;
            }
            field.WriteXml(writer);
        }