internal static MatchField Reflect(FieldInfo fieldInfo)
        {
            if (!fieldInfo.IsPublic)
            {
                return(null);
            }
            object[] attrs = fieldInfo.GetCustomAttributes(typeof(MatchAttribute), false);
            if (attrs.Length == 0)
            {
                return(null);
            }
            MatchAttribute attr  = (MatchAttribute)attrs[0];
            MatchField     field = new MatchField();

            field.regex      = new Regex(attr.Pattern, RegexOptions.Singleline | (attr.IgnoreCase ? RegexOptions.IgnoreCase | RegexOptions.CultureInvariant: 0));
            field.group      = attr.Group;
            field.capture    = attr.Capture;
            field.maxRepeats = attr.MaxRepeats;
            field.fieldInfo  = fieldInfo;
            Type fieldType = fieldInfo.FieldType;

            if (field.maxRepeats < 0) // unspecified
            {
                field.maxRepeats = fieldType.IsArray ? int.MaxValue : 1;
            }
            if (fieldType.IsArray)
            {
                fieldType = fieldType.GetElementType();
            }
            if (fieldType != typeof(string))
            {
                field.matchType = MatchType.Reflect(fieldType);
            }
            return(field);
        }
        internal static MatchType Reflect(Type type)
        {
            MatchType matchType = new MatchType();

            matchType.type = type;
            FieldInfo[] fieldInfos = type.GetFields();
            ArrayList   list       = new ArrayList();

            for (int i = 0; i < fieldInfos.Length; i++)
            {
                MatchField field = MatchField.Reflect(fieldInfos[i]);
                if (field != null)
                {
                    list.Add(field);
                }
            }
            matchType.fields = (MatchField[])list.ToArray(typeof(MatchField));
            return(matchType);
        }