public DocumentationGenerator(
            string assemblyFilePath,
            string documentationFilePath,
            string homePageName,
            FileNameMode fileNameMode,
            NestedTypeVisibility nestedTypeVisibility,
            bool wikiLinks,
            string linksFiles)
        {
            _decompiler = new CSharpDecompiler(assemblyFilePath, new DecompilerSettings {
                ThrowOnAssemblyResolveErrors = false
            });
            _documentationProvider = new XmlDocumentationProvider(documentationFilePath);
            _resolver             = new CSharpResolver(_decompiler.TypeSystem);
            _fileNameMode         = fileNameMode;
            _nestedTypeVisibility = nestedTypeVisibility;
            _wikiLinks            = wikiLinks;

            _docItems = new Dictionary <string, DocItem>();
            foreach (DocItem item in GetDocItems(homePageName))
            {
                _docItems.Add(item.Id, item);
            }

            _links = new Dictionary <string, string>();
            foreach ((string id, string link) in GetExternalLinks(linksFiles))
            {
                _links[id] = link;
            }
        }
        public DocumentationWriter(
            FileNameMode fileNameMode,
            NestedTypeVisibility nestedTypeVisibility,
            IReadOnlyDictionary <string, DocItem> items,
            IReadOnlyDictionary <string, string> links,
            string folderPath,
            DocItem item)
        {
            if (!_builders.TryDequeue(out _builder))
            {
                _builder = new StringBuilder(1024);
            }

            _fileNameMode        = fileNameMode;
            NestedTypeVisibility = nestedTypeVisibility;
            _items    = items;
            _links    = links;
            _mainItem = item;
            _filePath = Path.Combine(folderPath, $"{item.GetLink(_fileNameMode)}.md");
        }
