4
4
5
5
namespace Rubberduck . VBEditor . SafeComWrappers
6
6
{
7
- public class SafeIDispatchWrapper < TDispatch > : SafeIDispatchWrapper
7
+ /// <summary>
8
+ /// Creates a new IDispatch-based wrapper for a provided
9
+ /// COM interface. This is internal and should be used only
10
+ /// within the Rubberduck.VBEditor.* projects.
11
+ /// </summary>
12
+ /// <remarks>
13
+ /// To avoid exposing additional interop libraries to other projects
14
+ /// and violating the separation, only the non-generic version of
15
+ /// <see cref="SafeIDispatchWrapper" /> be provided for consumption outside
16
+ /// the Rubberduck.VBEditor.* projects.
17
+ /// Within those projects, the class is useful for wrapping COM interfaces
18
+ /// that do not have a corresponding <see cref="ISafeComWrapper{T}" />
19
+ /// implementations to ensure those are managed and will not leak.
20
+ /// </remarks>
21
+ /// <typeparam name="TDispatch">COM interface to wrap</typeparam>
22
+ /// <inheritdoc />
23
+ internal class SafeIDispatchWrapper < TDispatch > : SafeIDispatchWrapper
8
24
{
9
- public SafeIDispatchWrapper ( TDispatch target , bool rewrapping = false ) : base ( target , rewrapping )
25
+ internal SafeIDispatchWrapper ( TDispatch target , bool rewrapping = false ) : base ( target , rewrapping )
10
26
{ }
11
27
12
28
public new TDispatch Target => ( TDispatch ) base . Target ;
13
29
}
14
30
31
+ /// <summary>
32
+ /// Provide a IDispatch-based (e.g. late-bound) access to a COM object.
33
+ /// Use <see cref="Invoke"/> to work with the object. The
34
+ /// <see cref="SafeIDispatchWrapper.Target"/> must be a raw COM object without
35
+ /// any wrappers.
36
+ /// </summary>
15
37
public class SafeIDispatchWrapper : SafeComWrapper < dynamic >
16
38
{
17
39
public SafeIDispatchWrapper ( object target , bool rewrapping = false ) : base ( target , rewrapping )
@@ -24,8 +46,18 @@ public SafeIDispatchWrapper(object target, bool rewrapping = false) : base(targe
24
46
IDispatchPointer = GetPointer ( target ) ;
25
47
}
26
48
49
+ // ReSharper disable once InconsistentNaming
27
50
public IntPtr IDispatchPointer { get ; }
28
51
52
+ /// <summary>
53
+ /// Use the method to encapsulate operations against the late-bound COM object.
54
+ /// It is caller's responsibilty to handle any exceptions that may result as part
55
+ /// of the operation.
56
+ /// </summary>
57
+ /// <param name="action">
58
+ /// A method that perform work against the late-bound COM object provided as the
59
+ /// parameter to the function
60
+ /// </param>
29
61
public void Invoke ( Action < dynamic > action )
30
62
{
31
63
action . Invoke ( Target ) ;
0 commit comments