Example #1
0
        /// <summary>
        /// Generate a row from a Feature Reader
        /// </summary>
        /// <param name="reader">The feature reader</param>
        /// <param name="readOnlyProperties">A list of properties to mark as read-only</param>
        /// <returns></returns>
        public static FdoRow FromFeatureReader(FdoFeatureReader reader, ICollection <string> readOnlyProperties)
        {
            FdoRow row = new FdoRow();

            for (int i = 0; i < reader.FieldCount; i++)
            {
                string name = reader.GetName(i);
                if (!reader.IsNull(name))
                {
                    if (name == reader.DefaultGeometryProperty)
                    {
                        row.DefaultGeometryProperty = reader.DefaultGeometryProperty;
                        row.AddGeometry(name, reader.GetGeometryObject(name));
                    }
                    else if (Array.IndexOf <string>(reader.GeometryProperties, name) >= 0)
                    {
                        row.AddGeometry(name, reader.GetGeometryObject(name));
                    }
                    else
                    {
                        row[name] = reader.GetValue(i); //reader[name];
                    }

                    if (readOnlyProperties.Contains(name))
                    {
                        row.MarkReadOnly(name);
                    }
                }
            }
            return(row);
        }
Example #2
0
 /// <summary>
 /// Called when a row is processed.
 /// </summary>
 /// <param name="op">The operation.</param>
 /// <param name="dictionary">The dictionary.</param>
 protected virtual void OnFeatureProcessed(FdoOperationBase op, FdoRow dictionary)
 {
     if (op.Statistics.OutputtedRows % 1000 == 0)
     {
         Info("Processed {0} rows in {1}", op.Statistics.OutputtedRows, op.Name);
     }
     else
     {
         Debug("Processed {0} rows in {1}", op.Statistics.OutputtedRows, op.Name);
     }
 }
Example #3
0
        /// <summary>
        /// Generate a row from a data reader
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <returns></returns>
        public static FdoRow FromReader(IDataReader reader)
        {
            FdoRow row = new FdoRow();

            for (int i = 0; i < reader.FieldCount; i++)
            {
                if (!reader.IsDBNull(i))
                {
                    row[reader.GetName(i)] = reader.GetValue(i);
                }
            }
            return(row);
        }
Example #4
0
        /// <summary>
        /// Copy all the public properties and fields of an object to the row
        /// </summary>
        /// <param name="obj">The obj.</param>
        /// <returns></returns>
        public static FdoRow FromObject(object obj)
        {
            if (obj == null)
            {
                throw new ArgumentNullException("obj");
            }
            FdoRow row = new FdoRow();

            foreach (PropertyInfo property in GetProperties(obj))
            {
                row[property.Name] = property.GetValue(obj, new object[0]);
            }
            foreach (FieldInfo field in GetFields(obj))
            {
                row[field.Name] = field.GetValue(obj);
            }
            return(row);
        }
Example #5
0
        /// <summary>
        /// Creates a new <see cref="FdoRow"/> from a <see cref="FdoFeature"/> instance
        /// </summary>
        /// <param name="feat">The <see cref="FdoFeature"/> instance</param>
        /// <returns>A new <see cref="FdoRow"/> instance</returns>
        public static FdoRow FromFeatureRow(FdoFeature feat)
        {
            if (feat.Table == null)
            {
                throw new InvalidOperationException(ResourceUtil.GetString("ERR_FEATURE_ROW_HAS_NO_PARENT_TABLE"));
            }

            FdoRow row = new FdoRow();

            foreach (DataColumn dc in feat.Table.Columns)
            {
                if (feat[dc] != null && feat[dc] != DBNull.Value)
                {
                    FdoGeometry geom = feat[dc] as FdoGeometry;
                    if (geom != null)
                    {
                        if (feat.Table.GeometryColumn == dc.ColumnName)
                        {
                            row.AddGeometry(dc.ColumnName, geom.InternalInstance);
                            row.DefaultGeometryProperty = dc.ColumnName;
                        }
                        else
                        {
                            row.AddGeometry(dc.ColumnName, geom.InternalInstance);
                        }
                    }
                    else
                    {
                        row[dc.ColumnName] = feat[dc];
                    }
                    if (dc.ReadOnly)
                    {
                        row.MarkReadOnly(dc.ColumnName);
                    }
                }
            }
            return(row);
        }
Example #6
0
        /// <summary>
        /// Clones this instance.
        /// </summary>
        /// <returns></returns>
        public FdoRow Clone()
        {
            FdoRow row = new FdoRow(this);

            return(row);
        }