示例#3
0
文件: Files.cs 项目: PavelPZ/NetNew
    /// <summary> Vrátí položku v lineárním výsledku. Zpùsobuje internì nastavení Active = true. </summary>
    /// <param name="mode">Urèuje formu/formát vráceného jména souboru.</param>
    /// <param name="index">Index položky.</param>
    /// <returns>Položka v lineárním výsledku.</returns>
    public string FileName(FileNameMode mode, int index) {
      Active = true;

      string entry = _ResultList[index];
      switch (mode) {
        case FileNameMode.FullPath:
          return _BasicPath + entry;

        case FileNameMode.FullName:
          return Path.ChangeExtension(_BasicPath + entry, null);

        case FileNameMode.RelPath:
          return entry;

        case FileNameMode.RelName:
          return Path.ChangeExtension(entry, null);

        case FileNameMode.Path:
          return Path.GetFileName(entry);

        case FileNameMode.Name:
          if (entry.EndsWith(@"\"))
            return Path.GetFileName(entry.Substring(0, entry.Length - 1));
          else
            return Path.GetFileNameWithoutExtension(entry);

        case FileNameMode.Extension:
          return Path.GetExtension(entry);

        default:
          throw new Exception(); // Nemìlo by nastat
      }
    }
示例#4
0
文件: Files.cs 项目: PavelPZ/NetNew
 public IEnumerable<string> FileName(FileNameMode mode) {
   for (int i = 0; i < Count; i++) yield return FileName(mode, i);
 }
示例#5
0
 private string GetFileName(FileNameMode Mode)
 {
     if ((DropDownListRevisions.SelectedIndex == 0) || (Mode == FileNameMode.Save))
         return (sMainRootPath + "/content." + DropDownListPages.SelectedItem.Text + "." + DropDownListSections.SelectedItem.Text + ".txt");
     else
         return (sMainRootPath + "/revision." + DropDownListPages.SelectedItem.Text + "." + DropDownListSections.SelectedItem.Text + "." + DropDownListRevisions.SelectedItem.Text + ".txt");
 }
示例#6
0
        private static void Main(string[] args)
        {
            FileInfo             assembly               = null;
            FileInfo             xml                    = null;
            DirectoryInfo        output                 = null;
            string               home                   = null;
            FileNameMode         fileNameMode           = FileNameMode.FullName;
            NestedTypeVisibility nestedTypeVisibility   = NestedTypeVisibility.Namespace;
            string               invalidCharReplacement = null;
            string               baseLink               = null;
            FileInfo             linksFile              = null;
            string               externalLinks          = null;
            bool wikiLinks = false;

            try
            {
                foreach (string arg in args)
                {
                    if (TryGetArgValue(arg, nameof(assembly), out string argValue))
                    {
                        assembly = new FileInfo(argValue);
                    }
                    else if (TryGetArgValue(arg, nameof(xml), out argValue))
                    {
                        xml = new FileInfo(argValue);
                    }
                    else if (TryGetArgValue(arg, nameof(output), out argValue) && !string.IsNullOrWhiteSpace(argValue))
                    {
                        output = new DirectoryInfo(argValue);
                    }
                    else if (TryGetArgValue(arg, nameof(home), out argValue) && !string.IsNullOrWhiteSpace(argValue))
                    {
                        home = argValue;
                    }
                    else if (TryGetArgValue(arg, nameof(fileNameMode), out argValue))
                    {
                        fileNameMode = (FileNameMode)Enum.Parse(typeof(FileNameMode), argValue);
                    }
                    else if (TryGetArgValue(arg, nameof(nestedTypeVisibility), out argValue))
                    {
                        nestedTypeVisibility = (NestedTypeVisibility)Enum.Parse(typeof(NestedTypeVisibility), argValue);
                    }
                    else if (TryGetArgValue(arg, nameof(invalidCharReplacement), out argValue))
                    {
                        invalidCharReplacement = argValue;
                    }
                    else if (TryGetArgValue(arg, nameof(baseLink), out argValue) && !string.IsNullOrWhiteSpace(argValue))
                    {
                        baseLink = argValue;
                    }
                    else if (TryGetArgValue(arg, nameof(linksFile), out argValue) && !string.IsNullOrWhiteSpace(argValue))
                    {
                        linksFile = new FileInfo(argValue);
                    }
                    else if (TryGetArgValue(arg, nameof(externalLinks), out argValue) && !string.IsNullOrWhiteSpace(argValue))
                    {
                        externalLinks = argValue;
                    }
                    else if (TryGetArgValue(arg, nameof(wikiLinks), out argValue) && !string.IsNullOrWhiteSpace(argValue))
                    {
                        wikiLinks = bool.Parse(argValue);
                    }
                }
            }
            catch
            {
                PrintHelp();
                throw;
            }

            if (assembly is null || xml is null)
            {
                PrintHelp();
                return;
            }
 public virtual string GetLink(FileNameMode fileNameMode) => (fileNameMode switch
示例#8
0
 public override string GetLink(FileNameMode fileNameMode) => FullName.Clean();
示例#9
0
        public static bool Equals(IFileContext context, FileInfo file, string otherFileName, string otherFileExtension, FileNameMode comparisonMode)
        {
            if (!string.IsNullOrWhiteSpace(otherFileExtension))
            {
                if (!string.Equals(file.Extension, "." + otherFileExtension))
                {
                    return(false);
                }
            }

            if (!string.IsNullOrWhiteSpace(otherFileName))
            {
                switch (comparisonMode)
                {
                case FileNameMode.Default:
                {
                    if (!string.Equals(file.Name, otherFileName))
                    {
                        return(false);
                    }
                } break;

                case FileNameMode.NonLiteral:
                {
                    if (file.Name.IndexOf(otherFileName, System.StringComparison.OrdinalIgnoreCase) == -1)
                    {
                        return(false);
                    }
                } break;

                case FileNameMode.NonLiteralIncludePath:
                {
                    if (context.GetRelativePath(file.FullName).IndexOf(otherFileName, System.StringComparison.OrdinalIgnoreCase) == -1)
                    {
                        return(false);
                    }
                } break;
                }
            }

            return(true);
        }
示例#10
0
        bool IFileCollector.Replace(IFileContext context, string file, FileInfo replacement, FileNameMode comparisonMode)
        {
            bool found = false;

            foreach (var item in _files)
            {
                if (FileReference.Equals(context, item.Value[0], file, string.Empty, comparisonMode))
                {
                    item.Value[1] = replacement;
                    found         = true;
                }
            }

            return(found);
        }