public void PositionConstructorTest()
 {
     int x = 0;
     int y = 0;
     Position target = new Position(x, y);
     Assert.IsNotNull(target);
 }
        public Position getPosition(int x,int y)
        {
            //首先在缓存中查找对象
            foreach (var item in positions)
            {
                if (item.X==x && item.Y==y)
                {
                    //在缓存中命中对象后还原对象的外部属性
                    return item;
                }
            }
            //如果缓存未命中则新建对象并加入缓存
            Position position = new Position(x, y);
            positions.Add(position);

            return position;
        }
        public void add(Position position, Glyph glyph)
        {
            if (position.X < 0 || position.X > this.maxRows)
            {
                throw new ValidationException("Invalid Row");
            }

            if (position.Y < 0 || position.Y > this.MaxCols)
            {
                throw new ValidationException("Invalid Col");
            }

            //todo the Regex needs to be updated
            if (!new Regex("^[a-zA-Z,. $]").IsMatch(glyph.Alphabet))
            {
                throw new ValidationException("Invalid Alphabet");
            }

            context.Add(position, glyph);
        }
 public Glyph getGlyphBy(Position position)
 {
     return context[position];
 }