本文整理汇总了C#中Structure.ReadByte方法的典型用法代码示例。如果您正苦于以下问题:C# Structure.ReadByte方法的具体用法?C# Structure.ReadByte怎么用?C# Structure.ReadByte使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Structure
的用法示例。
在下文中一共展示了Structure.ReadByte方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanReadAndWriteStructsFromTrees
public void CanReadAndWriteStructsFromTrees()
{
var indexedAt = new DateTime(2015, 1, 20);
var schema = new StructureSchema<IndexingStatsFields>()
.Add<int>(IndexingStatsFields.Attempts)
.Add<int>(IndexingStatsFields.Errors)
.Add<int>(IndexingStatsFields.Successes)
.Add<byte>(IndexingStatsFields.IsValid)
.Add<long>(IndexingStatsFields.IndexedAt);
using (var tx = Env.NewTransaction(TransactionFlags.ReadWrite))
{
var tree = Env.CreateTree(tx, "stats");
var stats = new Structure<IndexingStatsFields>(schema);
stats.Set(IndexingStatsFields.Attempts, 5);
stats.Set(IndexingStatsFields.Errors, -1);
stats.Set(IndexingStatsFields.Successes, 4);
stats.Set(IndexingStatsFields.IsValid, (byte) 1);
stats.Set(IndexingStatsFields.IndexedAt, indexedAt.ToBinary());
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;
Assert.Equal(5, stats.ReadInt(IndexingStatsFields.Attempts));
Assert.Equal(-1, stats.ReadInt(IndexingStatsFields.Errors));
Assert.Equal(4, stats.ReadInt(IndexingStatsFields.Successes));
Assert.Equal(1, stats.ReadByte(IndexingStatsFields.IsValid));
Assert.Equal(indexedAt, DateTime.FromBinary(stats.ReadLong(IndexingStatsFields.IndexedAt)));
}
}