示例#1
0
        private void LoadLibraryTypes()
        {
            Regex fileRegex = (!string.IsNullOrEmpty(_fileRegexPattern))
                    ? new Regex(_fileRegexPattern)
                    : null;

            //Finds all dll files with current pattern
            Func <string, bool> isFileToProcess = (s) => {
                if (!s.EndsWith(".dll"))
                {
                    return(false);
                }

                if (fileRegex != null)
                {
                    var fileName = s.Substring(s.LastIndexOf("\\") + 1);
                    if (!fileRegex.IsMatch(fileName))
                    {
                        return(false);
                    }
                }

                return(true);
            };

            var assemblyFiles = Directory.GetFiles(_srcPath).Where(isFileToProcess).ToList();

            foreach (var assemblyFilePath in assemblyFiles)
            {
                _logger.LogInformation($"Loading assembly {assemblyFilePath}...");
                _types.AddRange(MarkdownCSharpGenerator.Load(assemblyFilePath, _nameSpaceRegexPattern, _logger));
            }
        }
示例#2
0
        private void LoadAssemblies()
        {
            Regex fileRegex = (!string.IsNullOrEmpty(_fileRegexPattern))
                    ? new Regex(_fileRegexPattern)
                    : null;

            //Finds all dll files with current pattern
            Func <string, bool> isFileToProcess = (s) =>
            {
                if (!s.EndsWith(".dll"))
                {
                    return(false);
                }

                if (fileRegex != null)
                {
                    var fileName = s.Substring(s.LastIndexOf("\\") + 1);
                    if (!fileRegex.IsMatch(fileName))
                    {
                        return(false);
                    }
                }

                return(true);
            };

            var library = new CSharpLibrary();

            library.RootPath = _aistantSettings?.Section?.Uri ?? "";

            var assemblyFiles = Directory.GetFiles(_srcPath).Where(isFileToProcess).ToList();

            foreach (var assemblyFilePath in assemblyFiles)
            {
                _logger.LogInformation($"Loading assembly {assemblyFilePath}...");
                _types.AddRange(MarkdownCSharpGenerator.LoadFromAssembly(library, assemblyFilePath, _nameSpaceRegexPattern, _logger));
            }
            foreach (var type in _types)
            {
                library.Types.TryAdd(type.ClrType.FullName, type);
            }
        }
示例#3
0
        private void LoadPackages()
        {
            Regex fileRegex = (!string.IsNullOrEmpty(_fileRegexPattern))
                  ? new Regex(_fileRegexPattern)
                  : null;

            var library = new CSharpLibrary();

            library.RootPath = _aistantSettings?.Section?.Uri ?? "";
            var packagesFiles = Directory.GetFiles(_packagesPath, "*.nupkg");

            foreach (var packageFilePath in packagesFiles)
            {
                _logger.LogInformation($"Loading package {packageFilePath}...");
                var package = NugetPackage.Load(packageFilePath, fileRegex);
                library.Packages.Add(package);
                _types.AddRange(MarkdownCSharpGenerator.LoadFromPackage(library, package, _nameSpaceRegexPattern, _logger));
            }
            foreach (var type in _types)
            {
                library.Types.TryAdd(type.ClrType.FullName, type);
            }
        }