Regions.cs 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace VINCheckLibrary
  7. {
  8. public class Regions
  9. {
  10. public string Region { get; private set; }
  11. public string Country { get; private set; }
  12. public string Key { get; private set; }
  13. private static Dictionary<char, (string, Dictionary<string, string>)> Codes = new Dictionary<char, (string, Dictionary<string, string>)>
  14. {
  15. { 'A', ("Africa", new Dictionary<string, string> {
  16. { "ABCDEFGH", "South Africa" },
  17. { "JKLMN", "Ivory Coast" }
  18. })
  19. },
  20. { 'B', ("Africa", new Dictionary<string, string> {
  21. { "ABCDE", "Angola" },
  22. { "FGHJK", "Kenya" },
  23. { "LMNPR", "Tanzania" }
  24. })
  25. },
  26. { 'C', ("Africa", new Dictionary<string, string> {
  27. { "ABCDE", "Benin" },
  28. { "FGHJK", "Madagascar" },
  29. { "LMNPR", "Tunisia" }
  30. })
  31. },
  32. { 'D', ("Africa", new Dictionary<string, string> {
  33. { "ABCDE", "Egypt" },
  34. { "FGHJK", "Morocco" },
  35. { "LMNPR", "Zambia" }
  36. })
  37. },
  38. { 'E', ("Africa", new Dictionary<string, string> {
  39. { "ABCDE", "Ethiopia" },
  40. { "FGHJK", "Mozambique" }
  41. })
  42. },
  43. { 'F', ("Africa", new Dictionary<string, string> {
  44. { "ABCDE", "Ghana" },
  45. { "FGHJK", "Nigeria" }
  46. })
  47. },
  48. //~//
  49. { 'J', ("Asia", new Dictionary<string, string> {
  50. { "ABCDEFGHJKLMNPRST", "Japan" }
  51. })
  52. },
  53. { 'K', ("Asia", new Dictionary<string, string> {
  54. { "ABCDE", "Sri Lanka" },
  55. { "FGHJK", "Israel" },
  56. { "LMNPR", "South Korea" },
  57. { "STUVWXYZ1234567890", "Kazakhstan" }
  58. })
  59. },
  60. { 'L', ("Asia", new Dictionary<string, string> {
  61. { "ABCDEFGHJKLMNPRSTUVWXYZ1234567890", "China" }
  62. })
  63. },
  64. { 'M', ("Asia", new Dictionary<string, string> {
  65. { "ABCDE", "India" },
  66. { "FGHJK", "Indonesia" },
  67. { "LMNPR", "Thailand" }
  68. })
  69. },
  70. { 'N', ("Asia", new Dictionary<string, string> {
  71. { "FGHJK", "Pakistan" },
  72. { "LMNPR", "Turkey" }
  73. })
  74. },
  75. { 'P', ("Asia", new Dictionary<string, string> {
  76. { "ABCDE", "Philippines" },
  77. { "FGHJK", "Singapore" },
  78. { "LMNPR", "Malaysia" }
  79. })
  80. },
  81. { 'R', ("Asia", new Dictionary<string, string> {
  82. { "ABCDE", "UAE" },
  83. { "FGHJK", "Taiwan" },
  84. { "LMNPR", "Vietnam" },
  85. { "STUVWXYZ1234567890", "Saudi Arabia" }
  86. })
  87. },
  88. //~//
  89. { 'S', ("Europe", new Dictionary<string, string> {
  90. { "ABCDEFGHJKLM", "Great Britain" },
  91. { "NPRST", "Germany" },
  92. { "UVWXYZ", "Poland" },
  93. { "1234", "Latvia" }
  94. })
  95. },
  96. { 'T', ("Europe", new Dictionary<string, string> {
  97. { "ABCDEFGH", "Switzerland" },
  98. { "JKLMNP", "Czech" },
  99. { "RSTUV", "Hungary" },
  100. { "WXYZ1", "Portugal" }
  101. })
  102. },
  103. { 'U', ("Europe", new Dictionary<string, string> {
  104. { "HJKLM", "Denmark" },
  105. { "NPRST", "Ireland" },
  106. { "UVWXYZ", "Romania" },
  107. { "567", "Slovakia" }
  108. })
  109. },
  110. { 'V', ("Europe", new Dictionary<string, string> {
  111. { "ABCDE", "Austria" },
  112. { "FGHJKLMNPR", "France" },
  113. { "STUVW", "Spain" },
  114. { "XYZ12", "Serbia" },
  115. { "345", "Croatia" },
  116. { "67890", "Estonia" }
  117. })
  118. },
  119. { 'W', ("Europe", new Dictionary<string, string> {
  120. { "ABCDEFGHJKLMNPRSTUVWXYZ1234567890", "Germany" }
  121. })
  122. },
  123. { 'X', ("Europe", new Dictionary<string, string> {
  124. { "ABCDE", "Bulgaria" },
  125. { "FGHJK", "Greece" },
  126. { "LMNPR", "Netherlands" },
  127. { "STUVW", "USSR/CIS" },
  128. { "XYZ12", "Luxembourg" },
  129. { "34567890", "Russia" }
  130. })
  131. },
  132. { 'Y', ("Europe", new Dictionary<string, string> {
  133. { "ABCDE", "Belgium" },
  134. { "FGHJK", "Finland" },
  135. { "LMNPR", "Malta" },
  136. { "STUVW", "Sweden" },
  137. { "XYZ12", "Norway" },
  138. { "345", "Belarus" },
  139. { "67890", "Ukraine" }
  140. })
  141. },
  142. { 'Z', ("Europe", new Dictionary<string, string> {
  143. { "ABCDEFGHJKLMNPR", "Italy" },
  144. { "XYZ12", "Slovenia" },
  145. { "345", "Lithuania" },
  146. { "67890", "Russia" }
  147. })
  148. },
  149. //~//
  150. { '1', ("North America", new Dictionary<string, string> {
  151. { "ABCDEFGHJKLMNPRSTUVWXYZ1234567890", "USA" }
  152. })
  153. },
  154. { '2', ("North America", new Dictionary<string, string> {
  155. { "ABCDEFGHJKLMNPRSTUVWXYZ1234567890", "Canada" }
  156. })
  157. },
  158. { '3', ("North America", new Dictionary<string, string> {
  159. { "ABCDEFGHJKLMNPRSTUVW", "Mexico" },
  160. { "XYZ1234567", "Costa Rica" },
  161. { "890", "Cayman islands" }
  162. })
  163. },
  164. { '4', ("North America", new Dictionary<string, string> {
  165. { "ABCDEFGHJKLMNPRSTUVWXYZ1234567890", "USA" }
  166. })
  167. },
  168. { '5', ("North America", new Dictionary<string, string> {
  169. { "ABCDEFGHJKLMNPRSTUVWXYZ1234567890", "USA" }
  170. })
  171. },
  172. //~//
  173. { '6', ("Ocenia", new Dictionary<string, string> {
  174. { "ABCDEFGHJKLMNPRSTUVW", "Australia" }
  175. })
  176. },
  177. { '7', ("Ocenia", new Dictionary<string, string> {
  178. { "ABCDE", "New Zealand" }
  179. })
  180. },
  181. //~//
  182. { '8', ("South America", new Dictionary<string, string> {
  183. { "ABCDE", "Argentina" },
  184. { "FGHJK", "Chile" },
  185. { "LMNPR", "Ecuador" },
  186. { "STUVW", "Peru" },
  187. { "XYZ12", "Venezuela" },
  188. })
  189. },
  190. { '9', ("South America", new Dictionary<string, string> {
  191. { "ABCDE", "Brazil" },
  192. { "FGHJK", "Colombia" },
  193. { "LMNPR", "Paraguay" },
  194. { "STUVW", "Uruguay" },
  195. { "XYZ12", "Trinidad and Tobago" },
  196. { "3456789", "Brazil" }
  197. })
  198. },
  199. };
  200. public Regions(string code)
  201. {
  202. if (Codes.TryGetValue(code[0], out var value))
  203. {
  204. Region = value.Item1;
  205. foreach (var pair in value.Item2)
  206. {
  207. if (pair.Key.Contains(code[1]))
  208. {
  209. Country = pair.Value;
  210. break;
  211. }
  212. }
  213. }
  214. }
  215. }
  216. }