可以创建实现支持实体的DDEX提供程序。
命名空间: Microsoft.VisualStudio.Data.Core
程序集: Microsoft.VisualStudio.Data.Core(在 Microsoft.VisualStudio.Data.Core.dll 中)
语法
声明
Public Interface IVsDataProviderObjectFactory
public interface IVsDataProviderObjectFactory
public interface class IVsDataProviderObjectFactory
type IVsDataProviderObjectFactory = interface end
public interface IVsDataProviderObjectFactory
IVsDataProviderObjectFactory 类型公开以下成员。
方法
名称 | 说明 | |
---|---|---|
![]() |
CreateObject | 创建指定的DDEX的实例支持由DDEX提供程序实现的实体。 |
![]() |
GetAssembly | 解析一个提供程序特定的程序集字符串与其对应的 Assembly 表示。 |
![]() |
GetType | 解析一个提供程序特定的类型名称与其对应的 Type 表示。 |
页首
备注
DDEX提供程序包括设置DDEX的特定实现支持可供客户端用于调用特定,已知的事件的提供程序特定的行为的实体。最基本级别,DDEX支持实体由接口表示,从而导致实体的其他类型,如XML内容。此接口表示任何全局DDEX的工厂支持实体,并且必须由所有DDEX提供程序的实现。它还演示使用何时使用可使用支持实体指定此信息作为字符串必须解决的自定义类型和程序集决策。
DDEX提供程序可以隐式或显式实现此接口。一个隐式实现时,会发生DDEX提供程序是基于的注册表,以及接口的内置实现读取描述如何创建支持实体的各种注册表项。显式实现时,会发生DDEX提供程序是基于的包,并且此接口实例时提供为提供程序的Visual Studio包实现的服务。前者是最for agile;后者是最灵活。除非有必要,前者是首选方法后者。
示例
下面的代码演示一个基于包的DDEX提供程序可以如何实现此接口与为标准支持实体的一些支持。它使用在DDEX framework程序集中定义接口的基实现。
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() {}
}