本文整理汇总了C#中BinaryReader.ReadInt方法的典型用法代码示例。如果您正苦于以下问题:C# BinaryReader.ReadInt方法的具体用法?C# BinaryReader.ReadInt怎么用?C# BinaryReader.ReadInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BinaryReader
的用法示例。
在下文中一共展示了BinaryReader.ReadInt方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ServiceDescriptor
/// <summary>
/// Initializes a new instance of the <see cref="ServiceDescriptor" /> class.
/// </summary>
/// <param name="name">Name.</param>
/// <param name="reader">Reader.</param>
/// <param name="services">Services.</param>
public ServiceDescriptor(string name, BinaryReader reader, IServices services)
{
Debug.Assert(reader != null);
Debug.Assert(services != null);
Debug.Assert(!string.IsNullOrEmpty(name));
_services = services;
Name = name;
CacheName = reader.ReadString();
MaxPerNodeCount = reader.ReadInt();
TotalCount = reader.ReadInt();
OriginNodeId = reader.ReadGuid() ?? Guid.Empty;
AffinityKey = reader.ReadObject<object>();
var mapSize = reader.ReadInt();
var snap = new Dictionary<Guid, int>(mapSize);
for (var i = 0; i < mapSize; i++)
snap[reader.ReadGuid() ?? Guid.Empty] = reader.ReadInt();
TopologySnapshot = snap.AsReadOnly();
}
示例2: ReadNullableList
/// <summary>
/// Reads nullable list.
/// </summary>
/// <param name="reader">Reader.</param>
/// <returns>List.</returns>
private static List<object> ReadNullableList(BinaryReader reader)
{
if (!reader.ReadBoolean())
return null;
var size = reader.ReadInt();
var list = new List<object>(size);
for (int i = 0; i < size; i++)
list.Add(reader.ReadObject<object>());
return list;
}
示例3: TcpDiscoverySpi
/// <summary>
/// Initializes a new instance of the <see cref="TcpDiscoverySpi"/> class.
/// </summary>
/// <param name="reader">The reader.</param>
internal TcpDiscoverySpi(BinaryReader reader)
{
IpFinder = reader.ReadBoolean() ? TcpDiscoveryIpFinderBase.ReadInstance(reader) : null;
SocketTimeout = reader.ReadLongAsTimespan();
AckTimeout = reader.ReadLongAsTimespan();
MaxAckTimeout = reader.ReadLongAsTimespan();
NetworkTimeout = reader.ReadLongAsTimespan();
JoinTimeout = reader.ReadLongAsTimespan();
ForceServerMode = reader.ReadBoolean();
ClientReconnectDisabled = reader.ReadBoolean();
LocalAddress = reader.ReadString();
ReconnectCount = reader.ReadInt();
LocalPort = reader.ReadInt();
LocalPortRange = reader.ReadInt();
MaxMissedHeartbeats = reader.ReadInt();
MaxMissedClientHeartbeats = reader.ReadInt();
StatisticsPrintFrequency = reader.ReadLongAsTimespan();
IpFinderCleanFrequency = reader.ReadLongAsTimespan();
ThreadPriority = reader.ReadInt();
HeartbeatFrequency = reader.ReadLongAsTimespan();
TopologyHistorySize = reader.ReadInt();
}
示例4: LoadMap
internal IEnumerator LoadMap(string s, Action onError = null, Action onLoaded = null)
{
mapLoading = true;
loadMap = null;
unityMap = "";
swirl = 0;
scale = 1;
print(mainSite + s);
WWW www = new WWW(mainSite + s);
yield return www;
if (!string.IsNullOrEmpty(www.error)) { if (onError != null) onError(); yield break; }
BinaryReader ms = new BinaryReader(www.bytes);
Debug.LogWarning("Loading Map " + ms.Length + " " + s);
int version = 0;
Dictionary<int, CurvySpline2> saveIds = new Dictionary<int, CurvySpline2>();
//bool ingame = _Game != null;
//HashSet<KeyValuePair<Vector3, string>> cells = new HashSet<KeyValuePair<Vector3, string>>();
ModelObject modelObject = null;
var enumType = typeof(LevelPackets);
//var levelPackets = Enum.GetValues(enumType);
LevelPackets P, oldP = LevelPackets.Unknown;
while (ms.Position < ms.Length)
{
try
{
P = (LevelPackets)ms.ReadInt();
if (!Enum.IsDefined(enumType, P))
{
ms.Position++;
if (isDebug)
Debug.LogError("wrong Levelpacked " + oldP);
else
Loader.errors++;
P = (LevelPackets)ms.ReadInt();
if (!Enum.IsDefined(enumType, P))
{
ms.Position--;
continue;
}
}
}
catch (Exception e)
{
Debug.LogError(e);
continue;
}
oldP = P;
if (P == LevelPackets.unityMap)
{
var map = ms.ReadString();
yield return StartCoroutine(LoadUnityMap(map));
}
if (P == LevelPackets.Spline)
yield return StartCoroutine(CreateSpline());
if (P == LevelPackets.shape)
{
yield return StartCoroutine(CreateSpline(null, true));
spline.CreatePivot(ms.ReadVector());
spline.saveId = ms.ReadInt();
saveIds[spline.saveId] = spline;
spline.tunnel = ms.ReadBool();
spline.materialId = ms.ReadInt();
spline.color = ms.readColor();
spline.name = ms.ReadString();
}
try
{
if (P == LevelPackets.flatTerrain)
SetFlatTerrain(true);
if (P == LevelPackets.ClosedSpline)
spline.Closed = true;
if (P == LevelPackets.CheckPoint2)
{
var t = SetCheckPoint(ms.ReadVector());
t.eulerAngles = ms.ReadVector();
}
if (P == LevelPackets.disableTerrain)
hideTerrain = true;
if (P == LevelPackets.Block)
{
var readString = ms.ReadString();
GameObject go;
if (modelLib == null)
{
Debug.LogWarning("Model lib not loaded");
go = GameObject.CreatePrimitive(PrimitiveType.Cube);
}
else if (modelLib.dict.ContainsKey(readString) && modelLib.dict[readString].gameObj != null)
{
ModelFile modelFile = modelLib.dict[readString];
var gameObj = modelFile.gameObj;
modelFile.usedCount++;
go = (GameObject)Instantiate(gameObj);
//.........这里部分代码省略.........
示例5: TcpCommunicationSpi
/// <summary>
/// Initializes a new instance of the <see cref="TcpCommunicationSpi"/> class.
/// </summary>
/// <param name="reader">The reader.</param>
internal TcpCommunicationSpi(BinaryReader reader)
{
AckSendThreshold = reader.ReadInt();
ConnectTimeout = reader.ReadLongAsTimespan();
DirectBuffer = reader.ReadBoolean();
DirectSendBuffer = reader.ReadBoolean();
IdleConnectionTimeout = reader.ReadLongAsTimespan();
LocalAddress = reader.ReadString();
LocalPort = reader.ReadInt();
LocalPortRange = reader.ReadInt();
MaxConnectTimeout = reader.ReadLongAsTimespan();
MessageQueueLimit = reader.ReadInt();
ReconnectCount = reader.ReadInt();
SelectorsCount = reader.ReadInt();
SlowClientQueueLimit = reader.ReadInt();
SocketReceiveBufferSize = reader.ReadInt();
SocketSendBufferSize = reader.ReadInt();
TcpNoDelay = reader.ReadBoolean();
UnacknowledgedMessagesBufferSize = reader.ReadInt();
}
示例6: ReadReplay
private Replay ReadReplay(byte[] buffer)
{
Replay rep = new Replay();
if (buffer == null) { print("Buffer is null"); return rep; }
rep.contry = _Loader.Country;
using (var ms = new BinaryReader(buffer))
{
Vector3 oldPos = Vector3.zero;
float oldmeters = 0;
PosVel posvel = null;
int vers = 0;
int errors = 0;
while (ms.Position < ms.Length)
{
lastRd = curredRd;
var b = curredRd = ms.ReadByte();
try
{
if (b == RD.playerName)
{
rep.playerName = ms.ReadString();
Debug.LogWarning(rep.playerName);
}
else if (b == RD.clan)
rep.clanTag = ms.ReadString();
else if (b == RD.version)
{
if (vers == 1241 || vers == 1234) return null;
vers = ms.ReadInt();
}
else if (b == RD.posVel)
{
posvel = new PosVel();
posvel.pos = ms.ReadVector();
if (oldPos == Vector3.zero)
oldPos = posvel.pos;
posvel.meters = oldmeters = oldmeters + (posvel.pos - oldPos).magnitude;
oldPos = posvel.pos;
posvel.rot.eulerAngles = ms.ReadVector();
posvel.vel = ms.ReadVector();
rep.posVels.Add(posvel);
}
else if (b == RD.score)
/*posvel.score = */
ms.ReadInt();
else if (b == RD.posVelMouse)
posvel.mouserot = ms.ReadFloat();
else if (b == RD.posVelSkid)
posvel.skid = ms.ReadFloat();
else if (b == RD.keyCode)
{
var kc = (KeyCode)ms.ReadInt();
float t = ms.ReadFloat();
bool d = ms.ReadBool();
//if (Player.recordKeys.Contains(kc))
rep.keyDowns.Add(new KeyDown() { down = d, keyCode = kc, time = t });
}
else if (b == RD.avatarId)
rep.avatarId = ms.ReadInt();
else if (b == RD.carSkin)
rep.carSkin = ms.ReadInt();
else if (b == RD.FinnishTime)
rep.finnishTime = ms.ReadFloat();
else if (b == RD.country)
{
CountryCodes countryCodes = (CountryCodes)ms.ReadByte();
//if (countryCodes != CountryCodes.fi)
rep.contry = countryCodes;
//print("Read Country " + rep.contry);
}
else if (b == RD.color)
rep.color = new Color(ms.ReadFloat(), ms.ReadFloat(), ms.ReadFloat());
else if (b == RD.avatarUrl)
rep.avatarUrl = ms.ReadString();
else if (b == RD.rank)
rep.rank = ms.ReadInt();
else
{
if (errors == 0)
Debug.LogError("byte unknown type " + b + " lastType " + lastRd + " version " + vers);
errors++;
//if (isDebug)
// Debug.LogError("byte unknown type " + b);
}
}
catch (Exception e)
{
if (errors == 0)
Debug.LogError("error curType" + b + " lastType " + lastRd + " version " + vers + "\n" + e);
errors++;
}
}
print("Replay version " + vers + " errors" + errors);
}
return rep;
}