Class ComWrapper
Wraps a late-bound COM server.
Inheritance
Namespace: Dapplo.Windows.Com
Assembly: Dapplo.Windows.Com.dll
Syntax
public sealed class ComWrapper : RealProxy, IDisposable, IRemotingTypeInfo
Fields
| Improve this Doc View SourceRPC_E_CALL_REJECTED
Declaration
public const int RPC_E_CALL_REJECTED = null
Field Value
| Type | Description |
|---|---|
| System.Int32 |
RPC_E_FAIL
Declaration
public const int RPC_E_FAIL = null
Field Value
| Type | Description |
|---|---|
| System.Int32 |
Properties
| Improve this Doc View SourceTypeName
Implementation for the interface IRemotingTypeInfo
Declaration
public string TypeName { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
Methods
| Improve this Doc View SourceCanCastTo(Type, Object)
Implementation for the interface IRemotingTypeInfo This makes it possible to cast the COMWrapper
Declaration
public bool CanCastTo(Type toType, object o)
Parameters
| Type | Name | Description |
|---|---|---|
| Type | toType | Type to cast to |
| System.Object | o | object to cast |
Returns
| Type | Description |
|---|---|
| System.Boolean |
CreateInstance<TCom>()
A simple create instance, doesn't create a wrapper!!
Declaration
public static TCom CreateInstance<TCom>()
Returns
| Type | Description |
|---|---|
| TCom | T |
Type Parameters
| Name | Description |
|---|---|
| TCom | Type of the COM |
Dispose()
Cleans up the COM object.
Declaration
public void Dispose()
Equals(Object)
Compares this object to another.
Declaration
public override bool Equals(object value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | value | The value to compare to. |
Returns
| Type | Description |
|---|---|
| System.Boolean | true if the objects are equal. |
Finalize()
If Dispose() is not called, we need to make sure that the COM object is still cleaned up.
Declaration
protected void Finalize()
GetHashCode()
Returns the hash code of the wrapped object.
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| System.Int32 | The hash code of the wrapped object. |
GetInstance<T>()
Gets a COM object and returns the transparent proxy which intercepts all calls to the object
Declaration
public static T GetInstance<T>()
Returns
| Type | Description |
|---|---|
| T | Transparent proxy to the real proxy for the object |
Type Parameters
| Name | Description |
|---|---|
| T | Interface which defines the method and properties to intercept |
Remarks
T must be an interface decorated with the ComProgIdAttributeattribute.
GetOrCreateInstance<T>()
Gets or creates a COM object and returns the transparent proxy which intercepts all calls to the object The ComProgId can be a normal ComProgId or a GUID prefixed with "clsid:"
Declaration
public static T GetOrCreateInstance<T>()
Returns
| Type | Description |
|---|---|
| T | Transparent proxy to the real proxy for the object |
Type Parameters
| Name | Description |
|---|---|
| T | Interface which defines the method and properties to intercept |
Remarks
T must be an interface decorated with the ComProgIdAttributeattribute.
Invoke(IMessage)
Intercept method calls
Declaration
public override IMessage Invoke(IMessage myMessage)
Parameters
| Type | Name | Description |
|---|---|---|
| IMessage | myMessage | Contains information about the method being called |
Returns
| Type | Description |
|---|---|
| IMessage | A |
ToString()
Returns a string representing the wrapped object.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| System.String | The full name of the intercepted type. |
Wrap<T>(Object)
Wrap a com object as COMWrapper
Declaration
public static T Wrap<T>(object comObject)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | comObject | An object to intercept |
Returns
| Type | Description |
|---|---|
| T | Transparent proxy to the real proxy for the object |
Type Parameters
| Name | Description |
|---|---|
| T | Interface which defines the method and properties to intercept |