Example #1
0
        private static Modifier ParseModifier(string exportString)
        {
            var nextModifier = AllModifierCombinations
                               .Cast <Modifier?>()
                               .FirstOrDefault(m => exportString.StartsWith(GetModifierStartToken(m.Value)));

            if (nextModifier == null)
            {
                throw new FormatException(
                          $"Couldn't parse '{GetShortenedString(exportString)}' to a keyboard modifier (e.g. {Modifier.Shift})");
            }

            return(nextModifier.Value);
        }
Example #2
0
        private static bool TryParseModifier(string exportString, out Modifier modifier)
        {
            var nextModifier = AllModifierCombinations
                               .Cast <Modifier?>()
                               .FirstOrDefault(m => exportString.StartsWith(GetModifierStartToken(m.Value)));

            if (nextModifier != null)
            {
                modifier = nextModifier.Value;
                return(true);
            }

            modifier = Modifier.None;
            return(false);
        }