コード例 #1
0
            /// <summary>
            /// Adds a part to the appropriate list for its type; returns the part.
            /// </summary>
            public Part Add(Part part)
            {
                switch (part)
                {
                case Part.MapPiece p: MapPieces.Add(p); break;

                case Part.Object p: Objects.Add(p); break;

                case Part.Enemy p: Enemies.Add(p); break;

                case Part.Player p: Players.Add(p); break;

                case Part.Collision p: Collisions.Add(p); break;

                case Part.Protoboss p: Protobosses.Add(p); break;

                case Part.Navmesh p: Navmeshes.Add(p); break;

                case Part.DummyObject p: DummyObjects.Add(p); break;

                case Part.DummyEnemy p: DummyEnemies.Add(p); break;

                case Part.ConnectCollision p: ConnectCollisions.Add(p); break;

                default:
                    throw new ArgumentException($"Unrecognized type {part.GetType()}.", nameof(part));
                }
                return(part);
            }
コード例 #2
0
            internal override Model ReadEntry(BinaryReaderEx br)
            {
                ModelType type = br.GetEnum32 <ModelType>(br.Position + 4);

                switch (type)
                {
                case ModelType.MapPiece:
                    return(MapPieces.EchoAdd(new Model.MapPiece(br)));

                case ModelType.Object:
                    return(Objects.EchoAdd(new Model.Object(br)));

                case ModelType.Enemy:
                    return(Enemies.EchoAdd(new Model.Enemy(br)));

                case ModelType.Player:
                    return(Players.EchoAdd(new Model.Player(br)));

                case ModelType.Collision:
                    return(Collisions.EchoAdd(new Model.Collision(br)));

                case ModelType.Navmesh:
                    return(Navmeshes.EchoAdd(new Model.Navmesh(br)));

                case ModelType.DummyObject:
                    return(DummyObjects.EchoAdd(new Model.DummyObject(br)));

                case ModelType.DummyEnemy:
                    return(DummyEnemies.EchoAdd(new Model.DummyEnemy(br)));

                default:
                    throw new NotImplementedException($"Unimplemented model type: {type}");
                }
            }
コード例 #3
0
            /// <summary>
            /// Adds a model to the appropriate list for its type; returns the model.
            /// </summary>
            public Model Add(Model model)
            {
                switch (model)
                {
                case Model.MapPiece m: MapPieces.Add(m); break;

                case Model.Object m: Objects.Add(m); break;

                case Model.Enemy m: Enemies.Add(m); break;

                case Model.Player m: Players.Add(m); break;

                case Model.Collision m: Collisions.Add(m); break;

                case Model.Navmesh m: Navmeshes.Add(m); break;

                case Model.DummyObject m: DummyObjects.Add(m); break;

                case Model.DummyEnemy m: DummyEnemies.Add(m); break;

                default:
                    throw new ArgumentException($"Unrecognized type {model.GetType()}.", nameof(model));
                }
                return(model);
            }
コード例 #4
0
            internal override Part ReadEntry(BinaryReaderEx br)
            {
                PartType type = br.GetEnum32 <PartType>(br.Position + 4);

                switch (type)
                {
                case PartType.MapPiece:
                    var mapPiece = new Part.MapPiece(br);
                    MapPieces.Add(mapPiece);
                    return(mapPiece);

                case PartType.Object:
                    var obj = new Part.Object(br);
                    Objects.Add(obj);
                    return(obj);

                case PartType.Enemy:
                    var enemy = new Part.Enemy(br);
                    Enemies.Add(enemy);
                    return(enemy);

                case PartType.Player:
                    var player = new Part.Player(br);
                    Players.Add(player);
                    return(player);

                case PartType.Collision:
                    var collision = new Part.Collision(br);
                    Collisions.Add(collision);
                    return(collision);

                case PartType.Navmesh:
                    var navmesh = new Part.Navmesh(br);
                    Navmeshes.Add(navmesh);
                    return(navmesh);

                case PartType.DummyObject:
                    var dummyObject = new Part.DummyObject(br);
                    DummyObjects.Add(dummyObject);
                    return(dummyObject);

                case PartType.DummyEnemy:
                    var dummyEnemy = new Part.DummyEnemy(br);
                    DummyEnemies.Add(dummyEnemy);
                    return(dummyEnemy);

                case PartType.ConnectCollision:
                    var connectCollision = new Part.ConnectCollision(br);
                    ConnectCollisions.Add(connectCollision);
                    return(connectCollision);

                default:
                    throw new NotImplementedException($"Unimplemented part type: {type}");
                }
            }
