本文整理汇总了C#中Content.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# Content.Equals方法的具体用法?C# Content.Equals怎么用?C# Content.Equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Content
的用法示例。
在下文中一共展示了Content.Equals方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ContentDeserializationTest_DeserializeFromJson_Success
public void ContentDeserializationTest_DeserializeFromJson_Success()
{
var valuesToFill = new Content(
// Add field.
new FieldContent("Report date", new DateTime(2000, 01, 01).ToShortDateString()),
// Add table.
new TableContent("Team Members Table")
.AddRow(
new FieldContent("Name", "Eric"),
new FieldContent("Role", "Program Manager"))
.AddRow(
new FieldContent("Name", "Bob"),
new FieldContent("Role", "Developer")),
// Add nested list.
new ListContent("Team Members Nested List")
.AddItem(new ListItemContent("Role", "Program Manager")
.AddNestedItem(new FieldContent("Name", "Eric"))
.AddNestedItem(new FieldContent("Name", "Ann")))
.AddItem(new ListItemContent("Role", "Developer")
.AddNestedItem(new FieldContent("Name", "Bob"))
.AddNestedItem(new FieldContent("Name", "Richard"))),
// Add image
new ImageContent("photo", new byte[] { 1, 2, 3 })
);
const string serialized = "{\"Tables\":[{\"Name\":\"Team Members Table\",\"Rows\":[{\"Tables\":[],\"Lists\":[],\"Fields\":[{\"Name\":\"Name\",\"Value\":\"Eric\"},{\"Name\":\"Role\",\"Value\":\"Program Manager\"}],\"Images\":[]},{\"Tables\":[],\"Lists\":[],\"Fields\":[{\"Name\":\"Name\",\"Value\":\"Bob\"},{\"Name\":\"Role\",\"Value\":\"Developer\"}],\"Images\":[]}],\"FieldNames\":[\"Name\",\"Role\"]}],\"Lists\":[{\"Name\":\"Team Members Nested List\",\"Items\":[{\"NestedFields\":[{\"NestedFields\":null,\"Tables\":[],\"Lists\":[],\"Fields\":[{\"Name\":\"Name\",\"Value\":\"Eric\"}],\"Images\":[]},{\"NestedFields\":null,\"Tables\":[],\"Lists\":[],\"Fields\":[{\"Name\":\"Name\",\"Value\":\"Ann\"}],\"Images\":[]}],\"Tables\":[],\"Lists\":[],\"Fields\":[{\"Name\":\"Role\",\"Value\":\"Program Manager\"}],\"Images\":[]},{\"NestedFields\":[{\"NestedFields\":null,\"Tables\":[],\"Lists\":[],\"Fields\":[{\"Name\":\"Name\",\"Value\":\"Bob\"}],\"Images\":[]},{\"NestedFields\":null,\"Tables\":[],\"Lists\":[],\"Fields\":[{\"Name\":\"Name\",\"Value\":\"Richard\"}],\"Images\":[]}],\"Tables\":[],\"Lists\":[],\"Fields\":[{\"Name\":\"Role\",\"Value\":\"Developer\"}],\"Images\":[]}],\"FieldNames\":[\"Role\",\"Name\"]}],\"Fields\":[{\"Name\":\"Report date\",\"Value\":\"01.01.2000\"}],\"Images\":[{\"Name\":\"photo\",\"Binary\":\"AQID\"}]}";
var deserialized = JsonConvert.DeserializeObject<Content>(serialized);
Assert.IsTrue(valuesToFill.Equals(deserialized));
}
示例2: ContentDeserializationTest_EmptyContentDeserializeFromJson_Success
public void ContentDeserializationTest_EmptyContentDeserializeFromJson_Success()
{
var valuesToFill = new Content();
const string serialized = "{\"Tables\":[],\"Lists\":[],\"Fields\":[],\"Images\":[]}";
var deserialized = JsonConvert.DeserializeObject<Content>(serialized);
Assert.IsTrue(valuesToFill.Equals(deserialized));
}
示例3: EqualsTest_CopareWithNull_NotEquals
public void EqualsTest_CopareWithNull_NotEquals()
{
var firstValuesToFill = new Content(
// Add field.
new FieldContent("Report date", new DateTime(2000, 01, 01).ToShortDateString()),
// Add table.
new TableContent("Team Members Table")
.AddRow(
new FieldContent("Name", "Eric"),
new FieldContent("Role", "Program Manager"))
.AddRow(
new FieldContent("Name", "Bob"),
new FieldContent("Role", "Developer"))
);
Assert.IsFalse(firstValuesToFill.Equals(null));
}
示例4: EqualsTest_ObjectsAreEqual_Equals
public void EqualsTest_ObjectsAreEqual_Equals()
{
var firstValuesToFill = new Content(
// Add field.
new FieldContent("Report date", new DateTime(2000, 01, 01).ToShortDateString()),
// Add table.
new TableContent("Team Members Table")
.AddRow(
new FieldContent("Name", "Eric"),
new FieldContent("Role", "Program Manager"))
.AddRow(
new FieldContent("Name", "Bob"),
new FieldContent("Role", "Developer")),
// Add nested list.
new ListContent("Team Members Nested List")
.AddItem(new ListItemContent("Role", "Program Manager")
.AddNestedItem(new FieldContent("Name", "Eric"))
.AddNestedItem(new FieldContent("Name", "Ann")))
.AddItem(new ListItemContent("Role", "Developer")
.AddNestedItem(new FieldContent("Name", "Bob"))
.AddNestedItem(new FieldContent("Name", "Richard"))),
// Add image
new ImageContent("photo", new byte[] { 1, 2, 3 })
);
var secondValuesToFill = new Content(
// Add field.
new FieldContent("Report date", new DateTime(2000, 01, 01).ToShortDateString()),
// Add table.
new TableContent("Team Members Table")
.AddRow(
new FieldContent("Name", "Eric"),
new FieldContent("Role", "Program Manager"))
.AddRow(
new FieldContent("Name", "Bob"),
new FieldContent("Role", "Developer")),
// Add nested list.
new ListContent("Team Members Nested List")
.AddItem(new ListItemContent("Role", "Program Manager")
.AddNestedItem(new FieldContent("Name", "Eric"))
.AddNestedItem(new FieldContent("Name", "Ann")))
.AddItem(new ListItemContent("Role", "Developer")
.AddNestedItem(new FieldContent("Name", "Bob"))
.AddNestedItem(new FieldContent("Name", "Richard"))),
// Add image
new ImageContent("photo", new byte[] { 1, 2, 3 })
);
Assert.IsTrue(firstValuesToFill.Equals(secondValuesToFill));
}