예제 #1
0
        public void Load()
        {
            Version         = (DBFVersion)br.ReadByte();
            UpdateYear      = br.ReadByte();
            UpdateMonth     = br.ReadByte();
            UpdateDay       = br.ReadByte();
            NumberOfRecords = br.ReadInt32();
            HeaderLength    = br.ReadInt16();
            RecordLength    = br.ReadInt16();
            Reserved        = br.ReadBytes(20);

            // Read fields
            Fields = new List <DBField>();
            while (br.PeekChar() != 0x0d)
            {
                DBField field = new DBField();
                field.Load(ref br);
                Fields.Add(field);
            }

            br.BaseStream.Position = HeaderLength;

            // Read features and attributes
            int fieldCount = Fields.Count;

            Features       = new List <DBFeature>();
            AttributeTable = new Dictionary <string, List <DBAttribute> >();
            for (int i = 0; i < NumberOfRecords; ++i)
            {
                DBFeature feature = new DBFeature(Fields);
                feature.Load(ref br);
                Features.Add(feature);

                for (int j = 0; j < fieldCount; ++j)
                {
                    string      name      = Fields[j].FieldName;
                    DBAttribute attribute = feature.Attributes[j];
                    if (!AttributeTable.ContainsKey(name))
                    {
                        AttributeTable.Add(name, new List <DBAttribute>());
                        AttributeTable[name].Add(attribute);
                    }
                    else
                    {
                        AttributeTable[name].Add(attribute);
                    }
                }
            }
        }
예제 #2
0
        public void Load(ref BinaryReader br)
        {
            if (br.PeekChar() == -1)
            {
                return;
            }

            DeletionMarker = br.ReadChar();
            foreach (DBField fd in Fields)
            {
                DBAttribute attribute = DataFactory.CreateInstance(fd);
                attribute.Load(ref br);
                Attributes.Add(attribute);
            }
        }