共用方式為


IVsDataProviderDynamicSupport.IsSourceSupported 方法

取得值 DDEX 特定資料來源是否以在目前環境的這 DDEX 提供者支援。

命名空間:  Microsoft.VisualStudio.Data.Core
組件:  Microsoft.VisualStudio.Data.Core (在 Microsoft.VisualStudio.Data.Core.dll 中)

語法

'宣告
Function IsSourceSupported ( _
    source As Guid _
) As Boolean
bool IsSourceSupported(
    Guid source
)
bool IsSourceSupported(
    Guid source
)
abstract IsSourceSupported : 
        source:Guid -> bool
function IsSourceSupported(
    source : Guid
) : boolean

參數

  • source
    類型:Guid

    DDEX 資料來源識別項。

傳回值

類型:Boolean
true DDEX,如果資料來源是由在目前環境的這 DDEX 提供者支援,否則, false。

備註

這個方法會在電腦上還可讓 DDEX 提供者會動態修改其支援的可用性在 Visual Studio 中的特定 DDEX 資料來源,在安裝或沒有安裝。 這會很有用。DDEX 提供者仰賴或目標可以個別或獨立安裝的特定技術 (例如,執行階段 ADO.NET 提供者)。

當這個方法會傳回 false時, IVsDataSourceManager 服務不會在指定的 DDEX 資料來源支援的提供者其清單的提供者。 如果資料來源結果不支援提供者,完全移除資料來源。

範例

下列程式碼將示範如何實作此方法,以便傳回 true ,只有在特定的登錄機碼的存在,表示正常的執行階段元件。

using System;
using System.ComponentModel.Design;
using Microsoft.Win32;
using Microsoft.VisualStudio.Data.Core;

public class MyProviderDynamicSupport3 : IVsDataProviderDynamicSupport
{
    public bool IsProviderSupported
    {
        get
        {
            return true;
        }
    }

    public bool IsSourceSupported(Guid source)
    {
        RegistryKey key = Registry.LocalMachine.OpenSubKey(
            @"SOFTWARE\Company\MyDatabaseSource");
        if (key == null)
        {
            return false;
        }
        key.Close();
        return true;
    }

    public bool IsOperationSupported(
        Guid source, CommandID command, object context)
    {
        return true;
    }

    public string GetUnsupportedReason(
        Guid source, CommandID command, object context)
    {
        return null;
    }
}

.NET Framework 安全性

請參閱

參考

IVsDataProviderDynamicSupport 介面

Microsoft.VisualStudio.Data.Core 命名空間