本文整理汇总了C#中Reader.ReadShort方法的典型用法代码示例。如果您正苦于以下问题:C# Reader.ReadShort方法的具体用法?C# Reader.ReadShort怎么用?C# Reader.ReadShort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Reader
的用法示例。
在下文中一共展示了Reader.ReadShort方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParseSettings
static SourceParseResult ParseSettings(byte[] info) {
var r = new Reader(info);
r.Skip(5);
var settings = new SourceParseResult();
settings.Protocol = r.ReadAsInt();
settings.Name = r.ReadStringUntil();
settings.Map = r.ReadStringUntil();
settings.Folder = r.ReadStringUntil();
settings.Game = r.ReadStringUntil();
settings.AppId = r.ReadShort();
settings.CurrentPlayers = r.ReadAsInt();
settings.MaxPlayers = r.ReadAsInt();
settings.BotCount = r.ReadAsInt();
settings.ServerType = r.ReadAsInt();
settings.Environment = r.ReadAsInt();
settings.Visibility = r.ReadAsInt();
settings.Vac = r.ReadAsInt();
//if The Ship, additional fields:
//_results.mode = reply[pos++];
//_results.witnesses = reply[pos++];
//_results.duration = reply[pos++];
settings.Version = r.ReadStringUntil();
var edf = r.ReadByte();
//settings.edf = edf.ToString(CultureInfo.InvariantCulture);
if ((edf & 0x80) != 0)
settings.Port = r.ReadShort();
if ((edf & 0x10) != 0)
settings.SteamId = r.ReadLong();
if ((edf & 0x40) != 0) {
settings.TvPort = r.ReadShort();
settings.TvName = r.ReadStringUntil();
}
if ((edf & 0x20) != 0) {
settings.Keywords = r.ReadStringUntil();
}
//gameID = full appID if was truncated in previous field (not always the case)
if ((edf & 0x01) != 0)
settings.AppId = r.ReadLong();
return settings;
}
示例2: ParseRules
public static Dictionary<string, string> ParseRules(byte[] rules) {
var r = new Reader(rules);
r.Skip(5);
var ruleCount = r.ReadShort();
var dict = new Dictionary<string, string>();
r.Skip(2);
r.WhileNotOutOfBounds(ruleCount, () => {
var rule = r.ReadStringUntil();
var value = r.ReadStringUntil();
dict[rule] = value;
});
return dict;
}