DisposableUtility.cs 361 B

12345678910111213141516171819
  1. using System;
  2. namespace NModbus.Unme.Common
  3. {
  4. internal static class DisposableUtility
  5. {
  6. public static void Dispose<T>(ref T item)
  7. where T : class, IDisposable
  8. {
  9. if (item == null)
  10. {
  11. return;
  12. }
  13. item.Dispose();
  14. item = default(T);
  15. }
  16. }
  17. }