diff 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
line wrap: on
line diff
--- a/Implab/Safe.cs	Fri Apr 14 15:57:23 2017 +0300
+++ b/Implab/Safe.cs	Fri Apr 21 14:27:17 2017 +0300
@@ -65,23 +65,31 @@
             }
         }
 
-        public static void Dispose(IEnumerable<IDisposable> objects) {
+        public static void DisposeCollection(IEnumerable<IDisposable> objects) {
             foreach (var d in objects)
-                if (d != null)
-                    d.Dispose();
+                Dispose(d);
+        }
+
+        public static void DisposeCollection(IEnumerable objects) {
+            foreach (var d in objects)
+                Dispose(d);
         }
 
         public static void Dispose(object obj) {
-            var d = obj as IDisposable;
-            if (d != null)
-                d.Dispose();
+            if (obj is IDisposable) {
+                Dispose((IDisposable)obj);
+            } else if (obj is IEnumerable) {
+                Dispose((IEnumerable)obj);
+            }
         }
 
+        [DebuggerStepThrough]
         public static void DispatchEvent<T>(this EventHandler<T> handler, object sender, T args) {
             if (handler != null)
                 handler(sender, args);
         }
 
+        [DebuggerStepThrough]
         public static void DispatchEvent(this EventHandler handler, object sender, EventArgs args) {
             if (handler != null)
                 handler(sender, args);