Partager via


IVsDataProviderObjectFactory.GetType Method

Resolves a provider-specific type name to its corresponding Type representation.

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

Syntax

'Declaration
Function GetType ( _
    typeName As String _
) As Type
Type GetType(
    string typeName
)
Type^ GetType(
    String^ typeName
)
abstract GetType : 
        typeName:string -> Type
function GetType(
    typeName : String
) : Type

Parameters

Return Value

Type: System.Type
An Type object representing the type resolved from the specified type name, if found; otherwise, nulla null reference (Nothing in Visual Basic).

Exceptions

Exception Condition
ArgumentNullException

The typeName parameter is nulla null reference (Nothing in Visual Basic).

Remarks

A provider implements this method when there are type names specified as strings in formats such as a data support XML file, and these type names cannot be automatically resolved (or would be resolved incorrectly) by the CLR’s GetType method. One use of this method would be to expand an unspecified namespace. (For example, if the string is "MyType" it might get expanded to "Company.Product.MyType" before the CLR resolves it.)

This method is provided to shorten a provider’s specification of type names, which can help reduce the duplication of some element, like a common namespace, throughout the code base.

Examples

The following code demonstrates how to implement this method to prepend a common namespace to all type names. The example inherits from the DataProviderObjectFactory class, which provides a default implementation of the GetType and GetAssembly methods.

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

public class MyProviderObjectFactory3 : DataProviderObjectFactory
{
    public override object CreateObject(Type objType)
    {
        return null;
    }

    public override Type GetType(string typeName)
    {
        typeName = "Company.DdexProvider." + typeName;
        return base.GetType(typeName);
    }
}

.NET Framework Security

See Also

Reference

IVsDataProviderObjectFactory Interface

Microsoft.VisualStudio.Data.Core Namespace