GameLocation.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using System;
  2. namespace OpenVIII
  3. {
  4. public sealed class GameLocation
  5. {
  6. private readonly static GameLocation s_current = GetCurrentLocation();
  7. public String DataPath { get; private set; }
  8. public GameLocation(String dataPath)
  9. {
  10. DataPath = dataPath;
  11. }
  12. public static GameLocation Current
  13. {
  14. get
  15. {
  16. return s_current;
  17. }
  18. }
  19. private static GameLocation GetCurrentLocation()
  20. {
  21. IGameLocationProvider provider = GetLocationProvider();
  22. return provider.GetGameLocation();
  23. }
  24. private static IGameLocationProvider GetLocationProvider()
  25. {
  26. switch (RuntimeEnvironment.Platform)
  27. {
  28. case RuntimePlatform.Windows:
  29. return new WindowsGameLocationProvider();
  30. case RuntimePlatform.Linux:
  31. return new LinuxGameLocationProvider();
  32. default:
  33. throw new NotSupportedException(RuntimeEnvironment.Platform.ToString());
  34. }
  35. }
  36. }
  37. }