70 lines
1.4 KiB
C#
70 lines
1.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using System.IO;
|
|
|
|
namespace DataLoader
|
|
{
|
|
public class FixItems : List<FixItem>
|
|
{
|
|
public FixItems(FileInfo myFile):base()
|
|
{
|
|
if (!myFile.Exists)
|
|
return;
|
|
FileStream fs = myFile.OpenRead();
|
|
int len = (int) myFile.Length;
|
|
byte [] buffer = new byte[len];
|
|
fs.Read(buffer, 0, len);
|
|
int offset = 0;
|
|
while(offset < len)
|
|
{
|
|
int lFixItem = (int)(buffer[offset]);
|
|
Add(new FixItem(buffer,offset));
|
|
offset += lFixItem + 1;
|
|
}
|
|
}
|
|
}
|
|
public class FixItem
|
|
{
|
|
public FixItem(byte[] buffer, int offset)
|
|
{
|
|
int lFixItem = (int)(buffer[offset]);
|
|
_Section = (char)(buffer[offset + 1]);
|
|
_Step = (int)(buffer[offset + 2]);
|
|
string str = System.Text.Encoding.GetEncoding(1251).GetString(buffer, offset + 3, lFixItem - 2);
|
|
if (str.Contains(" "))
|
|
{
|
|
int index = str.IndexOf(" ");
|
|
_Sequence = str.Substring(0, index);
|
|
_Rev = str.Substring(index + 1);
|
|
}
|
|
else
|
|
_Sequence = str;
|
|
}
|
|
private char _Section;
|
|
public char Section
|
|
{
|
|
get { return _Section; }
|
|
set { _Section = value; }
|
|
}
|
|
private int _Step;
|
|
public int Step
|
|
{
|
|
get { return _Step; }
|
|
set { _Step = value; }
|
|
}
|
|
private string _Sequence;
|
|
public string Sequence
|
|
{
|
|
get { return _Sequence; }
|
|
set { _Sequence = value; }
|
|
}
|
|
private string _Rev;
|
|
public string Rev
|
|
{
|
|
get { return _Rev; }
|
|
set { _Rev = value; }
|
|
}
|
|
}
|
|
}
|