本文整理汇总了C#中Structure.ReadString方法的典型用法代码示例。如果您正苦于以下问题:C# Structure.ReadString方法的具体用法?C# Structure.ReadString怎么用?C# Structure.ReadString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Structure
的用法示例。
在下文中一共展示了Structure.ReadString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanReadAndWriteStructsWithProxyClassFromTrees
public void CanReadAndWriteStructsWithProxyClassFromTrees()
{
var indexedAt = new DateTime(2015, 1, 20);
var schema = ProxyGenerator.GetSchema<TestClass>();
foreach (var field in schema.Fields)
Console.WriteLine("{0,10} - {1} - {2}", field.Name, field.Type.ToString().PadRight(14), field.ToString());
Console.WriteLine();
using (var tx = Env.NewTransaction(TransactionFlags.ReadWrite))
{
var tree = Env.CreateTree(tx, "stats");
var stats = new Structure<int>(schema);
TestClass testClass = ProxyGenerator.CreateWriter<TestClass>(stats);
testClass.Attempts = 5;
testClass.Errors = -1;
testClass.Successes = 4;
testClass.IsValid = 1;
testClass.IndexedAt = indexedAt.ToBinary();
testClass.Text = "Some Text";
tree.WriteStruct("stats/1", stats);
tx.Commit();
}
using (var tx = Env.NewTransaction(TransactionFlags.Read))
{
var tree = tx.ReadTree("stats");
var stats = tree.ReadStruct("stats/1", schema).Reader;
TestClass testClass = ProxyGenerator.CreateReader<TestClass>(stats);
Console.WriteLine("Attempts: {0}", testClass.Attempts);
Console.WriteLine("Text: {0}", stats.ReadString(5));
Assert.Equal(5, testClass.Attempts);
Assert.Equal(-1, testClass.Errors);
Assert.Equal(4, testClass.Successes);
Assert.Equal(1, testClass.IsValid);
Assert.Equal(indexedAt, DateTime.FromBinary(testClass.IndexedAt));
Assert.Equal("Some Text", testClass.Text);
}
}