Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Dictionary<string, object> Unpack(byte[] Record, out int RealLength)
- {
- int Counter = 0;
- object buf = null;
- //перебираем сгенерированный ранее словарь с данными
- foreach (string SxRecordName in SxTypeCodes.Keys)
- {
- //вытаскиваем код типа данных
- string SxTypeCode = SxTypeCodes[SxRecordName];
- //вытаскиваем данные в object buf
- switch (SxTypeCode[0])
- {
- case 't':
- {
- buf = GetTinuintSigned(Record, Counter);
- Counter++;
- }; break;
- case 'T':
- {
- buf = GetTinuintUnsigned(Record, Counter);
- Counter++;
- }; break;
- case 's':
- {
- buf = GetSmallintSigned(Record, Counter);
- Counter+=2;
- }; break;
- case 'S':
- {
- buf = GetSmallintUnsigned(Record, Counter);
- Counter+=2;
- }; break;
- case 'm':
- {
- buf = GetMediumintSigned(Record, Counter);
- Counter += 3;
- }; break;
- case 'M':
- {
- buf = GetMediumintUnsigned(Record, Counter);
- Counter += 3;
- }; break;
- case 'i':
- {
- buf = GetIntSigned(Record, Counter);
- Counter += 4;
- }; break;
- case 'I':
- {
- buf = GetIntUnsigned(Record, Counter);
- Counter += 4;
- }; break;
- case 'f':
- {
- buf = GetFloat(Record, Counter);
- Counter += 4;
- }; break;
- case 'd':
- {
- buf = GetDouble(Record, Counter);
- Counter += 8;
- }; break;
- case 'n':
- {
- string signs = SxTypeCode.Substring(1);
- int isigns = Convert.ToInt32(signs);
- buf = GetN16(Record, Counter, isigns);
- Counter += 2;
- }; break;
- case 'N':
- {
- string signs = SxTypeCode.Substring(1);
- int isigns = Convert.ToInt32(signs);
- buf = GetN32(Record, Counter, isigns);
- Counter += 4;
- }; break;
- case 'c':
- {
- int length = Convert.ToInt32(SxTypeCode.Substring(1));
- buf = GetFixedString(Record, Counter, length);
- Counter += length;
- }; break;
- case 'b':
- {
- string Result = "";
- Counter = GetBlob(Record, Counter ,out Result);
- buf = Result;
- }; break;
- default:
- {
- buf = null;
- }; break;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement