DocLinks.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. // --------------------------------------------------------------------------------------------------------------------
  2. // <copyright file="DocLinks.cs" company="Exit Games GmbH">
  3. // Part of: Pun demos
  4. // </copyright>
  5. // <author>developer@exitgames.com</author>
  6. // --------------------------------------------------------------------------------------------------------------------
  7. using System.Collections.Generic;
  8. namespace Photon.Pun.Demo.Shared
  9. {
  10. /// <summary>
  11. /// Document links.
  12. /// </summary>
  13. public static class DocLinks {
  14. /// <summary>
  15. /// Document types
  16. /// </summary>
  17. public enum DocTypes {Doc,Api};
  18. /// <summary>
  19. /// The various supported languages
  20. /// </summary>
  21. public enum Products {OnPremise,Realtime,Pun,Chat,Voice,Bolt,Quantum};
  22. /// <summary>
  23. /// The various version of the documentation that exists. Current will be either V1 or V2 or possibly a beta version or branched version.
  24. /// </summary>
  25. public enum Versions {Current,V1,V2};
  26. /// <summary>
  27. /// The various supported languages
  28. /// </summary>
  29. public enum Languages {English,Japanese,Korean,Chinese};
  30. /// <summary>
  31. /// The version to generate links for
  32. /// </summary>
  33. public static Versions Version = Versions.Current;
  34. /// <summary>
  35. /// The language to generate links with
  36. /// </summary>
  37. public static Languages Language = Languages.English;
  38. /// <summary>
  39. /// The product to generate links for
  40. /// </summary>
  41. public static Products Product = Products.Pun;
  42. /// <summary>
  43. /// The API URL format.
  44. /// 0 is the Language
  45. /// 1 is the Product
  46. /// 2 is the Version
  47. /// 3 is the custom part passed to generate the link with
  48. /// </summary>
  49. public static string ApiUrlRoot = "https://doc-api.photonengine.com/{0}/{1}/{2}/{3}";
  50. /// <summary>
  51. /// The Doc URL format.
  52. /// 0 is the Language
  53. /// 1 is the Product
  54. /// 2 is the Version
  55. /// 3 is the custom part passed to generate the link with
  56. /// </summary>
  57. public static string DocUrlFormat = "https://doc.photonengine.com/{0}/{1}/{2}/{3}";
  58. /// <summary>
  59. /// LookUp dictionnary for doc versions to avoid parsing this every link request
  60. /// </summary>
  61. static Dictionary<Products,string> ProductsFolders = new Dictionary<Products, string>
  62. {
  63. {Products.Bolt, "bolt"},
  64. {Products.Chat, "chat"},
  65. {Products.OnPremise, "onpremise"},
  66. {Products.Pun, "pun"},
  67. {Products.Quantum, "quantum"},
  68. {Products.Realtime, "realtime"},
  69. {Products.Voice, "voice"}
  70. };
  71. /// <summary>
  72. /// LookUp dictionnary for api languages to avoid parsing this every link request
  73. /// </summary>
  74. static Dictionary<Languages,string> ApiLanguagesFolder = new Dictionary<Languages, string>
  75. {
  76. {Languages.English, "en"},
  77. {Languages.Japanese, "ja-jp"},
  78. {Languages.Korean, "ko-kr"},
  79. {Languages.Chinese, "zh-tw"}
  80. };
  81. /// <summary>
  82. /// LookUp dictionnary for doc languages to avoid parsing this every link request
  83. /// </summary>
  84. static Dictionary<Languages,string> DocLanguagesFolder = new Dictionary<Languages, string>
  85. {
  86. {Languages.English, "en-us"},
  87. {Languages.Japanese, "ja-jp"},
  88. {Languages.Korean, "ko-kr"},
  89. {Languages.Chinese, "en"} // fallback to english
  90. };
  91. /// <summary>
  92. /// LookUp dictionnary for doc versions to avoid parsing this every link request
  93. /// </summary>
  94. static Dictionary<Versions,string> VersionsFolder = new Dictionary<Versions, string>
  95. {
  96. {Versions.Current, "current"},
  97. {Versions.V1, "v1"},
  98. {Versions.V2, "v2"}
  99. };
  100. /// <summary>
  101. /// Gets a documentation link given a reference
  102. /// </summary>
  103. /// <returns>The link.</returns>
  104. /// <param name="type">Type.</param>
  105. /// <param name="reference">Reference.</param>
  106. public static string GetLink(DocTypes type,string reference)
  107. {
  108. if (type == DocTypes.Api) {
  109. return GetApiLink (reference);
  110. }
  111. if (type == DocTypes.Doc) {
  112. return GetDocLink (reference);
  113. }
  114. return "https://doc.photonengine.com";
  115. }
  116. /// <summary>
  117. /// Gets the API link given a reference
  118. /// </summary>
  119. /// <returns>The API link.</returns>
  120. /// <param name="reference">Reference.</param>
  121. public static string GetApiLink(string reference)
  122. {
  123. return string.Format(ApiUrlRoot, ApiLanguagesFolder[Language],ProductsFolders[Product], VersionsFolder[Version], reference);
  124. }
  125. /// <summary>
  126. /// Gets the Doc link given a reference
  127. /// </summary>
  128. /// <returns>The document link.</returns>
  129. /// <param name="reference">Reference.</param>
  130. public static string GetDocLink(string reference)
  131. {
  132. return string.Format(DocUrlFormat, DocLanguagesFolder[Language],ProductsFolders[Product], VersionsFolder[Version], reference);
  133. }
  134. }
  135. }