comparison Implab/Safe.cs @ 215:fe5101083150 v2

Fixed InteractiveListener to support OLE and clipboard. Safe.Dispose methods made more convinent
author cin
date Fri, 21 Apr 2017 14:27:17 +0300
parents 9ee78a345738
children 8808383fcb94
comparison
equal deleted inserted replaced
214:9c32ef39b851 215:fe5101083150
63 if (d != null) 63 if (d != null)
64 d.Dispose(); 64 d.Dispose();
65 } 65 }
66 } 66 }
67 67
68 public static void Dispose(IEnumerable<IDisposable> objects) { 68 public static void DisposeCollection(IEnumerable<IDisposable> objects) {
69 foreach (var d in objects) 69 foreach (var d in objects)
70 if (d != null) 70 Dispose(d);
71 d.Dispose(); 71 }
72
73 public static void DisposeCollection(IEnumerable objects) {
74 foreach (var d in objects)
75 Dispose(d);
72 } 76 }
73 77
74 public static void Dispose(object obj) { 78 public static void Dispose(object obj) {
75 var d = obj as IDisposable; 79 if (obj is IDisposable) {
76 if (d != null) 80 Dispose((IDisposable)obj);
77 d.Dispose(); 81 } else if (obj is IEnumerable) {
82 Dispose((IEnumerable)obj);
83 }
78 } 84 }
79 85
86 [DebuggerStepThrough]
80 public static void DispatchEvent<T>(this EventHandler<T> handler, object sender, T args) { 87 public static void DispatchEvent<T>(this EventHandler<T> handler, object sender, T args) {
81 if (handler != null) 88 if (handler != null)
82 handler(sender, args); 89 handler(sender, args);
83 } 90 }
84 91
92 [DebuggerStepThrough]
85 public static void DispatchEvent(this EventHandler handler, object sender, EventArgs args) { 93 public static void DispatchEvent(this EventHandler handler, object sender, EventArgs args) {
86 if (handler != null) 94 if (handler != null)
87 handler(sender, args); 95 handler(sender, args);
88 } 96 }
89 97