예제 #1
0
 public AoFeatureClassType(bool required,
                           AoTable attribs,
                           params esriGeometryType[] allowed) : base("Feature layer", required)
 {
     m_allowed = allowed;
     m_attribs = attribs;
 }
예제 #2
0
        protected override void ValueCheck(IGPFeatureLayer feat)
        {
            bool found = (m_allowed.Length == 0);             // assume true if no geometries

            if (feat != null && feat.DEFeatureClass != null)
            {
                for (int i = 0; i < m_allowed.Length; i++)
                {
                    if (m_allowed[i] == feat.DEFeatureClass.ShapeType)
                    {
                        found = true;
                    }
                }
                if (!found)
                {
                    Error("Features are of the wrong type.");
                    return;
                }
            }
            else
            {
                if (this.Required)
                {
                    Error("A layer is required.");
                    return;
                }
                else
                {
                    Warning("Will use default layer name.");
                }
            }

            if (m_attribs != null)
            {
                AoTable vtb = AoTable.From(feat.DEFeatureClass);

                bool ok = true;
                foreach (AoField f in m_attribs.AoFields)
                {
                    if (vtb[f.Name] == null)
                    {
                        Error("Missing required field " + f.Name);
                        ok = false;
                    }                     // TODO: check the field type too?
                }
                if (!ok)
                {
                    return;
                }
            }
        }