Share via


IVsDataSource.GetProperty Method (Guid, String)

Gets a property of the DDEX data source as registered by a specific supporting DDEX provider.

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

Syntax

'Declaration
Function GetProperty ( _
    provider As Guid, _
    name As String _
) As Object
Object GetProperty(
    Guid provider,
    string name
)
Object^ GetProperty(
    Guid provider, 
    String^ name
)
abstract GetProperty : 
        provider:Guid * 
        name:string -> Object
function GetProperty(
    provider : Guid, 
    name : String
) : Object

Parameters

  • provider
    Type: System.Guid

    The identifier of a supporting DDEX provider.

Return Value

Type: System.Object
The value of the property, if exists; otherwise, nulla null reference (Nothing in Visual Basic).

Exceptions

Exception Condition
ArgumentNullException

The name parameter was nulla null reference (Nothing in Visual Basic).

Remarks

A DDEX data source can register a set of properties that are accessed by DDEX clients to determine information about the data source. Additionally, each DDEX provider that supports a DDEX data source can register provider-specific properties associated with the DDEX data source.

When the provider parameter is an empty GUID, this method retrieves a global data source property value by opening the DDEX data source’s root registry key (under the DataSources key in the Visual Studio local registry hive) and requesting a value under the key that has the specified name. When the provider parameter is a valid supporting DDEX provider identifier, this method retrieves a provider-specific data source property value by opening the supporting provider’s subkey under the data source’s root registry key and requesting a value under this subkey with the specified name. After a specific property has been requested, its value is saved in memory by the DDEX runtime and not refreshed until Visual Studio is restarted.

Examples

The following code demonstrates the implementation of the DisplayName property. Because localized strings are provided only by supporting providers, it determines an appropriate supporting provider to use based on the default provider and/or which providers supply values for the DisplayName property. It then resolves this to the actual localized string by using the DDEX provider API.

using System;
using System.Data;
using System.Data.Common;
using Microsoft.VisualStudio.Data.Core;

public class DDEX_IVsDataSourceExample2
{
    public static string GetSourceDisplayName(
        IServiceProvider serviceProvider,
        IVsDataSource dataSource)
    {
        string displayName = null;
        string resourceId = null;
        Guid provider = dataSource.DefaultProvider;
        if (provider != Guid.Empty)
        {
            resourceId = dataSource.GetProperty(provider, "DisplayName") as string;
        }
        if (resourceId == null)
        {
            foreach (Guid providerId in dataSource.GetProviders())
            {
                resourceId = dataSource.GetProperty(
                    providerId, "DisplayName") as string;
                if (resourceId != null)
                {
                    provider = providerId;
                    break;
                }
            }
        }
        if (provider != Guid.Empty && resourceId != null)
        {
            IVsDataProviderManager providerManager = serviceProvider.GetService(
                typeof(IVsDataProviderManager)) as IVsDataProviderManager;
            IVsDataProvider dataProvider = providerManager.Providers[provider];
            displayName = dataProvider.GetString(resourceId);
        }
        return displayName;
    }
}

.NET Framework Security

See Also

Reference

IVsDataSource Interface

GetProperty Overload

Microsoft.VisualStudio.Data.Core Namespace