Exemple #1
0
 protected internal Fields(Layer layer) : base(MiApi.mitab_c_get_field_count(layer.Handle))
 {
     fields = new Field[Count];
     for (int i = 0; i < Count; i++)
     {
         fields[i] = CreateField(layer, i);
     }
 }
Exemple #2
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;
                }
            }
        }