Compartir a través de


IVsDataProviderObjectFactory Interface

Provides the ability to create DDEX provider implementations of support entities.

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

Syntax

'Declaration
Public Interface IVsDataProviderObjectFactory
public interface IVsDataProviderObjectFactory
public interface class IVsDataProviderObjectFactory
type IVsDataProviderObjectFactory =  interface end
public interface IVsDataProviderObjectFactory

The IVsDataProviderObjectFactory type exposes the following members.

Methods

  Name Description
Public method CreateObject Creates an instance of the specified DDEX support entity that is implemented by the DDEX provider.
Public method GetAssembly Resolves a provider-specific assembly string to its corresponding Assembly representation.
Public method GetType Resolves a provider-specific type name to its corresponding Type representation.

Top

Remarks

A DDEX provider consists of a set of specific implementations of DDEX support entities that can be used by clients to invoke provider-specific behavior for a particular, well-known action. At the most fundamental level, DDEX support entities are represented by interfaces, which may then produce other types of entities, such as XML content. This interface represents the factory for all global DDEX support entities and must be implemented by all DDEX providers. It also represents custom type and assembly resolution that you can use when working with support entities that specify this information as strings that must be resolved.

A DDEX provider may implement this interface implicitly or explicitly. An implicit implementation occurs when the DDEX provider is registry based and a built-in implementation of the interface reads various registry keys that describe how to create the support entities. An explicit implementation occurs when the DDEX provider is package based and an instance of this interface is proffered as a service on the provider’s Visual Studio Package implementation. The former is the most agile; the latter is the most flexible. The former is the preferred approach unless the latter is required.

Examples

The following code demonstrates how a package-based DDEX provider can implement this interface with support for some the standard support entities. It uses the base implementation of the interface that is defined in the DDEX framework assembly.

using System;
using Microsoft.VisualStudio.Data.Core;
using Microsoft.VisualStudio.Data.Framework;
using Microsoft.VisualStudio.Data.Services;
using Microsoft.VisualStudio.Data.Services.SupportEntities;

internal class MyProviderObjectFactory : DataProviderObjectFactory
{
    public override object CreateObject(Type objType)
    {
        if (objType == null)
        {
            throw new ArgumentNullException("objType");
        }
        if (objType == typeof(IVsDataConnectionProperties))
        {
            return new MyConnectionProperties();
        }
        if (objType == typeof(IVsDataConnectionSupport))
        {
            return new MyConnectionSupport();
        }
        return null;
    }
}

internal class MyConnectionProperties : DataConnectionProperties
{
}

internal class MyConnectionSupport : IVsDataConnectionSupport
{
    // Implement the interface methods 

    public void Initialize(object providerObj) {}
    public bool Open(bool doPromptCheck) {return true;}
    public void Close() {}
    public string ConnectionString { get {return "";} set {} }
    public int ConnectionTimeout { get {return 0;} set {} }
    public DataConnectionState State { get {return DataConnectionState.Closed;} }
    public object ProviderObject { get {return null;} }

    // Inherited from System.IServiceProvider  
    public Object GetService(Type serviceType) {return null;}

    // Inherited from System.IDisposable 
    public void Dispose() {}

}

See Also

Reference

Microsoft.VisualStudio.Data.Core Namespace