You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

NavigationElement.cs 3.7 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. //////////////////////////////////////////////////////////////////////////////////////////////
  2. // DocNet is licensed under the MIT License (MIT)
  3. // Copyright(c) 2016 Frans Bouma
  4. // Get your copy at: https://github.com/FransBouma/DocNet
  5. //
  6. // Permission is hereby granted, free of charge, to any person obtaining a copy of
  7. // this software and associated documentation files (the "Software"), to deal in the
  8. // Software without restriction, including without limitation the rights to use, copy,
  9. // modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
  10. // and to permit persons to whom the Software is furnished to do so, subject to the
  11. // following conditions:
  12. //
  13. // The above copyright notice and this permission notice shall be included in all copies
  14. // or substantial portions of the Software.
  15. //
  16. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  17. // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  18. // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
  19. // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  20. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  21. // DEALINGS IN THE SOFTWARE.
  22. //////////////////////////////////////////////////////////////////////////////////////////////
  23. using System;
  24. using System.Collections.Generic;
  25. using System.Linq;
  26. using System.Text;
  27. using System.Threading.Tasks;
  28. namespace Docnet
  29. {
  30. public abstract class NavigationElement<T> : INavigationElement
  31. where T : class
  32. {
  33. /// <summary>
  34. /// Generates the output for this navigation element
  35. /// </summary>
  36. /// <param name="activeConfig">The active configuration to use for the output.</param>
  37. /// <param name="activePath">The active path navigated through the ToC to reach this element.</param>
  38. /// <returns>true if everything went well, false otherwise</returns>
  39. public abstract void GenerateOutput(Config activeConfig, NavigatedPath activePath);
  40. /// <summary>
  41. /// Generates the ToC fragment for this element, which can either be a simple line or a full expanded menu.
  42. /// </summary>
  43. /// <param name="navigatedPath">The navigated path to the current element, which doesn't necessarily have to be this element.</param>
  44. /// <param name="relativePathToRoot">The relative path back to the URL root, e.g. ../.., so it can be used for links to elements in this path.</param>
  45. /// <returns></returns>
  46. public abstract string GenerateToCFragment(NavigatedPath navigatedPath, string relativePathToRoot);
  47. /// <summary>
  48. /// Collects the search index entries. These are created from simple navigation elements found in this container, which aren't index element.
  49. /// </summary>
  50. /// <param name="collectedEntries">The collected entries.</param>
  51. /// <param name="activePath">The active path currently navigated.</param>
  52. public abstract void CollectSearchIndexEntries(List<SearchIndexEntry> collectedEntries, NavigatedPath activePath);
  53. #region Properties
  54. public abstract string TargetURL { get; }
  55. /// <summary>
  56. /// Gets / sets a value indicating whether this element is the __index element
  57. /// </summary>
  58. public abstract bool IsIndexElement { get; set; }
  59. public string Name { get; set; }
  60. /// <summary>
  61. /// Gets or sets the value of this element, which can either be a string or a NavigationLevel
  62. /// </summary>
  63. public T Value { get; set; }
  64. object INavigationElement.Value
  65. {
  66. get { return this.Value; }
  67. set { this.Value = value as T; }
  68. }
  69. public NavigationLevel ParentContainer { get; set; }
  70. #endregion
  71. }
  72. }

No Description

Contributors (1)