Esempio n. 1
0
        /// <summary>
        /// returns the "movements" of the key, i.e. how each relevant wildcard has to be "rotated" to produce the next key.
        /// </summary>
        /// <returns></returns>
        public IKeyMovement[] getKeyMovements()
        {
            KeyPattern fullKeyPattern = new KeyPattern(pattern);

            fullKeyPattern.WildcardKey = pattern;

            int arraySize = 0;

            foreach (Wildcard wc in this.wildcardList)
            {
                if (wc.getLength() > 1)
                {
                    arraySize++;
                }
            }

            IKeyMovement[] result = new IKeyMovement[arraySize];

            int c = 0;

            for (int i = 0; i < wildcardList.Count; i++)
            {
                if (((Wildcard)this.wildcardList[i]).getLength() > 1)
                {
                    result[c] = getWildcardMovement((Wildcard)this.wildcardList[i], (Wildcard)fullKeyPattern.wildcardList[i]);
                    c++;
                }
            }

            return(result);
        }
Esempio n. 2
0
        private bool WildcardInRange(int i)
        {
            IKeyMovement mov = keyMovements[i];

            if (mov is LinearKeyMovement)
            {
                return(movementStatus[i] < (mov as LinearKeyMovement).UpperBound);
            }
            else if (mov is ListKeyMovement)
            {
                return(movementStatus[i] < (mov as ListKeyMovement).KeyList.Count);
            }

            return(false);
        }
Esempio n. 3
0
        private int CalcWildcard(int i)
        {
            IKeyMovement mov = keyMovements[i];

            if (mov is LinearKeyMovement)
            {
                return(movementStatus[i] * (mov as LinearKeyMovement).A + (mov as LinearKeyMovement).B);
            }
            else if (mov is ListKeyMovement)
            {
                return((mov as ListKeyMovement).KeyList[movementStatus[i]]);
            }

            throw new Exception("Movement not implemented!");
        }