Platform.cs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. using System.Globalization;
  5. namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities
  6. {
  7. internal static class Platform
  8. {
  9. private static readonly CompareInfo InvariantCompareInfo = CultureInfo.InvariantCulture.CompareInfo;
  10. internal static bool EqualsIgnoreCase(string a, string b)
  11. {
  12. return string.Equals(a, b, StringComparison.OrdinalIgnoreCase);
  13. }
  14. internal static string GetEnvironmentVariable(string variable)
  15. {
  16. try
  17. {
  18. return Environment.GetEnvironmentVariable(variable);
  19. }
  20. catch (System.Security.SecurityException)
  21. {
  22. // We don't have the required permission to read this environment variable,
  23. // which is fine, just act as if it's not set
  24. return null;
  25. }
  26. }
  27. internal static int IndexOf(string source, char value)
  28. {
  29. return InvariantCompareInfo.IndexOf(source, value, CompareOptions.Ordinal);
  30. }
  31. internal static int IndexOf(string source, string value)
  32. {
  33. return InvariantCompareInfo.IndexOf(source, value, CompareOptions.Ordinal);
  34. }
  35. internal static int IndexOf(string source, char value, int startIndex)
  36. {
  37. return InvariantCompareInfo.IndexOf(source, value, startIndex, CompareOptions.Ordinal);
  38. }
  39. internal static int IndexOf(string source, string value, int startIndex)
  40. {
  41. return InvariantCompareInfo.IndexOf(source, value, startIndex, CompareOptions.Ordinal);
  42. }
  43. internal static int LastIndexOf(string source, string value)
  44. {
  45. return InvariantCompareInfo.LastIndexOf(source, value, CompareOptions.Ordinal);
  46. }
  47. internal static bool StartsWith(string source, string prefix)
  48. {
  49. return InvariantCompareInfo.IsPrefix(source, prefix, CompareOptions.Ordinal);
  50. }
  51. internal static bool EndsWith(string source, string suffix)
  52. {
  53. return InvariantCompareInfo.IsSuffix(source, suffix, CompareOptions.Ordinal);
  54. }
  55. internal static string GetTypeName(object obj)
  56. {
  57. return obj.GetType().FullName;
  58. }
  59. }
  60. }
  61. #pragma warning restore
  62. #endif