protected bool Parse <T>(BinaryReader stream, CVSReader.ValueParse <T> parse, byte count, ref int iIndex, ref int vIndex)
        {
            bool result = false;
            uint num    = stream.ReadUInt32();

            if (num == 0u)
            {
                iIndex = 0;
                vIndex = 0;
            }
            else
            {
                CVSReader.SeqCache value;
                if (CVSReader._seqIndex.TryGetValue(num, out value))
                {
                    parse.SkipBuffer(stream, (int)count);
                }
                else
                {
                    value.valueIndex = parse.ReadBuffer(stream);
                    for (byte b = 1; b < count; b += 1)
                    {
                        parse.ReadBuffer(stream);
                    }
                    value.indexIndex         = iIndex;
                    CVSReader._seqIndex[num] = value;
                    result = true;
                }
                iIndex = value.indexIndex;
                vIndex = value.valueIndex;
            }
            return(result);
        }
 protected bool Parse <T>(string Field, ref Seq2ListRef <T> b, CVSReader.ValueParse <T> parse, string post)
 {
     if (Field.Length == 0)
     {
         b.indexOffset = 0;
         return(true);
     }
     string[] array = Field.Split(new char[]
     {
         '|'
     });
     if (array.Length == 0)
     {
         b.indexOffset = 0;
         return(true);
     }
     lock (CVSReader._seqIndex)
     {
         b.count       = (byte)array.Length;
         b.indexOffset = this.AddIndexBuffer(array.Length);
         for (int i = 0; i < array.Length; i++)
         {
             string field = array[i];
             int    num   = 0;
             this.Parse <T>(field, ref num, parse, post, 2);
             CVSReader.indexBuffer[b.indexOffset + i] = num;
         }
     }
     return(true);
 }
 protected bool Parse <T>(string Field, ref Seq3Ref <T> b, CVSReader.ValueParse <T> parse, string post)
 {
     if (Field.Length == 0)
     {
         b.indexOffset = 0;
         return(true);
     }
     lock (CVSReader._seqIndex)
     {
         int num = 0;
         b.indexOffset = this.Parse <T>(Field, ref num, parse, post, 3);
     }
     return(true);
 }
 protected bool ReadSeq <T>(BinaryReader stream, ref Seq4Ref <T> v, CVSReader.ValueParse <T> parse)
 {
     lock (CVSReader._seqIndex)
     {
         int  indexOffset = CVSReader.indexIndex;
         int  num         = 0;
         bool flag        = this.Parse <T>(stream, parse, 4, ref indexOffset, ref num);
         v.indexOffset = indexOffset;
         if (flag)
         {
             CVSReader.indexBuffer[CVSReader.indexIndex++] = num;
         }
     }
     return(true);
 }
        protected void WriteSeq <T>(BinaryWriter stream, string Field, CVSReader.ValueParse <T> parse, int count, string post)
        {
            uint value = 0u;

            if (Field.Length == 0)
            {
                stream.Write(value);
                return;
            }
            string[] array = Field.Split(CVSReader.SeqSeparator, StringSplitOptions.RemoveEmptyEntries);
            if (array.Length == 0)
            {
                stream.Write(value);
                return;
            }
            this.TrimField(array);
            string text = array[0];

            for (int i = 1; i < count; i++)
            {
                if (i < array.Length)
                {
                    text = text + "=" + array[i];
                }
                else
                {
                    text += "=0";
                }
            }
            text += post;
            value = XSingleton <XCommon> .singleton.XHash(text);

            stream.Write(value);
            for (int j = 0; j < count; j++)
            {
                if (j < array.Length)
                {
                    parse.Write(stream, array[j]);
                }
                else
                {
                    parse.Write(stream, null);
                }
            }
        }
        protected bool ReadArray <T>(BinaryReader stream, ref T[] v, CVSReader.ValueParse <T> parse)
        {
            byte b = stream.ReadByte();

            if (b > 0)
            {
                v = new T[(int)b];
                for (byte b2 = 0; b2 < b; b2 += 1)
                {
                    parse.Read(stream, ref v[(int)b2]);
                }
            }
            else
            {
                v = null;
            }
            return(true);
        }
        protected void WriteArray <T>(BinaryWriter stream, string Field, CVSReader.ValueParse <T> parse)
        {
            byte b = 0;

            string[] array = Field.Split(CVSReader.ListSeparator, StringSplitOptions.RemoveEmptyEntries);
            if (array == null || array.Length == 0)
            {
                stream.Write(b);
                return;
            }
            b = (byte)array.Length;
            stream.Write(b);
            for (byte b2 = 0; b2 < b; b2 += 1)
            {
                string data = array[(int)b2];
                this.TrimField(ref data);
                parse.Write(stream, data);
            }
        }
 protected bool ReadSeqList <T>(BinaryReader stream, ref Seq4ListRef <T> v, CVSReader.ValueParse <T> parse)
 {
     v.count = stream.ReadByte();
     if (v.count > 0)
     {
         lock (CVSReader._seqIndex)
         {
             v.indexOffset = this.AddIndexBuffer(v.count);
             for (byte b = 0; b < v.count; b += 1)
             {
                 int num  = v.indexOffset + (int)b;
                 int num2 = 0;
                 this.Parse <T>(stream, parse, 4, ref num, ref num2);
                 CVSReader.indexBuffer[v.indexOffset + (int)b] = num2;
             }
             return(true);
         }
     }
     v.indexOffset = 0;
     return(true);
 }
 protected int Parse <T>(string Field, ref int valueIndex, CVSReader.ValueParse <T> parse, string post, int size)
 {
     if (!string.IsNullOrEmpty(Field))
     {
         uint key = this.ComputerHash(Field, post);
         CVSReader.SeqCache value;
         value.valueIndex = -1;
         value.indexIndex = 0;
         if (!CVSReader._seqIndex.TryGetValue(key, out value))
         {
             string[] array = Field.Split(new char[]
             {
                 '='
             });
             if (array.Length > 0)
             {
                 int num = parse.ParseBuffer(array[0]);
                 for (int i = 1; i < size; i++)
                 {
                     if (i < array.Length)
                     {
                         parse.ParseBuffer(array[i]);
                     }
                     else
                     {
                         parse.DefaultValue();
                     }
                 }
                 value.valueIndex = num;
                 value.indexIndex = CVSReader.indexIndex;
                 CVSReader.indexBuffer[CVSReader.indexIndex++] = num;
                 CVSReader._seqIndex[key] = value;
             }
         }
         valueIndex = value.valueIndex;
         return(value.indexIndex);
     }
     return(0);
 }
Beispiel #10
0
        protected void WriteSeqList <T>(BinaryWriter stream, string Field, CVSReader.ValueParse <T> parse, int count, string post)
        {
            byte b = 0;

            if (Field.Length == 0)
            {
                stream.Write(b);
                return;
            }
            string[] array = Field.Split(CVSReader.ListSeparator, StringSplitOptions.RemoveEmptyEntries);
            if (array == null || array.Length == 0)
            {
                stream.Write(b);
                return;
            }
            b = (byte)array.Length;
            stream.Write(b);
            for (byte b2 = 0; b2 < b; b2 += 1)
            {
                this.WriteSeq <T>(stream, array[(int)b2], parse, count, post);
            }
        }
Beispiel #11
0
 protected bool Read <T>(BinaryReader stream, ref T v, CVSReader.ValueParse <T> parse)
 {
     parse.Read(stream, ref v);
     return(true);
 }
Beispiel #12
0
 protected void Write <T>(BinaryWriter stream, string Field, CVSReader.ValueParse <T> parse)
 {
     this.TrimField(ref Field);
     parse.Write(stream, Field);
 }