Example #1
0
        /// <summary>
        ///    Gets image file name (with extension) for appropriate <see cref="MinefieldCellState" />
        /// </summary>
        /// <param name="this">Minefield cell state</param>
        /// <returns>Image file name</returns>
        public static string GetImageFile(this MinefieldCellState @this)
        {
            if (!Enum.IsDefined(typeof(MinefieldCellState), @this))
            {
                throw new InvalidEnumArgumentException(nameof(@this), (int)@this, typeof(MinefieldCellState));
            }

            return(@this.GetType()
                   .GetField(@this.ToString())
                   .GetCustomAttributes <MineImageFileAttribute>()
                   .FirstOrDefault()
                   ?.ImageFile);
        }
Example #2
0
 /// <summary>
 ///    Ctor
 /// </summary>
 /// <param name="row">Row</param>
 /// <param name="column">Column</param>
 /// <param name="cellState">State</param>
 public MinefieldCell(int row, int column, MinefieldCellState cellState = MinefieldCellState.Closed)
 {
     Row    = row;
     Column = column;
     State  = cellState;
 }