comparison Implab/Safe.cs @ 2:aa367305156b

small fixes
author cin
date Thu, 29 Aug 2013 17:03:44 +0400
parents 6fb3b01ee971
children dafaadca5b9f
comparison
equal deleted inserted replaced
1:6fb3b01ee971 2:aa367305156b
5 5
6 namespace Implab 6 namespace Implab
7 { 7 {
8 public static class Safe 8 public static class Safe
9 { 9 {
10 public static void Dispose<T>(ref T obj) where T : IDisposable 10 public static void Dispose<T>(ref T obj) where T : class
11 { 11 {
12 if (obj != null) 12 var disp = obj as IDisposable;
13 if (disp != null)
13 { 14 {
14 obj.Dispose(); 15 disp.Dispose();
15 obj = default(T); 16 obj = default(T);
16 } 17 }
17 } 18 }
18 } 19 }
19 } 20 }