Code: Select all
   public interface IPieceSort
    {
        int Value { get; }
    }
Code: Select all
       public enum Sort { whitePawn, whiteKnight, whiteBishop, whiteRook,  whiteQueen, whiteKing, blackPawn, blackKnight, blackBishop, blackRook, blackQueen, blackKing, none }
Now I need an extra class to make it work.
Code: Select all
 class PredefinedPieceSortValues
    {
        public IPieceSort[] pieceSortValues;
        private static object syncRoot = new Object();
        private static PredefinedPieceSortValues instance;
        public static PredefinedPieceSortValues PieceSortInstance
        {
            get
            {
                if (instance == null)
                {
                    lock (syncRoot)
                    {
                        if (instance == null)
                            instance = new PredefinedPieceSortValues();
                    }
                }
                return instance;
            }
        }
        private PredefinedPieceSortValues()
        {
            const int NUMBER_OF_SORT_VALUES = (int)none;
            pieceSortValues = new ChessPieceSort[NUMBER_OF_SORT_VALUES];
            for (var i = whitePawn; i <= blackKing; i++)
            {
                pieceSortValues[(int)i] = new ChessPieceSort(i);
            }
        }
        public IPieceSort PieceSort(ChessPiece.Sort pieceSort)
        {
            return pieceSortValues[(int)pieceSort];
        }
 }
Get the impression making it overcomplicated. But don't see a better solution yet.