Safe.cs
20 lines
| 424 B
| text/x-csharp
|
CSharpLexer
/ Implab / Safe.cs
|
|
r1 | using System; | ||
| using System.Collections.Generic; | ||||
| using System.Linq; | ||||
| using System.Text; | ||||
| namespace Implab | ||||
| { | ||||
| public static class Safe | ||||
| { | ||||
|
|
r2 | public static void Dispose<T>(ref T obj) where T : class | ||
|
|
r1 | { | ||
|
|
r2 | var disp = obj as IDisposable; | ||
| if (disp != null) | ||||
|
|
r1 | { | ||
|
|
r2 | disp.Dispose(); | ||
|
|
r1 | obj = default(T); | ||
| } | ||||
| } | ||||
| } | ||||
| } | ||||
