DebugHelper.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. using System;
  2. namespace com.bbbirder.injection
  3. {
  4. #if NO_UNITY
  5. public static class DebugHelper
  6. {
  7. public static void Log(object message)
  8. {
  9. System.Diagnostics.Debug.WriteLine(message);
  10. }
  11. public static void LogWarning(object message)
  12. {
  13. System.Diagnostics.Debug.WriteLine(message);
  14. }
  15. public static void LogError(object message)
  16. {
  17. System.Diagnostics.Debug.WriteLine(message);
  18. }
  19. public static void LogException(Exception exception)
  20. {
  21. System.Diagnostics.Debug.WriteLine(exception.ToString());
  22. }
  23. public static void IsNotNull<T>(T value) where T : class
  24. {
  25. IsNotNull(value, null);
  26. }
  27. public static void IsNotNull<T>(T value, string message) where T : class
  28. {
  29. if (typeof(Object).IsAssignableFrom(typeof(T)))
  30. {
  31. IsNotNull(value as Object, message);
  32. }
  33. else if (value == null)
  34. {
  35. System.Diagnostics.Debug.WriteLine("assert faild:" + message);
  36. }
  37. }
  38. public static void IsNotNull(Object value, string message)
  39. {
  40. if (value == null)
  41. {
  42. System.Diagnostics.Debug.WriteLine("assert faild:"+message);
  43. }
  44. }
  45. }
  46. #else
  47. public static class DebugHelper
  48. {
  49. public static void Log(object message)
  50. {
  51. UnityEngine.Debug.Log(message);
  52. }
  53. public static void LogWarning(object message)
  54. {
  55. UnityEngine.Debug.LogWarning(message);
  56. }
  57. public static void LogError(object message)
  58. {
  59. UnityEngine.Debug.LogError(message);
  60. }
  61. public static void LogException(Exception exception)
  62. {
  63. UnityEngine.Debug.LogException(exception);
  64. }
  65. public static void IsNotNull<T>(T value) where T : class
  66. {
  67. UnityEngine.Assertions.Assert.IsNotNull(value);
  68. }
  69. public static void IsNotNull<T>(T value, string message) where T : class
  70. {
  71. UnityEngine.Assertions.Assert.IsNotNull(value, message);
  72. }
  73. public static void IsNotNull(Object value, string message)
  74. {
  75. UnityEngine.Assertions.Assert.IsNotNull(value, message);
  76. }
  77. }
  78. #endif
  79. }