From d6bce2e7525dfdbacc086051e7ea0a9e56220fd7 Mon Sep 17 00:00:00 2001 From: David Hall Date: Sat, 21 Jul 2018 14:12:08 -0600 Subject: [PATCH] Refactored constructors for easier inheritance --- Core/InteropServices/ComConnectionPoint.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Core/InteropServices/ComConnectionPoint.cs b/Core/InteropServices/ComConnectionPoint.cs index d76d3785..e1443d6e 100644 --- a/Core/InteropServices/ComConnectionPoint.cs +++ b/Core/InteropServices/ComConnectionPoint.cs @@ -22,7 +22,8 @@ namespace Vanara.InteropServices { if (source == null) throw new ArgumentNullException(nameof(source)); if (sink == null) sink = this; - if (interfaces == null || interfaces.Length < 1) throw new ArgumentOutOfRangeException(nameof(interfaces)); + if (interfaces == null) interfaces = GetComInterfaces(sink); + if (interfaces.Length < 1) throw new ArgumentOutOfRangeException(nameof(interfaces)); // Start the event sink if (!(source is IConnectionPointContainer connectionPointContainer)) throw new InvalidOperationException("The source object must be COM object that supports the IConnectionPointContainer interface."); @@ -42,7 +43,7 @@ namespace Vanara.InteropServices /// will be used to setup the connection points. If this object implements COM interfaces that cannot be used as connection points, /// use the constructor that allows for supported interfaces to be specified. /// - public ComConnectionPoint(object source, object sink) : this(source, sink, GetComInterfaces(sink)) { } + public ComConnectionPoint(object source, object sink) : this(source, sink, null) { } private static Type[] GetComInterfaces(object sink) {