public static ulong EntryCode <K, V, KP, VP>(K key, V value, Stream buf, KP keyType, VP valueType) where KP : ProtoType where VP : ProtoType { if (Cache <K, KP> .Code == null) { throw new NotImplementedException(); } if (Cache <V, VP> .Code == null) { if (value is Enum && valueType is ProtoEnum) { Cache <V, VP> .Code = (V parm1, Stream parm2) => ProtoTool.EnumCode(parm1, parm2); } else { throw new NotImplementedException(); } } ulong bytes = 0; bytes += VarintCode(EntryByteSizeWithoutLength(key, value, keyType, valueType), buf); bytes += KeyCode(1, (uint)keyType.GetWireType(), buf); bytes += Cache <K, KP> .Code(key, buf); bytes += KeyCode(2, (uint)valueType.GetWireType(), buf); bytes += Cache <V, VP> .Code(value, buf); return(bytes); }
private static ulong EntryCode <T, P>(T value, Stream buf, P type) { if (Cache <T, P> .Code == null) { if (value is Enum && type is ProtoEnum) { Cache <T, P> .Code = (T parm1, Stream parm2) => ProtoTool.EnumCode(parm1, parm2); } else { throw new NotImplementedException(); } } return(Cache <T, P> .Code(value, buf)); }