public void WriteTo(CodedOutputStream output, FieldCodec <T> codec) { if (this.count == 0) { goto IL_0B; } goto IL_1E1; uint arg_18F_0; Action <CodedOutputStream, T> valueWriter; while (true) { IL_18A: uint num; switch ((num = (arg_18F_0 ^ 1953686162u)) % 17u) { case 0u: arg_18F_0 = (num * 3203489594u ^ 1031590236u); continue; case 1u: { uint tag; output.WriteTag(tag); uint value; output.WriteRawVarint32(value); int num2 = 0; arg_18F_0 = (num * 515923323u ^ 23271688u); continue; } case 2u: { uint tag = codec.Tag; arg_18F_0 = ((RepeatedField <T> .smethod_1(typeof(T).TypeHandle).IsValueType() ? 1056524744u : 1802064101u) ^ num * 3884348354u); continue; } case 3u: arg_18F_0 = (num * 2769258316u ^ 2862122040u); continue; case 4u: { uint value = (uint)this.CalculatePackedDataSize(codec); arg_18F_0 = (num * 4231138135u ^ 3155140988u); continue; } case 5u: { uint tag; output.WriteTag(tag); int num3; valueWriter(output, this.array[num3]); num3++; arg_18F_0 = 603286320u; continue; } case 6u: { int num2; arg_18F_0 = ((num2 < this.count) ? 1868080555u : 798875600u); continue; } case 8u: { uint tag; arg_18F_0 = (((WireFormat.GetTagWireType(tag) != WireFormat.WireType.LengthDelimited) ? 457279799u : 500871248u) ^ num * 3734816805u); continue; } case 9u: { int num3 = 0; arg_18F_0 = 1317493604u; continue; } case 10u: { int num2; valueWriter(output, this.array[num2]); arg_18F_0 = 1207070914u; continue; } case 11u: { int num3; arg_18F_0 = ((num3 >= this.count) ? 1230221189u : 414117966u); continue; } case 12u: goto IL_1E1; case 13u: return; case 14u: { int num2; num2++; arg_18F_0 = (num * 2746311965u ^ 3912762196u); continue; } case 15u: return; case 16u: goto IL_0B; } break; } return; IL_0B: arg_18F_0 = 793007137u; goto IL_18A; IL_1E1: valueWriter = codec.ValueWriter; arg_18F_0 = 158090120u; goto IL_18A; }
public void AddEntriesFrom_CodedInputStream() { // map will have string key and string value var keyTag = WireFormat.MakeTag(1, WireFormat.WireType.LengthDelimited); var valueTag = WireFormat.MakeTag(2, WireFormat.WireType.LengthDelimited); var memoryStream = new MemoryStream(); var output = new CodedOutputStream(memoryStream); output.WriteLength(20); // total of keyTag + key + valueTag + value output.WriteTag(keyTag); output.WriteString("the_key"); output.WriteTag(valueTag); output.WriteString("the_value"); output.Flush(); var field = new MapField <string, string>(); var mapCodec = new MapField <string, string> .Codec(FieldCodec.ForString(keyTag, ""), FieldCodec.ForString(valueTag, ""), 10); var input = new CodedInputStream(memoryStream.ToArray()); // test the legacy overload of AddEntriesFrom that takes a CodedInputStream field.AddEntriesFrom(input, mapCodec); CollectionAssert.AreEquivalent(new[] { "the_key" }, field.Keys); CollectionAssert.AreEquivalent(new[] { "the_value" }, field.Values); Assert.IsTrue(input.IsAtEnd); }
private int CalculatePackedDataSize(FieldCodec <T> codec) { int fixedSize = codec.FixedSize; if (fixedSize == 0) { while (true) { IL_D4: uint arg_A2_0 = 2833686227u; while (true) { uint num; switch ((num = (arg_A2_0 ^ 2175998545u)) % 9u) { case 0u: goto IL_D4; case 1u: { int num2; return(num2); } case 2u: { int num2 = 0; int num3 = 0; arg_A2_0 = (num * 2189381860u ^ 2913051558u); continue; } case 3u: { int num3; arg_A2_0 = ((num3 < this.count) ? 2988845271u : 2662832558u); continue; } case 4u: { int num3; num3++; arg_A2_0 = (num * 3732949925u ^ 1868024201u); continue; } case 5u: arg_A2_0 = (num * 1679443217u ^ 2977036967u); continue; case 6u: { int num2; int num3; Func <T, int> valueSizeCalculator; num2 += valueSizeCalculator(this.array[num3]); arg_A2_0 = 2488117428u; continue; } case 7u: { Func <T, int> valueSizeCalculator = codec.ValueSizeCalculator; arg_A2_0 = (num * 4280227348u ^ 3021418933u); continue; } } goto Block_3; } } Block_3 :; } return(fixedSize * this.Count); }
public int CalculateSize(FieldCodec <T> codec) { if (this.count == 0) { goto IL_7F; } goto IL_14C; uint arg_10E_0; int num2; uint tag; int num3; while (true) { IL_109: uint num; switch ((num = (arg_10E_0 ^ 4001631253u)) % 12u) { case 0u: goto IL_15A; case 1u: num2 = this.CalculatePackedDataSize(codec); arg_10E_0 = (num * 3891558231u ^ 1575501722u); continue; case 2u: goto IL_14C; case 3u: { Func <T, int> valueSizeCalculator = codec.ValueSizeCalculator; num3 = this.count * CodedOutputStream.ComputeRawVarint32Size(tag); arg_10E_0 = 3044489711u; continue; } case 4u: { Func <T, int> valueSizeCalculator; int num4; num3 += valueSizeCalculator(this.array[num4]); num4++; arg_10E_0 = 2737623098u; continue; } case 5u: return(0); case 6u: arg_10E_0 = (((WireFormat.GetTagWireType(tag) == WireFormat.WireType.LengthDelimited) ? 1110063554u : 216719364u) ^ num * 1888421937u); continue; case 7u: goto IL_7F; case 8u: arg_10E_0 = ((RepeatedField <T> .smethod_1(typeof(T).TypeHandle).IsValueType() ? 405727823u : 968969150u) ^ num * 1456731362u); continue; case 10u: { int num4 = 0; arg_10E_0 = (num * 2246578605u ^ 3048063944u); continue; } case 11u: { int num4; arg_10E_0 = ((num4 < this.count) ? 3082958981u : 4069993376u); continue; } } break; } return(num3); IL_15A: return(CodedOutputStream.ComputeRawVarint32Size(tag) + CodedOutputStream.ComputeLengthSize(num2) + num2); IL_7F: arg_10E_0 = 2713212068u; goto IL_109; IL_14C: tag = codec.Tag; arg_10E_0 = 2759193717u; goto IL_109; }
public void AddEntriesFrom(CodedInputStream input, FieldCodec <T> codec) { uint lastTag = input.LastTag; Func <CodedInputStream, T> valueReader = codec.ValueReader; if (RepeatedField <T> .smethod_1(typeof(T).TypeHandle).IsValueType()) { goto IL_79; } goto IL_189; uint arg_147_0; while (true) { IL_142: uint num; switch ((num = (arg_147_0 ^ 349581016u)) % 13u) { case 0u: arg_147_0 = ((input.MaybeConsumeTag(lastTag) ? 2792542167u : 2493560502u) ^ num * 4283985340u); continue; case 1u: arg_147_0 = (((WireFormat.GetTagWireType(lastTag) == WireFormat.WireType.LengthDelimited) ? 4182580420u : 2445968179u) ^ num * 3573087188u); continue; case 2u: arg_147_0 = (num * 2407926176u ^ 627495612u); continue; case 3u: { int num2; arg_147_0 = (((num2 > 0) ? 704969730u : 1347903514u) ^ num * 2106852334u); continue; } case 4u: { int oldLimit; input.PopLimit(oldLimit); arg_147_0 = (num * 2913868755u ^ 1655185686u); continue; } case 6u: { int num2; int oldLimit = input.PushLimit(num2); arg_147_0 = (num * 3972840873u ^ 320789690u); continue; } case 7u: goto IL_79; case 8u: this.Add(valueReader(input)); arg_147_0 = 1293084732u; continue; case 9u: arg_147_0 = ((!input.ReachedLimit) ? 862879642u : 1176527045u); continue; case 10u: return; case 11u: goto IL_189; case 12u: { int num2 = input.ReadLength(); arg_147_0 = (num * 1888486294u ^ 430467554u); continue; } } break; } return; IL_79: arg_147_0 = 431838837u; goto IL_142; IL_189: this.Add(valueReader(input)); arg_147_0 = 320588544u; goto IL_142; }
/// <summary> /// Creates a new entry codec based on a separate key codec and value codec, /// and the tag to use for each map entry. /// </summary> /// <param name="keyCodec">The key codec.</param> /// <param name="valueCodec">The value codec.</param> /// <param name="mapTag">The map tag to use to introduce each map entry.</param> public Codec(FieldCodec <TKey> keyCodec, FieldCodec <TValue> valueCodec, uint mapTag) { this.keyCodec = keyCodec; this.valueCodec = valueCodec; this.mapTag = mapTag; }
/// <inheritdoc/> public override FieldCodec <ulong> CreateFieldCodec(int fieldNumber) { return(FieldCodec.ForUInt64(WireFormat.MakeTag(fieldNumber, WireType))); }