当前位置: 首页>>代码示例>>C#>>正文


C# BitStream.GetBuffer方法代码示例

本文整理汇总了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);
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:73,代码来源:DynamicEntityTests.cs

示例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);
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:36,代码来源:DynamicEntityTests.cs

示例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);
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:78,代码来源:DynamicEntityTests.cs

示例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);
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:17,代码来源:DynamicEntityTests.cs

示例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);
            }
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:47,代码来源:DynamicEntityTests.cs

示例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);
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:10,代码来源:DynamicEntityTests.cs

示例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);
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:88,代码来源:DynamicEntityTests.cs


注:本文中的NetGore.IO.BitStream.GetBuffer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。