예제 #1
0
        /// <summary>
        /// Creates a new SequenceItem from an input file token.
        /// </summary>
        /// <param name="token">The token, containing a positionrecord's name and some modifiers.</param>
        /// <returns>A SequenceItem created from this token.</returns>
        public static SequenceItem FromToken(string token)
        {
            // List of modifiers that specify details about how the item can be matched.
            List <char> modifiers = new List <char>();

            // Strip the end of the token from its modifiers, and
            // store those modifiers in the list.
            while (isModifier(token[token.Length - 1]))
            {
                modifiers.Add(token[token.Length - 1]);
                token = token.Substring(0, token.Length - 1);
            }
            // If the name still contains any characters that are not alphanumeric,
            // throw an exception.
            if (!isAlphanumeric(token))
            {
                throw new MalformedException(string.Format("Name must be alphanumeric, and all modifiers should appear at the end of the name. This token is invalid: {0}", token));
            }
            SequenceItem rv = new SequenceItem(token);

            rv.Position = PositionParser.GetByName(token);
            rv.parseModifiers(modifiers);
            return(rv);
        }
예제 #2
0
 /// <summary>
 /// Appends a positionrecord to the sequence.
 /// </summary>
 /// <param name="data">The record that should be added.</param>
 public void Add(SequenceItem data)
 {
     sequence.Add(data);
     // Hook into the position's Changed event.
     // data.PositionChanged += this.HandChanged;
 }