当前位置: 首页>>代码示例>>C#>>正文


C# RelayTwo.MergeWith方法代码示例

本文整理汇总了C#中RelayTwo.MergeWith方法的典型用法代码示例。如果您正苦于以下问题:C# RelayTwo.MergeWith方法的具体用法?C# RelayTwo.MergeWith怎么用?C# RelayTwo.MergeWith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RelayTwo的用法示例。


在下文中一共展示了RelayTwo.MergeWith方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MergeSavesWithDifferentFields

        public void MergeSavesWithDifferentFields()
        {
			{
	            RelayTwo relay = new RelayTwo();
				
				TableTwo table = relay.CreateTable("Table");
	
	            table.AddField<string>("oldField");
	
	            TableRow row1 = table.CreateRow();
	            TableRow row2 = table.CreateRow();
				TableRow row3 = table.CreateRow();
	
	            row1.Set("oldField", "kottar");
	            row2.Set("oldField", "stenar");
				row3.Set("oldField", "gräs");
				
				relay.Subset("Table", (o => o.row == 0)).SaveAll("s0.json");
				relay.Subset("Table", (o => o.row == 1)).SaveAll("s1.json");
				relay.Subset("Table", (o => o.row == 2)).SaveAll("s2.json");
	
				table.AddField<int>("newField");
				
	            TableRow row4 = table.CreateRow();
				TableRow row5 = table.CreateRow();		
				
				row4.Set("newField", 500);
				row5.Set("newField", 1000);
				
				relay.Subset("Table", (o => o.row == 3)).SaveAll("s3.json");
				relay.Subset("Table", (o => o.row == 4)).SaveAll("s4.json");
			}
			{
				RelayTwo relay = new RelayTwo();
				
				relay.MergeWith(new RelayTwo("s4.json"));
				relay.MergeWith(new RelayTwo("s0.json"));
				relay.MergeWith(new RelayTwo("s1.json"));
				relay.MergeWith(new RelayTwo("s2.json"));
				relay.MergeWith(new RelayTwo("s3.json"));
				
				
				TableTwo table = relay.GetTable("Table");
				Assert.AreEqual(5, table.GetRows().Length);
				
				Assert.AreEqual("kottar", table.GetRow(0).Get<string>("oldField"));
				Assert.AreEqual("stenar", table.GetRow(1).Get<string>("oldField"));
				Assert.AreEqual("gräs", table.GetRow(2).Get<string>("oldField"));
				
				Assert.AreEqual(500, table.GetRow(3).Get<int>("newField"));
				Assert.AreEqual(1000, table.GetRow(4).Get<int>("newField"));
			}
        }
开发者ID:substans,项目名称:Relay,代码行数:53,代码来源:RelayTwoTests.cs

示例2: MergeSaves

        public void MergeSaves()
        {
			{
	            RelayTwo relay = new RelayTwo();
				
				TableTwo table = relay.CreateTable("Table");
	
	            table.AddField<string>("name");
	
	            TableRow row1 = table.CreateRow();
	            TableRow row2 = table.CreateRow();
	            TableRow row3 = table.CreateRow();
	
	            row1.Set("name", "a");
	            row2.Set("name", "b");
				row3.Set("name", "c");
	
	            Assert.AreEqual(3, table.GetRows().Length);
				Assert.AreEqual("a", table.GetRow(0).Get<string>("name"));
				Assert.AreEqual("b", table.GetRow(1).Get<string>("name"));
				Assert.AreEqual("c", table.GetRow(2).Get<string>("name"));
	
	            RelayTwo save1 = relay.Subset("Table", (o => o.Get<string>("name") == "a"));
	            RelayTwo save2 = relay.Subset("Table", (o => o.Get<string>("name") == "b"));
				RelayTwo save3 = relay.Subset("Table", (o => o.Get<string>("name") == "c"));
				
				Assert.AreEqual(1, save1.GetTable("Table").GetRows().Length);
				Assert.AreEqual(1, save2.GetTable("Table").GetRows().Length);
				Assert.AreEqual(1, save3.GetTable("Table").GetRows().Length);
				
				save1.SaveAll("PartialSave1.json");
				save2.SaveAll("PartialSave2.json");
				save3.SaveAll("PartialSave3.json");
			}
			{
				RelayTwo relay = new RelayTwo();
				relay.MergeWith(new RelayTwo("PartialSave1.json"));
				relay.MergeWith(new RelayTwo("PartialSave2.json"));
				relay.MergeWith(new RelayTwo("PartialSave3.json"));
				
				TableTwo table = relay.GetTable("Table");
				Assert.AreEqual(3, table.GetRows().Length);
				
				Assert.AreEqual("a", table.GetRow(0).Get<string>("name"));
				Assert.AreEqual("b", table.GetRow(1).Get<string>("name"));
				Assert.AreEqual("c", table.GetRow(2).Get<string>("name"));
			}
        }
开发者ID:substans,项目名称:Relay,代码行数:48,代码来源:RelayTwoTests.cs


注:本文中的RelayTwo.MergeWith方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。