Beispiel #1
0
        protected internal DataValues(Feature feature) : base(MiApi.mitab_c_get_field_count(feature.Layer.Handle))
        {
            Values = new object[Count];
            for (int i = 0; i < Count; i++)
            {
                switch (feature.Layer.Fields[i].Type)
                {
                case FieldType.TABFT_Char:
                    Values[i] = MiApi.mitab_c_get_field_as_string(feature.Handle, i);
                    break;

                case FieldType.TABFT_Date:
                    double d = MiApi.mitab_c_get_field_as_double(feature.Handle, i);
                    if (d == 0)
                    {
                        Values[i] = null;
                    }
                    else
                    {
                        int year  = (int)(d / 10000);
                        int month = (int)((d - year * 10000) / 100);
                        int day   = (int)(d - year * 10000 - month * 100);
                        Values[i] = new DateTime(year, month, day);
                    }
                    break;

                case FieldType.TABFT_Decimal:
                    Values[i] = MiApi.mitab_c_get_field_as_double(feature.Handle, i);
                    break;

                case FieldType.TABFT_Float:
                    Values[i] = (float)MiApi.mitab_c_get_field_as_double(feature.Handle, i);
                    break;

                case FieldType.TABFT_Integer:
                    Values[i] = (int)MiApi.mitab_c_get_field_as_double(feature.Handle, i);
                    break;

                case FieldType.TABFT_Logical:
                    Values[i] = MiApi.mitab_c_get_field_as_string(feature.Handle, i) == "T"? true : false;
                    break;

                case FieldType.TABFT_SmallInt:
                    Values[i] = (short)MiApi.mitab_c_get_field_as_double(feature.Handle, i);
                    break;
                }
            }
        }
Beispiel #2
0
 /// <summary>
 /// Returns a string representation of this fields value for the given feature.
 /// </summary>
 /// <param name="feature">The feature to find the fields value for.</param>
 /// <returns>A string representation of this fields value for the given feature</returns>
 public string GetValueAsString(Feature feature)
 {
     return(MiApi.mitab_c_get_field_as_string(feature.Handle, this.Index));
 }