Share via


IVsDataProvider.GetProperty Method

Gets a registered property of the DDEX provider.

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

Syntax

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

Parameters

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 is nulla null reference (Nothing in Visual Basic).

Remarks

A DDEX provider can register a set of properties that DDEX clients can access to determine information about the provider. Standard properties include the provider name, display name, short display name, description, and technology, but any property may be included by the provider.

A property value is retrieved by opening the DDEX provider’s root registry key and requesting a value under the key that has the specified name. (The root registry key is located under the DataProviders key in the Visual Studio local registry hive.) 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 how to retrieve the value of the InvariantName property, which is typically defined by DDEX providers that are based on ADO.NET technology. The value of this property is then used to create an ADO.NET connection object through the DbProviderFactory APIs.

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

public class DDEX_IVsDataProviderExample4
{
    public static DbConnection CreateAdoDotNetConnection(
        IVsDataProvider provider)
    {
        string invariantName = provider.GetProperty("InvariantName") as string;
        if (invariantName != null)
        {
            DbProviderFactory factory = DbProviderFactories.GetFactory(
                invariantName);
            if (factory != null)
            {
                return factory.CreateConnection();
            }
        }
        return null;
    }
}

.NET Framework Security

See Also

Reference

IVsDataProvider Interface

Microsoft.VisualStudio.Data.Core Namespace