Share via


IVsDataClientObject<T> Interface

Represents a client wrapper object that interacts with an underlying provider object.

Namespace:  Microsoft.VisualStudio.Data.Core
Assembly:  Microsoft.VisualStudio.Data.Core (in Microsoft.VisualStudio.Data.Core.dll)

Syntax

'Declaration
Public Interface IVsDataClientObject(Of T As Class)
public interface IVsDataClientObject<T>
where T : class
generic<typename T>
where T : ref class
public interface class IVsDataClientObject
type IVsDataClientObject<'T when 'T : not struct> =  interface end
JScript does not support generic types or methods.

Type Parameters

  • T
    The type of the parameter.

The IVsDataClientObject<T> type exposes the following members.

Methods

  Name Description
Public method Initialize Initializes the client object with the underlying provider object implementation.

Top

Remarks

When a DDEX client calls the DDEX runtime to create an instance of a DDEX support entity for a particular provider, the provider object is typically created and returned directly to the client. In this case, the client has a direct handle to the provider’s implementation. In some cases, the owner of the DDEX support entity may want to define additional or modified behavior of the support entity when interacting with the client so as to meet client expectations without adding extra burden on the provider writer.

The most common example of this requirement comes in the form of DDEX connection services like the IVsDataCommand support entity. One goal of IVsDataConnection, the DDEX connection object, is to minimize the overhead required on the client side to ensure that the connection is currently open and not in use by another client, but at the same time eliminate the need to be concerned about these issues on the provider side. Therefore, a given connection service may have a client object associated with it that performs extra logic ensuring that the connection is open and properly shared among multiple clients. This implementation wraps the underlying provider object and is automatically supplied to the client by the DDEX runtime.

DDEX support entities that intend to have the DDEX runtime return a client wrapper object on creation of the provider’s support entity include the DataClientObjectAttribute attribute on the type representing the support entity. This attribute identifies a wrapper class that implements this interface. When requested by a client, the DDEX runtime will first create an instance of the underlying provider object and then create an instance of the wrapper class. The purpose of this interface is to supply a method for initializing the wrapper object with the underlying provider object.

The IVsDataClientObject<T> interface is primarily of interest to DDEX platform extenders, that is, those creating additional DDEX services and support entities.

Examples

The following code shows the definition of a fictitious support entity that declares a client object attribute. This definition is followed by the implementation of the client object, which adds simple logging of the calls to the support entity.

using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using Microsoft.VisualStudio.Data.Core;

[DataClientObject("1520C77F-09AF-40b4-B1FE-53C30A177C59")]
public interface IVsDataSupportEntity
{
    void DoSomething();
}

[Guid("1520C77F-09AF-40b4-B1FE-53C30A177C59")]
internal class ClientSupportEntity : IVsDataSupportEntity,
    IVsDataClientObject<IVsDataSupportEntity>
{
    private IVsDataSupportEntity _providerObj;

    public void Initialize(IVsDataSupportEntity providerObj)
    {
        if (providerObj == null)
        {
            throw new ArgumentNullException("providerObj");
        }
        _providerObj = providerObj;
    }

    public void DoSomething()
    {
        Trace.WriteLine("DoSomething started.");
        _providerObj.DoSomething();
        Trace.WriteLine("DoSomething finished.");
    }
}

See Also

Reference

Microsoft.VisualStudio.Data.Core Namespace