public void TestCalculateSizeWithTag() { var stream = new MemoryStream(); var codedOutput = CodedOutputStream.CreateInstance(stream); codec.WriteTagAndValue(codedOutput, sampleValue); codedOutput.Flush(); Assert.AreEqual(stream.Position, codec.CalculateSizeWithTag(sampleValue)); }
public int CalculateSize() { if (!hasValue) { return(0); } return(codec.CalculateSizeWithTag(field)); }
public int CalculateSize() { return(codec.CalculateSizeWithTag(field)); }
internal static int CalculateSize <T>(T value, FieldCodec <T> codec) { int fieldLength = codec.CalculateSizeWithTag(value); return(CodedOutputStream.ComputeLengthSize(fieldLength) + fieldLength); }
internal static void Write <T>(CodedOutputStream output, T value, FieldCodec <T> codec) { output.WriteLength(codec.CalculateSizeWithTag(value)); codec.WriteTagAndValue(output, value); }
internal static void Write <T>(ref WriteContext ctx, T value, FieldCodec <T> codec) { ctx.WriteLength(codec.CalculateSizeWithTag(value)); codec.WriteTagAndValue(ref ctx, value); }