コード例 #5
0
            public void Add(IMsbPart item)
            {
                switch (item)
                {
                case Part.MapPiece m:
                    MapPieces.Add(m);
                    break;

                case Part.DummyObject m:
                    DummyObjects.Add(m);
                    break;

                case Part.Object m:
                    Objects.Add(m);
                    break;

                case Part.DummyEnemy m:
                    DummyEnemies.Add(m);
                    break;

                case Part.Enemy m:
                    Enemies.Add(m);
                    break;

                case Part.Player m:
                    Players.Add(m);
                    break;

                case Part.Collision m:
                    Collisions.Add(m);
                    break;

                case Part.Navmesh m:
                    Navmeshes.Add(m);
                    break;

                case Part.ConnectCollision m:
                    ConnectCollisions.Add(m);
                    break;

                default:
                    throw new ArgumentException(
                              message: "Item is not recognized",
                              paramName: nameof(item));
                }
            }
コード例 #6
0
        public IActionResult SortedSetType(SeedSortedSetTypeViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                for (int i = 1; i <= viewModel.NumberOfKeys; i++)
                {
                    var key   = $"{i}:{i+1}:seed_sorted_set";
                    var value = DummyObjects.GetListWithNValues(viewModel.NumberOfValuesInKey);
                    _redisRepositorySortedSet.Insert(key, value, _scoreCalculator.ScoreYear1970());
                }

                new SetTempDataMessage()
                .Display(TempData, "OK", "Seed has complete.");
            }

            return(View(viewModel));
        }
コード例 #7
0
        public IActionResult StringType(SeedStringTypeViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                for (int i = 1; i <= viewModel.NumberOfKeys; i++)
                {
                    var key   = $"{i}:{i+1}:seed_string";
                    var value = DummyObjects.GetOneValue();
                    _redisRepositoryString.Insert(key, value);
                }

                new SetTempDataMessage()
                .Display(TempData, "OK", "Seed has complete.");
            }

            return(View(viewModel));
        }
コード例 #8
0
        public void Delete_insert_a_new_record_then_delete_it_then_confirm_its_gone()
        {
            // Arrange
            string expected = null;
            var    key      = $"123:delete:{Guid.NewGuid()}";
            var    value    = DummyObjects.GetListWithNValues(10);

            redisRepositoryString.Insert(key, value);

            // Act
            var insertedValue = redisRepositoryString.Select(key);

            redisRepository.Delete(key);
            var actual = redisRepositoryString.Select(key);

            // Assert
            Assert.AreEqual(insertedValue, value);
            Assert.AreEqual(actual, expected);
        }
コード例 #9
0
            internal override Part ReadEntry(BinaryReaderEx br)
            {
                PartType type = br.GetEnum32 <PartType>(br.Position + 4);

                switch (type)
                {
                case PartType.MapPiece:
                    return(MapPieces.EchoAdd(new Part.MapPiece(br)));

                case PartType.Object:
                    return(Objects.EchoAdd(new Part.Object(br)));

                case PartType.Enemy:
                    return(Enemies.EchoAdd(new Part.Enemy(br)));

                case PartType.Player:
                    return(Players.EchoAdd(new Part.Player(br)));

                case PartType.Collision:
                    return(Collisions.EchoAdd(new Part.Collision(br)));

                case PartType.Protoboss:
                    return(Protobosses.EchoAdd(new Part.Protoboss(br)));

                case PartType.Navmesh:
                    return(Navmeshes.EchoAdd(new Part.Navmesh(br)));

                case PartType.DummyObject:
                    return(DummyObjects.EchoAdd(new Part.DummyObject(br)));

                case PartType.DummyEnemy:
                    return(DummyEnemies.EchoAdd(new Part.DummyEnemy(br)));

                case PartType.ConnectCollision:
                    return(ConnectCollisions.EchoAdd(new Part.ConnectCollision(br)));

                default:
                    throw new NotImplementedException($"Unimplemented part type: {type}");
                }
            }