public static bool TryParse(string[] body, QualifiedModuleName qualifiedModuleName, out Member result) { var signature = body.FirstOrDefault(line => _keywords.Any(line.StartsWith)); if (signature == null) { result = null; return(false); } signature = signature.Replace("\r", string.Empty); body = body.Select(line => line.Replace("\r", string.Empty)).ToArray(); var withoutKeyword = signature.Substring((_keywords.First(keyword => signature.StartsWith(keyword))).Length); var name = withoutKeyword.Split(' ')[1] .Split('(')[0]; var type = GetMemberType(signature, withoutKeyword); var visibility = GetMemberVisibility(signature); var signatureLineIndex = body.ToList().IndexOf(signature); var attributes = MemberAttribute.GetAttributes(body.Take(signatureLineIndex) .Where(line => line.StartsWith("'@"))); result = new Member(type, qualifiedModuleName.QualifyMemberName(name), signature, body, attributes); return(true); }
public static bool HasAttribute(this CodeModule code, string name) { if (code.CountOfDeclarationLines == 0) { return(false); } var moduleAttributes = MemberAttribute.GetAttributes(code.Lines[1, code.CountOfDeclarationLines].Split('\n')); return(moduleAttributes.Any(attribute => attribute.Name == name)); }