Пример #1
0
            public static ulong EntryDecode <K, V, KP, VP>(ref K key, ref V value, Stream buf, KP keyType, VP valueType)
                where KP : ProtoType
                where VP : ProtoType
            {
                if (Cache <K, KP> .Decode == null)
                {
                    throw new NotImplementedException();
                }
                if (Cache <V, VP> .Decode == null)
                {
                    if (value is Enum && valueType is ProtoEnum)
                    {
                        Cache <V, VP> .Decode = (ref V parm1, Stream parm2) => ProtoTool.EnumDecode(ref parm1, parm2);
                    }
                    else
                    {
                        throw new NotImplementedException();
                    }
                }

                ulong bytes  = 0;
                ulong length = 0;

                bytes += VarintDecode(ref length, buf);
                uint tag  = 0;
                uint type = 0;

                bytes += KeyDecode(ref tag, ref type, buf);
                bytes += Cache <K, KP> .Decode(ref key, buf);

                bytes += KeyDecode(ref tag, ref type, buf);
                bytes += Cache <V, VP> .Decode(ref value, buf);

                return(bytes);
            }
Пример #2
0
 private static ulong EntryDecode <T, P>(ref T value, Stream buf, P type)
 {
     if (Cache <T, P> .Decode == null)
     {
         if (value is Enum && type is ProtoEnum)
         {
             Cache <T, P> .Decode = (ref T parm1, Stream parm2) => ProtoTool.EnumDecode(ref parm1, parm2);
         }
         else
         {
             throw new NotImplementedException();
         }
     }
     return(Cache <T, P> .Decode(ref value, buf));
 }