/// <summary> /// Try to parse enum from file /// </summary> /// <param name="file">Text lines of the file</param> /// <param name="index">Index in the file</param> /// <param name="namespace">Namespace of the class</param> private CodeElementModel ParseEnum(string[] file, int index, string @namespace) { EnumModel model = null; // Try to match current line as class definition var match = _enumRegex.Match(file[index]); if (!match.Success) { return(model); } // Create class model var typeMatch = match.Groups["type"]; model = new EnumModel(match.Groups["enumName"].Value) { BaseType = typeMatch.Success ? DetermineType(typeMatch.Value) : ModelValueType.Int32, AccessModifier = ParseAccessModifier(match.Groups["accessModifier"].Value) }; // Add attributes by moving up the lines ParseAttributes(file, index, model); return(model); }
/// <summary> /// Parse enum member and add to the root model /// </summary> /// <param name="file">All text lines of the file</param> /// <param name="index">Current index in the file</param> /// <param name="model">Enum model</param> private void ParseMember(string[] file, int index, EnumModel model) { // Try parsing property var match = _memberRegex.Match(file[index]); if (!match.Success) { return; } // Create property model var valueMatch = match.Groups["value"]; var member = new EnumMember(match.Groups["name"].Value) { Value = valueMatch.Success ? int.Parse(valueMatch.Value) : model.Members.Count + 1 }; // Add attributes by moving up the lines ParseAttributes(file, index, member); model.Members.Add(member); }