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
    型 : System.Type
    DDEX のサポートのエンティティの型。

戻り値

型 : System.Object
DDEX プロバイダーでサポートされていれば、DDEX プロバイダーによって実装された指定 DDEX のサポートのエンティティのインスタンス; それ以外 nullnull 参照 (Visual Basic では Nothing)。

例外

例外 条件
ArgumentNullException

objType パラメーターが nullnull 参照 (Visual Basic では Nothing) です。

解説

DDEX プラットフォームの、最も重要なメソッドは、このメソッドのコア機能拡張モデルを表し、プロバイダーに渡すように、抽象型 (インターフェイスまたは基本クラス) し、[戻る]この種のプロバイダーの実装を取得します。プロバイダーは、トップレベルのサポートのエンティティを通常はサービスへのデータ接続を照会したり、データのサポートの XML ファイルから参照される型を作成することに対してクライアントが間接的に直接作成するつまり、を返すには、このメソッドを実装します。

次のコードは、いくつかの標準的なサポートのエンティティを作成するには、このメソッドを実行する方法を示します。この例では GetTypeGetAssembly のメソッドの既定の実装を提供するフレームワークの DataProviderObjectFactory のクラスから継承します。

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 名前空間