예제 #1
0
        public override void UpdateState(Maze clone, ExtractedParameters state)
        {
            if (state.HasValue(nameof(Tiles.Tiles)))
            {
                var tiles        = state.ToString(nameof(Tiles.Tiles));
                var tilesChanged = tiles.ToTiles();

                foreach (var tileChange in tilesChanged)
                {
                    clone._tiles[tileChange.Coordinates] = tileChange.Name;
                }
            }

            base.UpdateState(clone, state);
        }
        public static T ToValue <T>(this ExtractedParameters parameters, string name) where T : struct
        {
            var value = parameters.ToString(name);

            switch (typeof(T).Name)
            {
            case "Int32": return((T)Convert.ChangeType(int.Parse(value), typeof(T)));

            case "Double": return((T)Convert.ChangeType(double.Parse(value), typeof(T)));

            case "Compass8Points": return((T)Convert.ChangeType(value.ToEnum <T>(), typeof(T)));

            case "Coordinate": return((T)Convert.ChangeType(value.ToCoordinates(), typeof(T)));
            }

            throw new ArgumentException($"Unable to convert [{name}:{value}] to type [{typeof(T).Name}]");
        }
        public static IDispatchee GetDispatchee(this ExtractedParameters parameters, string name, DispatchRegistry registry)
        {
            var value = parameters.ToString(name);

            return(registry.GetDispatchee(value));
        }