本文整理汇总了C#中NetGore.IO.BitStream.GetBuffer方法的典型用法代码示例。如果您正苦于以下问题:C# BitStream.GetBuffer方法的具体用法?C# BitStream.GetBuffer怎么用?C# BitStream.GetBuffer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NetGore.IO.BitStream
的用法示例。
在下文中一共展示了BitStream.GetBuffer方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestWriteReadValuesAndUpdatePositionVelocity
public void TestWriteReadValuesAndUpdatePositionVelocity()
{
var writer = new BitStream(2048);
var src = new DE();
_dynamicEntityFactoryBase.Write(writer, src);
var buffer = writer.GetBuffer();
var reader = new BitStream(buffer);
var dest = (DE)_dynamicEntityFactoryBase.Read(reader);
Assert.AreEqual(src.Position, dest.Position);
Assert.AreEqual(src.Size, dest.Size);
Assert.AreEqual(src.Velocity, dest.Velocity);
Assert.AreEqual(src.Weight, dest.Weight);
Assert.AreEqual(src.MapEntityIndex, dest.MapEntityIndex);
Assert.AreEqual(src.Center, dest.Center);
Assert.AreEqual(src.A, dest.A);
Assert.AreEqual(src.B, dest.B);
Assert.AreEqual(src.C, dest.C);
Assert.AreEqual(src.D, dest.D);
Assert.AreEqual(src.E, dest.E);
Assert.AreEqual(src.F, dest.F);
Assert.AreEqual(src.G, dest.G);
Assert.AreEqual(src.H, dest.H);
Assert.AreEqual(src.I, dest.I);
Assert.AreEqual(src.J, dest.J);
Assert.AreEqual(src.K, dest.K);
Assert.AreEqual(src.L, dest.L);
Assert.AreEqual(src.M, dest.M);
Assert.AreEqual(src.N, dest.N);
Assert.AreEqual(src.O, dest.O);
Assert.AreEqual(src.P, dest.P);
Assert.AreEqual(src.Q, dest.Q);
Assert.AreEqual(src.R, dest.R);
src.Position = new Vector2(10981, -123);
src.SetVelocity(new Vector2(0.114f, 10.181f));
writer = new BitStream(2048);
src.SerializePositionAndVelocity(writer, 0);
buffer = writer.GetBuffer();
reader = new BitStream(buffer);
dest.DeserializePositionAndVelocity(reader);
Assert.AreEqual(src.Position, dest.Position);
Assert.AreEqual(src.Size, dest.Size);
Assert.AreEqual(src.Velocity, dest.Velocity);
Assert.AreEqual(src.Weight, dest.Weight);
Assert.AreEqual(src.MapEntityIndex, dest.MapEntityIndex);
Assert.AreEqual(src.Center, dest.Center);
Assert.AreEqual(src.A, dest.A);
Assert.AreEqual(src.B, dest.B);
Assert.AreEqual(src.C, dest.C);
Assert.AreEqual(src.D, dest.D);
Assert.AreEqual(src.E, dest.E);
Assert.AreEqual(src.F, dest.F);
Assert.AreEqual(src.G, dest.G);
Assert.AreEqual(src.H, dest.H);
Assert.AreEqual(src.I, dest.I);
Assert.AreEqual(src.J, dest.J);
Assert.AreEqual(src.K, dest.K);
Assert.AreEqual(src.L, dest.L);
Assert.AreEqual(src.M, dest.M);
Assert.AreEqual(src.N, dest.N);
Assert.AreEqual(src.O, dest.O);
Assert.AreEqual(src.P, dest.P);
Assert.AreEqual(src.Q, dest.Q);
Assert.AreEqual(src.R, dest.R);
}
示例2: TestWriteReadValuesExtensive
public void TestWriteReadValuesExtensive()
{
var writer = new BitStream(2048);
var src = new DE();
_dynamicEntityFactoryBase.Write(writer, src);
var buffer = writer.GetBuffer();
var reader = new BitStream(buffer);
var dest = (DE)_dynamicEntityFactoryBase.Read(reader);
Assert.AreEqual(src.Position, dest.Position);
Assert.AreEqual(src.Size, dest.Size);
Assert.AreEqual(src.Velocity, dest.Velocity);
Assert.AreEqual(src.Weight, dest.Weight);
Assert.AreEqual(src.MapEntityIndex, dest.MapEntityIndex);
Assert.AreEqual(src.Center, dest.Center);
Assert.AreEqual(src.A, dest.A);
Assert.AreEqual(src.B, dest.B);
Assert.AreEqual(src.C, dest.C);
Assert.AreEqual(src.D, dest.D);
Assert.AreEqual(src.E, dest.E);
Assert.AreEqual(src.F, dest.F);
Assert.AreEqual(src.G, dest.G);
Assert.AreEqual(src.H, dest.H);
Assert.AreEqual(src.I, dest.I);
Assert.AreEqual(src.J, dest.J);
Assert.AreEqual(src.K, dest.K);
Assert.AreEqual(src.L, dest.L);
Assert.AreEqual(src.M, dest.M);
Assert.AreEqual(src.N, dest.N);
Assert.AreEqual(src.O, dest.O);
Assert.AreEqual(src.P, dest.P);
Assert.AreEqual(src.Q, dest.Q);
Assert.AreEqual(src.R, dest.R);
}
示例3: TestWriteReadValuesAndUpdateExtensive
public void TestWriteReadValuesAndUpdateExtensive()
{
var writer = new BitStream(2048);
var src = new DE();
_dynamicEntityFactoryBase.Write(writer, src);
var buffer = writer.GetBuffer();
var reader = new BitStream(buffer);
var dest = (DE)_dynamicEntityFactoryBase.Read(reader);
Assert.AreEqual(src.Position, dest.Position);
Assert.AreEqual(src.Size, dest.Size);
Assert.AreEqual(src.Velocity, dest.Velocity);
Assert.AreEqual(src.Weight, dest.Weight);
Assert.AreEqual(src.MapEntityIndex, dest.MapEntityIndex);
Assert.AreEqual(src.Center, dest.Center);
Assert.AreEqual(src.A, dest.A);
Assert.AreEqual(src.B, dest.B);
Assert.AreEqual(src.C, dest.C);
Assert.AreEqual(src.D, dest.D);
Assert.AreEqual(src.E, dest.E);
Assert.AreEqual(src.F, dest.F);
Assert.AreEqual(src.G, dest.G);
Assert.AreEqual(src.H, dest.H);
Assert.AreEqual(src.I, dest.I);
Assert.AreEqual(src.J, dest.J);
Assert.AreEqual(src.K, dest.K);
Assert.AreEqual(src.L, dest.L);
Assert.AreEqual(src.M, dest.M);
Assert.AreEqual(src.N, dest.N);
Assert.AreEqual(src.O, dest.O);
Assert.AreEqual(src.P, dest.P);
Assert.AreEqual(src.Q, dest.Q);
Assert.AreEqual(src.R, dest.R);
src.A = false;
src.D = 100;
src.K = 5123;
src.N = "asfdoiuweroijsadf";
src.P = Alignment.Left;
src.M = new GrhIndex(10091);
src.L = new Vector2(213, 123);
writer = new BitStream(2048);
src.Serialize(writer);
buffer = writer.GetBuffer();
reader = new BitStream(buffer);
dest.Deserialize(reader);
Assert.AreEqual(src.Position, dest.Position);
Assert.AreEqual(src.Size, dest.Size);
Assert.AreEqual(src.Velocity, dest.Velocity);
Assert.AreEqual(src.Weight, dest.Weight);
Assert.AreEqual(src.MapEntityIndex, dest.MapEntityIndex);
Assert.AreEqual(src.Center, dest.Center);
Assert.AreEqual(src.A, dest.A);
Assert.AreEqual(src.B, dest.B);
Assert.AreEqual(src.C, dest.C);
Assert.AreEqual(src.D, dest.D);
Assert.AreEqual(src.E, dest.E);
Assert.AreEqual(src.F, dest.F);
Assert.AreEqual(src.G, dest.G);
Assert.AreEqual(src.H, dest.H);
Assert.AreEqual(src.I, dest.I);
Assert.AreEqual(src.J, dest.J);
Assert.AreEqual(src.K, dest.K);
Assert.AreEqual(src.L, dest.L);
Assert.AreEqual(src.M, dest.M);
Assert.AreEqual(src.N, dest.N);
Assert.AreEqual(src.O, dest.O);
Assert.AreEqual(src.P, dest.P);
Assert.AreEqual(src.Q, dest.Q);
Assert.AreEqual(src.R, dest.R);
}
示例4: TestWriteReadValues
public void TestWriteReadValues()
{
var writer = new BitStream(1024);
var src = new DE();
_dynamicEntityFactoryBase.Write(writer, src);
var buffer = writer.GetBuffer();
var reader = new BitStream(buffer);
var dest = (DE)_dynamicEntityFactoryBase.Read(reader);
Assert.AreEqual(src.Position, dest.Position);
Assert.AreEqual(src.Size, dest.Size);
Assert.AreEqual(src.Velocity, dest.Velocity);
Assert.AreEqual(src.Weight, dest.Weight);
Assert.AreEqual(src.MapEntityIndex, dest.MapEntityIndex);
Assert.AreEqual(src.Center, dest.Center);
}
示例5: TestWriteReadManyValuesExtensive
public void TestWriteReadManyValuesExtensive()
{
const int count = 1000;
var writer = new BitStream(1024 * 1024);
var sources = new List<DE>(count);
for (var i = 0; i < count; i++)
{
var src = new DE();
sources.Add(src);
_dynamicEntityFactoryBase.Write(writer, src);
}
var buffer = writer.GetBuffer();
var reader = new BitStream(buffer);
for (var i = 0; i < count; i++)
{
var src = sources[i];
var dest = (DE)_dynamicEntityFactoryBase.Read(reader);
Assert.AreEqual(src.Position, dest.Position);
Assert.AreEqual(src.Size, dest.Size);
Assert.AreEqual(src.Velocity, dest.Velocity);
Assert.AreEqual(src.Weight, dest.Weight);
Assert.AreEqual(src.MapEntityIndex, dest.MapEntityIndex);
Assert.AreEqual(src.Center, dest.Center);
Assert.AreEqual(src.A, dest.A, "Index: " + i);
Assert.AreEqual(src.B, dest.B, "Index: " + i);
Assert.AreEqual(src.C, dest.C, "Index: " + i);
Assert.AreEqual(src.D, dest.D, "Index: " + i);
Assert.AreEqual(src.E, dest.E, "Index: " + i);
Assert.AreEqual(src.F, dest.F, "Index: " + i);
Assert.AreEqual(src.G, dest.G, "Index: " + i);
Assert.AreEqual(src.H, dest.H, "Index: " + i);
Assert.AreEqual(src.I, dest.I, "Index: " + i);
Assert.AreEqual(src.J, dest.J, "Index: " + i);
Assert.AreEqual(src.K, dest.K, "Index: " + i);
Assert.AreEqual(src.L, dest.L, "Index: " + i);
Assert.AreEqual(src.M, dest.M, "Index: " + i);
Assert.AreEqual(src.N, dest.N, "Index: " + i);
Assert.AreEqual(src.O, dest.O, "Index: " + i);
Assert.AreEqual(src.P, dest.P, "Index: " + i);
Assert.AreEqual(src.Q, dest.Q, "Index: " + i);
Assert.AreEqual(src.R, dest.R, "Index: " + i);
}
}
示例6: TestWriteRead
public void TestWriteRead()
{
var writer = new BitStream(2048);
var src = new DE();
_dynamicEntityFactoryBase.Write(writer, src);
var buffer = writer.GetBuffer();
var reader = new BitStream(buffer);
_dynamicEntityFactoryBase.Read(reader);
}
示例7: TestSkipNonSyncNetworkValues
public void TestSkipNonSyncNetworkValues()
{
var writer = new BitStream(2048);
var src = new DE { SkipA = 1, SkipB = 2, SkipC = 3 };
_dynamicEntityFactoryBase.Write(writer, src);
var buffer = writer.GetBuffer();
var reader = new BitStream(buffer);
var dest = (DE)_dynamicEntityFactoryBase.Read(reader);
Assert.AreEqual(src.Position, dest.Position);
Assert.AreEqual(src.Size, dest.Size);
Assert.AreEqual(src.Velocity, dest.Velocity);
Assert.AreEqual(src.Weight, dest.Weight);
Assert.AreEqual(src.MapEntityIndex, dest.MapEntityIndex);
Assert.AreEqual(src.Center, dest.Center);
Assert.AreEqual(src.A, dest.A);
Assert.AreEqual(src.B, dest.B);
Assert.AreEqual(src.C, dest.C);
Assert.AreEqual(src.D, dest.D);
Assert.AreEqual(src.E, dest.E);
Assert.AreEqual(src.F, dest.F);
Assert.AreEqual(src.G, dest.G);
Assert.AreEqual(src.H, dest.H);
Assert.AreEqual(src.I, dest.I);
Assert.AreEqual(src.J, dest.J);
Assert.AreEqual(src.K, dest.K);
Assert.AreEqual(src.L, dest.L);
Assert.AreEqual(src.M, dest.M);
Assert.AreEqual(src.N, dest.N);
Assert.AreEqual(src.O, dest.O);
Assert.AreEqual(src.P, dest.P);
Assert.AreEqual(src.Q, dest.Q);
Assert.AreEqual(src.R, dest.R);
Assert.AreNotEqual(src.SkipA, dest.SkipA);
Assert.AreNotEqual(src.SkipB, dest.SkipB);
Assert.AreEqual(src.SkipC, dest.SkipC);
src.A = false;
src.D = 100;
src.K = 5123;
src.N = "asfdoiuweroijsadf";
src.P = Alignment.Left;
src.M = new GrhIndex(10091);
src.L = new Vector2(213, 123);
src.Q = new Vector3(123, 412, 1931);
src.R = new Vector4(109, 12, 190, 51);
writer = new BitStream(2048);
src.Serialize(writer);
buffer = writer.GetBuffer();
reader = new BitStream(buffer);
dest.Deserialize(reader);
Assert.AreEqual(src.Position, dest.Position);
Assert.AreEqual(src.Size, dest.Size);
Assert.AreEqual(src.Velocity, dest.Velocity);
Assert.AreEqual(src.Weight, dest.Weight);
Assert.AreEqual(src.MapEntityIndex, dest.MapEntityIndex);
Assert.AreEqual(src.Center, dest.Center);
Assert.AreEqual(src.A, dest.A);
Assert.AreEqual(src.B, dest.B);
Assert.AreEqual(src.C, dest.C);
Assert.AreEqual(src.D, dest.D);
Assert.AreEqual(src.E, dest.E);
Assert.AreEqual(src.F, dest.F);
Assert.AreEqual(src.G, dest.G);
Assert.AreEqual(src.H, dest.H);
Assert.AreEqual(src.I, dest.I);
Assert.AreEqual(src.J, dest.J);
Assert.AreEqual(src.K, dest.K);
Assert.AreEqual(src.L, dest.L);
Assert.AreEqual(src.M, dest.M);
Assert.AreEqual(src.N, dest.N);
Assert.AreEqual(src.O, dest.O);
Assert.AreEqual(src.P, dest.P);
Assert.AreEqual(src.Q, dest.Q);
Assert.AreEqual(src.R, dest.R);
Assert.AreNotEqual(src.SkipA, dest.SkipA);
Assert.AreNotEqual(src.SkipB, dest.SkipB);
Assert.AreEqual(src.SkipC, dest.SkipC);
}