本文整理汇总了C#中RelayTwo.GetTable方法的典型用法代码示例。如果您正苦于以下问题:C# RelayTwo.GetTable方法的具体用法?C# RelayTwo.GetTable怎么用?C# RelayTwo.GetTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RelayTwo
的用法示例。
在下文中一共展示了RelayTwo.GetTable方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TimetableRunner
//, TingRunner pTingRunner)
public TimetableRunner(RelayTwo pRelay)
{
_timetableTable = pRelay.GetTable(Timetable.TABLE_NAME);
foreach(var timetable in InstantiatorTwo.Process<Timetable>(_timetableTable)) {
_timetables[timetable.name] = timetable;
}
}
示例2: CreateInitialSaveFromInitData1
public void CreateInitialSaveFromInitData1()
{
InitialSaveFileCreator i = new InitialSaveFileCreator();
i.CreateSaveFile("../InitData1/", WorldTestHelper.INITIAL_SAVE_1);
RelayTwo relay = new RelayTwo(WorldTestHelper.INITIAL_SAVE_1);
AssertThatCanFindAllTables(relay);
TableTwo tingTable = relay.GetTable(Character.TABLE_NAME);
Assert.AreEqual("Adam", tingTable.GetRow(0).Get<string>("name"));
Assert.AreEqual("Eva", tingTable.GetRow(1).Get<string>("name"));
Assert.AreEqual("PowerCube", relay.GetTable(MysticalCube.TABLE_NAME).GetRow(0).Get<string>("name"));
TableTwo roomTable = relay.GetTable(Room.TABLE_NAME);
Assert.AreEqual("Eden", roomTable.GetRow(0).Get<string>("name"));
Assert.AreEqual("Hallway", roomTable.GetRow(1).Get<string>("name"));
Assert.AreEqual("Kitchen", roomTable.GetRow(2).Get<string>("name"));
Assert.AreEqual("Bedroom", roomTable.GetRow(3).Get<string>("name"));
}
示例3: ProgramRunner
public ProgramRunner(RelayTwo pRelay)
{
D.isNull(pRelay);
_programTable = pRelay.GetTable(Program.TABLE_NAME);
_programsList = InstantiatorTwo.Process<Program>(_programTable);
foreach (var program in _programsList) {
program.Init(this);
_programsDictionary.Add(program.objectId, program);
}
}
示例4: SourceCodeDispenser
public SourceCodeDispenser(RelayTwo pRelay)
{
_sourceCodeTable = pRelay.GetTable(SourceCode.TABLE_NAME);
//Console.WriteLine("Getting source code from " + _sourceCodeTable.name);
_sourceCodes = InstantiatorTwo.Process<SourceCode>(_sourceCodeTable);
foreach (SourceCode sc in _sourceCodes)
{
//Console.WriteLine("found source code " + sc.name);
}
}
示例5: AssertThatCanFindAllTables
void AssertThatCanFindAllTables(RelayTwo pRelay)
{
Assert.IsNotNull(pRelay.GetTable(Ting.TABLE_NAME));
Assert.IsNotNull(pRelay.GetTable(Room.TABLE_NAME));
Assert.IsNotNull(pRelay.GetTable(DialogueNode.TABLE_NAME));
Assert.IsNotNull(pRelay.GetTable(SourceCode.TABLE_NAME));
Assert.IsNotNull(pRelay.GetTable(Program.TABLE_NAME));
Assert.IsNotNull(pRelay.GetTable(WorldSettings.TABLE_NAME));
}
示例6: SaveSubsetOfDatabase
public void SaveSubsetOfDatabase()
{
{
RelayTwo relay = new RelayTwo();
TableTwo table = relay.CreateTable("Table1");
table.AddField<string>("name");
table.AddField<bool>("1337");
TableRow row1 = table.CreateRow();
TableRow row2 = table.CreateRow();
TableRow row3 = table.CreateRow();
row1.Set("name", "Arne");
row1.Set("1337", false);
row2.Set("name", "Björn");
row2.Set("1337", true);
row3.Set("name", "Charlie");
row3.Set("1337", false);
Assert.AreEqual(3, table.GetRows().Length);
RelayTwo subset = relay.Subset("Table1", (o => o.Get<bool>("1337") == true));
subset.SaveAll("Only1337People.json");
}
{
RelayTwo relay = new RelayTwo("Only1337People.json");
TableTwo table = relay.GetTable("Table1");
TableRow[] rows = table.GetRows();
Assert.AreEqual(1, rows.Length);
Assert.AreEqual("Björn", table.First().Get<string>("name"));
}
}
示例7: 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"));
}
}
示例8: 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"));
}
}
示例9: LoadFromSeveralPartialDatabases
public void LoadFromSeveralPartialDatabases()
{
{
RelayTwo r1 = new RelayTwo();
TableTwo t = r1.CreateTable("Table");
t.AddField<string>("animal");
t.AddField<int>("age");
TableRow row0 = t.CreateRow();
row0.Set("animal", "rabbit");
row0.Set("age", 5);
TableRow row1 = t.CreateRow();
row1.Set("animal", "salmon");
row1.Set("age", 10);
TableRow row2 = t.CreateRow();
row2.Set("animal", "spider");
row2.Set("age", 1);
r1.SaveAll("r1.json");
}
{
RelayTwo r2 = new RelayTwo();
TableTwo t = r2.CreateTable("Table");
t.AddField<string>("animal");
t.AddField<bool>("carnivore");
TableRow row0 = t.CreateRow();
row0.Set("animal", "mouse");
row0.Set("carnivore", false);
TableRow row1 = t.CreateRow();
row1.Set("animal", "fox");
row1.Set("carnivore", true);
r2.SaveAll("r2.json");
}
{
RelayTwo combined = new RelayTwo();
combined.AppendTables("r1.json");
combined.AppendTables("r2.json");
Assert.AreEqual(1, combined.tables.Count);
TableTwo t = combined.GetTable("Table");
Assert.AreEqual(3, t.fieldNames.Length);
Console.WriteLine("The merged table contains the following rows: ");
foreach(int rowIndex in t.GetIndexesOfPopulatedRows())
{
TableRow row = t[rowIndex];
Console.WriteLine("Values in row " + rowIndex);
foreach(string s in row.valuesAsStrings) {
Console.Write(s + ", ");
}
Console.WriteLine("\n");
}
Assert.AreEqual(5, t.GetIndexesOfPopulatedRows().Length);
TableRow rabbit = t[0];
TableRow salmon = t[1];
TableRow spider = t[2];
TableRow mouse = t[3];
TableRow fox = t[4];
Assert.AreEqual("rabbit", rabbit.Get<string>("animal"));
Assert.AreEqual("salmon", salmon.Get<string>("animal"));
Assert.AreEqual("spider", spider.Get<string>("animal"));
Assert.AreEqual("mouse", mouse.Get<string>("animal"));
Assert.AreEqual("fox", fox.Get<string>("animal"));
Assert.AreEqual(5, rabbit.Get<int>("age"));
Assert.AreEqual(10, salmon.Get<int>("age"));
Assert.AreEqual(1, spider.Get<int>("age"));
Assert.Throws<RelayException>(() =>
{
Assert.AreEqual(0, mouse.Get<int>("age"));
});
Assert.Throws<RelayException>(() =>
{
Assert.AreEqual(0, fox.Get<int>("age"));
});
Assert.AreEqual(true, fox.Get<bool>("carnivore"));
}
}
示例10: SaveAndLoad
public void SaveAndLoad()
{
int rowNr0, rowNr1, rowNr2;
{
RelayTwo r1 = new RelayTwo();
r1.CreateTable("Table1");
TableTwo table = r1.GetTable("Table1");
rowNr0 = table.CreateRow().row;
rowNr1 = table.CreateRow().row;
rowNr2 = table.CreateRow().row;
table.GetValueEntryEnsureDefault<float>(rowNr0, "a", 3.5f);
table.GetValueEntryEnsureDefault<float>(rowNr0, "b", 7.0f);
table.GetValueEntryEnsureDefault<float>(rowNr1, "a", 2.0f);
table.SetValue<float>(rowNr0, "a", 5.0f);
table.GetValueEntryEnsureDefault<string>(rowNr2, "blehu", "ap\na");
Assert.AreEqual(5.0f, table[rowNr0].Get<float>("a"));
Assert.AreEqual(7.0f, table[rowNr0].Get<float>("b"));
Assert.AreEqual(2.0f, table[rowNr1].Get<float>("a"));
Assert.AreEqual("ap\na", table[rowNr2].Get<string>("blehu"));
r1.SaveAll("sdfsdf.json");
}
{
RelayTwo r2 = new RelayTwo("sdfsdf.json");
TableTwo table = r2.GetTable("Table1");
Assert.AreEqual(5.0f, table[rowNr0].Get<float>("a"));
Assert.AreEqual(7.0f, table[rowNr0].Get<float>("b"));
Assert.AreEqual(2.0f, table[rowNr1].Get<float>("a"));
Assert.AreEqual("ap\na", table[rowNr2].Get<string>("blehu"));
}
}
示例11: WorldSettings
public WorldSettings(RelayTwo pRelay)
{
_table = pRelay.GetTable(TABLE_NAME);
SetupCells();
}