コード例 #1
0
        public static ILookup <string, XmlDocumentComment> GetCommentsLookup(Assembly assembly)
        {
            var xmlFile  = $"{Path.GetDirectoryName(assembly.Location)}\\{Path.GetFileNameWithoutExtension(assembly.Location)}.xml";
            var comments = !File.Exists(xmlFile)
                ? Array.Empty <XmlDocumentComment>()
                : VSDocParser.ParseXmlComment(XDocument.Parse(File.ReadAllText(xmlFile)));

            return(comments.ToLookup(x => x.ClassName));
        }
コード例 #2
0
        public static MarkdownableType[] Load(string dllPath, string namespaceMatch)
        {
            string xmlPath = Path.Combine(
                Directory.GetParent(dllPath).FullName, Path.GetFileNameWithoutExtension(dllPath) + ".xml");

            XmlDocumentComment[] comments = new XmlDocumentComment[0];
            if (File.Exists(xmlPath))
            {
                comments = VSDocParser.ParseXmlComment(XDocument.Parse(File.ReadAllText(xmlPath)), namespaceMatch);
            }
            ILookup <string, XmlDocumentComment> commentsLookup = comments.ToLookup(x => x.ClassName);

            Regex namespaceRegex =
                !string.IsNullOrEmpty(namespaceMatch) ? new Regex(namespaceMatch) : null;

            return(new[] { Assembly.LoadFrom(dllPath) }
                   .SelectMany(
                       x =>
            {
                try
                {
                    return x.GetTypes();
                }
                catch (ReflectionTypeLoadException ex)
                {
                    return ex.Types.Where(t => t != null);
                }
                catch
                {
                    return Type.EmptyTypes;
                }
            })
                   .Where(x => x != null)
                   .Where(
                       x => x.IsPublic && !typeof(Delegate).IsAssignableFrom(x) &&
                       !x.GetCustomAttributes <ObsoleteAttribute>().Any())
                   .Where(x => IsRequiredNamespace(x, namespaceRegex))
                   .Select(x => new MarkdownableType(x, commentsLookup))
                   .ToArray());
        }