public static DataDescriptiveRecord FromStream( BinaryReader reader )
        {
            DataDescriptiveRecord ddr = new DataDescriptiveRecord { Leader = DataDescriptiveRecordLeader.FromStream( reader ) };
            ddr.LoadDirectoriesFromStream( reader );

            foreach( DDRDirectoryEntry directory in ddr.Directories.OfType<DDRDirectoryEntry>() )
            {
                char[] buffer = reader.ReadChars(directory.Length);
                directory.Type = TypeFromTag( new string( buffer, 0, 4 ) );
                directory.FieldTerminatorChar = buffer[ 4 ];
                directory.UnitTerminatorChar = buffer[ 5 ];
                string fields = new string( buffer, 6, directory.Length - 7 );
                directory.Fields = fields.Split( new char[] { (char)INT_FieldSeparator } ).ToList();
                switch( directory.Type )
                {
                    case DDRDirectoryEntryType.FileName:
                        ddr.Filename = directory.Fields.First();
                        break;
                    case DDRDirectoryEntryType.RecordIdentifier:
                        break;
                    case DDRDirectoryEntryType.FieldList:
                        directory.SubFields = directory.Fields[1].Split( '!' ).Select( str => new DataField { Name = str, Directory = directory } ).ToList();
                        ApplyFieldTypes( directory );
                        break;
                    case DDRDirectoryEntryType.ArrayFieldList:
                        directory.SubFields = directory.Fields[1].Substring( 1 ).Split( '!' ).Select( str => new DataField { Name = str, Directory = directory } ).ToList();
                        ApplyFieldTypes( directory );
                        break;
                }
            }
            return ddr;
        }
Esempio n. 2
0
        public static DataRecord FromStream( DataDescriptiveRecord ddr, BinaryReader reader )
        {
            var record = new DataRecord { Leader = DataRecordLeader.FromStream( reader ), DescriptiveRecord = ddr };

            record.LoadDirectoriesFromStream( reader );

            record.LoadRows( reader );

            return record;
        }
Esempio n. 3
0
 public void SetUp()
 {
     _stream = new FileStream( "BD01CATD.DDF", FileMode.Open );
     _reader = new BinaryReader( _stream );
     _ddr = DataDescriptiveRecord.FromStream( _reader );
 }