public static PrintToString ( IMessage message ) : string | ||
message | IMessage | |
리턴 | string |
public void PrintMessage() { TestUtil.TestInMultipleCultures(() => { string text = TextFormat.PrintToString(TestUtil.GetAllSet()); Assert.AreEqual(AllFieldsSetText.Replace("\r\n", "\n"), text.Replace("\r\n", "\n")); }); }
public void PrintBuilder() { TestUtil.TestInMultipleCultures(() => { string messageText = TextFormat.PrintToString(TestUtil.GetAllSet()); string builderText = TextFormat.PrintToString(TestUtil.GetAllSet().ToBuilder()); Assert.AreEqual(messageText, builderText); }); }
public void PrintUnknownFields() { TestEmptyMessage message = TestEmptyMessage.CreateBuilder() .SetUnknownFields( UnknownFieldSet.CreateBuilder() .AddField(5, UnknownField.CreateBuilder() .AddVarint(1) .AddFixed32(2) .AddFixed64(3) .AddLengthDelimited(ByteString.CopyFromUtf8("4")) .AddGroup( UnknownFieldSet.CreateBuilder() .AddField(10, UnknownField.CreateBuilder() .AddVarint(5) .Build()) .Build()) .Build()) .AddField(8, UnknownField.CreateBuilder() .AddVarint(1) .AddVarint(2) .AddVarint(3) .Build()) .AddField(15, UnknownField.CreateBuilder() .AddVarint(0xABCDEF1234567890L) .AddFixed32(0xABCD1234) .AddFixed64(0xABCDEF1234567890L) .Build()) .Build()) .Build(); Assert.AreEqual( "5: 1\n" + "5: 0x00000002\n" + "5: 0x0000000000000003\n" + "5: \"4\"\n" + "5 {\n" + " 10: 5\n" + "}\n" + "8: 1\n" + "8: 2\n" + "8: 3\n" + "15: 12379813812177893520\n" + "15: 0xabcd1234\n" + "15: 0xabcdef1234567890\n", TextFormat.PrintToString(message)); }
public void PrintExtensions() { string text = TextFormat.PrintToString(TestUtil.GetAllExtensionsSet()); Assert.AreEqual(AllExtensionsSetText.Replace("\r\n", "\n"), text.Replace("\r\n", "\n")); }
/// <summary> /// Converts the set to a string in protocol buffer text format. This /// is just a trivial wrapper around TextFormat.PrintToString. /// </summary> public override String ToString() { return(TextFormat.PrintToString(this)); }
public sealed override string ToString() { return(TextFormat.PrintToString(this)); }