Ejemplo n.º 1
0
        public void Should_Parse_Tanks_Path(string rawPath, string fullMatch, string aircraft, string type)
        {
            var parsed = DropTankIdentifier.TryParse(rawPath, out var ident);

            Assert.True(parsed);
            Assert.Equal(fullMatch, ident.RawValue);
            Assert.Equal(aircraft, ident.Aircraft);
            Assert.Equal(type, ident.Type);
        }
Ejemplo n.º 2
0
        public static bool TryParse(string value, out DropTankIdentifier ident)
        {
            // var rex = new System.Text.RegularExpressions.Regex(@"\/Weapons\/w_(\w+_\w+)");
            var rex   = new System.Text.RegularExpressions.Regex(@"(?<aircraft>[a-zA-Z0-9]{4,6}?)_dptk_(?<type>[A-Z]{1}|[A-Za-z]{4})(?:[^\w])(?!u[^a\W])");
            var match = rex.Match(value);

            if (match != null && match.MatchedGroups().Count >= 3)
            {
                ident = new DropTankIdentifier(match.Groups[0].Value, match.Groups["aircraft"].Value, match.Groups["type"].Value);
                return(true);
            }
            ident = null;
            return(false);
        }