예제 #1
0
        public static void GetMatchValues(MatchCollection mc, RegexOutput output)
        {
            output.MatchCollection.Add(mc);
            var matchGroups = SelectMatchGroups(mc, output.GroupNames);

            output.Groups.AddRange(matchGroups);
            NamedGroupValues.Add(output.AllMatchedNamedGroupValues, output.GroupNames, matchGroups);
        }
예제 #2
0
        public static void GetMatchValues <T>(MatchCollection mc, RegexOutput <T> output) where T : new()
        {
            var newEntry = new T();

            output.MatchCollection.Add(mc);
            int id          = output.UserProvidedModel.Count() + 1;
            var input       = mc.GetInputValue();
            var matchGroups = SelectMatchGroups(mc, output.GroupNames);

            output.Groups.AddRange(matchGroups);
            NamedGroupValues.Add(output.AllMatchedNamedGroupValues, id, output.GroupNames, matchGroups);
            foreach (Group mg in matchGroups)
            {
                newEntry.GetType().GetProperty(mg.Name)?.SetValue(newEntry, mg.Value);
            }
            newEntry.GetType().GetProperty("Id")?.SetValue(newEntry, id);
            newEntry.GetType().GetProperty("InputRecord")?.SetValue(newEntry, input);
            output.UserProvidedModel.Add(newEntry);
        }