IVsDataProviderObjectFactory.CreateObject 메서드

DDEX 공급자에 의해 구현 된 지정한 DDEX 지원 엔터티 인스턴스를 만듭니다.

네임스페이스:  Microsoft.VisualStudio.Data.Core
어셈블리:  Microsoft.VisualStudio.Data.Core(Microsoft.VisualStudio.Data.Core.dll)

구문

‘선언
Function CreateObject ( _
    objType As Type _
) As Object
Object CreateObject(
    Type objType
)
Object^ CreateObject(
    Type^ objType
)
abstract CreateObject : 
        objType:Type -> Object
function CreateObject(
    objType : Type
) : Object

매개 변수

  • objType
    형식: Type

    DDEX 지원 엔티티 유형입니다.

반환 값

형식: Object
DDEX 공급자에서 지 원하는 경우 DDEX 공급자에 의해 구현 되는 지정 된 DDEX 지원 엔터티 인스턴스. 그렇지 않으면 nullNull 참조(Visual Basic의 경우 Nothing).

예외

예외 조건
ArgumentNullException

objType 매개 변수가 nullNull 참조(Visual Basic의 경우 Nothing)입니다.

설명

아마도 DDEX 플랫폼에서 가장 중요 한 메서드를 공급자에 전달 될 추상 형식 (예를 들어,는 인터페이스 또는 기본 클래스)를 허용 하 고 공급자의 구현 형식을 다시 가져오는 확장성 모델의 핵심을이 메서드를 나타냅니다. 이외의 일반적으로로 클라이언트가 직접 직접 데이터 연결 서비스를 쿼리하여 만들지 최상위 지원 엔터티를 반환 합니다.이 메서드는 공급자를 구현 하거나 지원 XML 파일에서 데이터 형식 만들기를 참조 합니다.

예제

다음 코드는 다양 한 표준 지원 엔터티를 만들려면이 메서드를 구현 하는 방법을 보여 줍니다. 이 예제에서는 프레임 워크에서 상속 DataProviderObjectFactory 의 기본 구현을 제공 하는 클래스는 GetTypeGetAssembly 메서드.

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() {}

}

.NET Framework 보안

참고 항목

참조

IVsDataProviderObjectFactory 인터페이스

Microsoft.VisualStudio.Data.Core 네임스페이스