示例#1
0
        public void ValidateParameterValues(ParameterValueCollection parameters)
        {
            List <ParameterClass> ps = _event.GetParameters(this);

            if (ps.Count > 0)
            {
                if (ps[0].IsLibType && typeof(object).Equals(ps[0].BaseClassType))
                {
                    if (string.Compare("sender", ps[0].Name, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        if (parameters.Count == 0)
                        {
                            ParameterValue pv = new ParameterValue(_action);
                            pv.Name = ps[0].Name;
                            pv.SetDataType(typeof(object));
                            pv.ValueType = EnumValueType.Property;
                            pv.Property  = _event.RootPointer;
                            parameters.Add(pv);
                        }
                        if (ps.Count > 1)
                        {
                            if (ps[1].IsLibType && typeof(EventArgs).Equals(ps[1].BaseClassType))
                            {
                                if (parameters.Count < 2)
                                {
                                    ParameterValue pv = new ParameterValue(_action);
                                    pv.Name = ps[1].Name;
                                    pv.SetDataType(typeof(EventArgs));
                                    pv.ValueType = EnumValueType.Property;
                                    FieldPointer fp = new FieldPointer();
                                    fp.Owner      = new DataTypePointer(new TypePointer(typeof(EventArgs)));
                                    fp.MemberName = "Empty";
                                    pv.Property   = fp;
                                    parameters.Add(pv);
                                }
                            }
                        }
                    }
                }
            }
            ParameterValueCollection.ValidateParameterValues(parameters, ps, this);
        }
示例#2
0
        public ParameterValueCollection GetParameters()
        {
            ParameterValueCollection ps = new ParameterValueCollection();

            if (_dataTransfers != null)
            {
                Dictionary <IProperty, ParameterValue> .ValueCollection.Enumerator en = _dataTransfers.Values.GetEnumerator();
                while (en.MoveNext())
                {
                    ps.Add(en.Current);
                }
            }
            return(ps);
        }
示例#3
0
 public void ValidateParameterValues(ParameterValueCollection parameters)
 {
     if (_prop == null)
     {
         FormWarning.ShowMessage("Error calling {0}.ValidateParameterValues. Property not set. Action:{1}", this.GetType().FullName, this.Action);
     }
     else
     {
         ParameterValue p = null;
         foreach (ParameterValue pv in parameters)
         {
             if (string.Compare(pv.Name, PropertyValueName, StringComparison.Ordinal) == 0)
             {
                 p = pv;
                 break;
             }
         }
         if (p == null)
         {
             p = createValue();
         }
         if (_prop.PropertyType != null)
         {
             p.SetDataType(_prop.PropertyType);
         }
         IList <Attribute> ed = _prop.GetUITypeEditor();
         if (ed != null && ed.Count > 0)
         {
             Attribute[] atts = new Attribute[ed.Count];
             ed.CopyTo(atts, 0);
             p.MergeValueAttributes(atts);
         }
         parameters.Clear();
         parameters.Add(p);
     }
 }
        private ParameterValueCollection CreateParameterValues(string prefix, FdoRow row)
        {
            ParameterValueCollection values = new ParameterValueCollection();

            if (_mappings == null || _mappings.Count == 0)
            {
                foreach (string col in row.Columns)
                {
                    //No excluded properties or property not in exclusion list
                    if (_unWritableProperties == null || _unWritableProperties.Count == 0 || !_unWritableProperties.Contains(col))
                    {
                        //Omit null values
                        if (row[col] != null && row[col] != DBNull.Value)
                        {
                            if (!row.IsGeometryProperty(col))
                            {
                                LiteralValue dv = ValueConverter.GetConvertedValue(row[col]);
                                if (dv != null)
                                {
                                    ParameterValue pv = new ParameterValue(prefix + col, dv);
                                    values.Add(pv);
                                }
                            }
                            else
                            {
                                IGeometry geom = row[col] as IGeometry;
                                if (geom != null)
                                {
                                    ParameterValue pv = new ParameterValue(prefix + col, new GeometryValue(FdoGeometryFactory.Instance.GetFgf(geom)));
                                    values.Add(pv);
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                foreach (string col in row.Columns)
                {
                    //No excluded properties or property not in exclusion list
                    if (_unWritableProperties == null || _unWritableProperties.Count == 0 || !_unWritableProperties.Contains(col))
                    {
                        //Omit null and un-mapped values
                        if (_mappings[col] != null || row[col] != null && row[col] != DBNull.Value)
                        {
                            if (!row.IsGeometryProperty(col))
                            {
                                LiteralValue dv = ValueConverter.GetConvertedValue(row[col]);
                                if (dv != null)
                                {
                                    ParameterValue pv = new ParameterValue(prefix + _mappings[col], dv);
                                    values.Add(pv);
                                }
                            }
                            else
                            {
                                IGeometry geom = row[col] as IGeometry;
                                if (geom != null)
                                {
                                    ParameterValue pv = new ParameterValue(prefix + _mappings[col], new GeometryValue(FdoGeometryFactory.Instance.GetFgf(geom)));
                                    values.Add(pv);
                                }
                            }
                        }
                    }
                }
            }
            return(values);
        }
示例#5
0
        /// <summary>
        /// Converts this feature to a parameter value collection.
        /// </summary>
        /// <param name="prefix">The prefix.</param>
        /// <param name="mappings">The mappings.</param>
        /// <param name="excludeProperties">The list of properties to exclude.</param>
        /// <returns></returns>
        public ParameterValueCollection ToParameterValueCollection(string prefix, NameValueCollection mappings, ICollection <string> excludeProperties)
        {
            ParameterValueCollection values = new ParameterValueCollection();

            if (mappings == null)
            {
                foreach (string col in this.Columns)
                {
                    //No excluded properties or property not in exclusion list
                    if (excludeProperties == null || excludeProperties.Count == 0 || !excludeProperties.Contains(col))
                    {
                        //Omit null values
                        if (this[col] != null && this[col] != DBNull.Value)
                        {
                            if (!IsGeometryProperty(col))
                            {
                                LiteralValue dv = ValueConverter.GetConvertedValue(this[col]);
                                if (dv != null)
                                {
                                    ParameterValue pv = new ParameterValue(prefix + col, dv);
                                    values.Add(pv);
                                }
                            }
                            else
                            {
                                IGeometry geom = this[col] as IGeometry;
                                if (geom != null)
                                {
                                    ParameterValue pv = new ParameterValue(prefix + col, new GeometryValue(FdoGeometryFactory.Instance.GetFgf(geom)));
                                    values.Add(pv);
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                foreach (string col in this.Columns)
                {
                    //No excluded properties or property not in exclusion list
                    if (excludeProperties == null || excludeProperties.Count == 0 || !excludeProperties.Contains(col))
                    {
                        //Omit null and un-mapped values
                        if (mappings[col] != null && this[col] != null && this[col] != DBNull.Value)
                        {
                            if (!IsGeometryProperty(col))
                            {
                                LiteralValue dv = ValueConverter.GetConvertedValue(this[col]);
                                if (dv != null)
                                {
                                    ParameterValue pv = new ParameterValue(prefix + col, dv);
                                    values.Add(pv);
                                }
                            }
                            else
                            {
                                IGeometry geom = this[col] as IGeometry;
                                if (geom != null)
                                {
                                    ParameterValue pv = new ParameterValue(prefix + col, new GeometryValue(FdoGeometryFactory.Instance.GetFgf(geom)));
                                    values.Add(pv);
                                }
                            }
                        }
                    }
                }
            }
            return(values);
        }
 private ParameterValueCollection CreateParameterValues(string prefix, FdoRow row)
 {
     ParameterValueCollection values = new ParameterValueCollection();
     if (_mappings == null || _mappings.Count == 0)
     {
         foreach (string col in row.Columns)
         {
             //No excluded properties or property not in exclusion list
             if (_unWritableProperties == null || _unWritableProperties.Count == 0 || !_unWritableProperties.Contains(col))
             {
                 //Omit null values
                 if (row[col] != null && row[col] != DBNull.Value)
                 {
                     if (!row.IsGeometryProperty(col))
                     {
                         LiteralValue dv = ValueConverter.GetConvertedValue(row[col]);
                         if (dv != null)
                         {
                             ParameterValue pv = new ParameterValue(prefix + col, dv);
                             values.Add(pv);
                         }
                     }
                     else
                     {
                         IGeometry geom = row[col] as IGeometry;
                         if (geom != null)
                         {
                             ParameterValue pv = new ParameterValue(prefix + col, new GeometryValue(FdoGeometryFactory.Instance.GetFgf(geom)));
                             values.Add(pv);
                         }
                     }
                 }
             }
         }
     }
     else
     {
         foreach (string col in row.Columns)
         {
             //No excluded properties or property not in exclusion list
             if (_unWritableProperties == null || _unWritableProperties.Count == 0 || !_unWritableProperties.Contains(col))
             {
                 //Omit null and un-mapped values
                 if (_mappings[col] != null || row[col] != null && row[col] != DBNull.Value)
                 {
                     if (!row.IsGeometryProperty(col))
                     {
                         LiteralValue dv = ValueConverter.GetConvertedValue(row[col]);
                         if (dv != null)
                         {
                             ParameterValue pv = new ParameterValue(prefix + _mappings[col], dv);
                             values.Add(pv);
                         }
                     }
                     else
                     {
                         IGeometry geom = row[col] as IGeometry;
                         if (geom != null)
                         {
                             ParameterValue pv = new ParameterValue(prefix + _mappings[col], new GeometryValue(FdoGeometryFactory.Instance.GetFgf(geom)));
                             values.Add(pv);
                         }
                     }
                 }
             }
         }
     }
     return values;
 }