コード例 #1
0
ファイル: FdoRow.cs プロジェクト: beritec/fdotoolbox
        /// <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);
        }
コード例 #2
0
ファイル: FdoRow.cs プロジェクト: beritec/fdotoolbox
        /// <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);
        }