ProvideLanguageExtensionAttribute 类   
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
将文件扩展名与特定语言服务相关联。
public ref class ProvideLanguageExtensionAttribute sealed : Microsoft::VisualStudio::Shell::RegistrationAttributepublic ref class ProvideLanguageExtensionAttribute sealed : Microsoft::VisualStudio::Shell::RegistrationAttribute[System.AttributeUsage(System.AttributeTargets.Class, AllowMultiple=true, Inherited=true)]
public sealed class ProvideLanguageExtensionAttribute : Microsoft.VisualStudio.Shell.RegistrationAttribute[<System.AttributeUsage(System.AttributeTargets.Class, AllowMultiple=true, Inherited=true)>]
type ProvideLanguageExtensionAttribute = class
    inherit RegistrationAttributePublic NotInheritable Class ProvideLanguageExtensionAttribute
Inherits RegistrationAttribute- 继承
- 属性
示例
此示例演示如何将文件扩展名“.myext”与语言服务相关联。
注意
Visual C# 通过删除名称的“Attribute”部分,允许用户定义属性的速记形式。 此速记形式用于本类和所有其他示例中。
using Microsoft.VisualStudio.Shell;  
namespace MyLanguagePackage  
{  
    [ProvideLanguageExtension(typeof(MyLanguageService), ".myext")]  
    public class MyLanguagePackage : Package  
    {  
    }  
}  
注解
此用户定义的 C# 属性用于向 Visual Studio 注册特定语言服务的文件扩展名。 此属性将必要信息放入程序集的元数据中,稍后由 regpkg.exe 检索和使用。 仍必须注册语言服务本身;此属性仅使文件扩展名和语言服务之间关联。 有关详细信息,请参阅 注册 VSPackages。
可以使用此属性的多个实例将多个文件扩展名与语言服务相关联。
受此属性影响的注册表项位于 Visual Studio 注册表项下:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\[X.Y]\  
  Languages\  
    File Extensions\  
      [FileExtension]\  
        (Default) = RG_SZ: [LanguageServiceGuid]  
其中:
- [X.Y] 是 Visual Studio 版本号,例如 8.0 或 8.0exp。 
- [FileExtension] 是一个字符串,其中包含具有前导句点的文件扩展名;例如“myext”。 
- [LanguageServiceGuid] 是语言服务的 GUID;例如 。 - {B614A40A-80D9-4FAC-A6AD-FC2868FFF7CD}
以下用户定义的属性用于语言服务:
| Attribute | 说明 | 
|---|---|
| ProvideLanguageServiceAttribute | 将语言服务注册到 Visual Studio 并指定支持的功能。 | 
| ProvideLanguageExtensionAttribute | 将文件扩展名与语言服务相关联。 | 
| ProvideLanguageEditorOptionPageAttribute | 指定特定于语言服务的“选项”对话框的属性节点或页面。 | 
| ProvideLanguageCodeExpansionAttribute | 指定位置信息以支持语言服务中的代码片段。 | 
| ProvideServiceAttribute | 将语言服务注册为 Visual Studio 服务。 托管代码中提供的所有服务都使用此属性。 | 
继承者说明
此属性类无法继承自,因此无需实现任何内容。
调用方说明
在 VSPackage 上使用此属性可将文件扩展名与语言服务相关联。
构造函数
| ProvideLanguageExtensionAttribute(String, String) | 使用指定的语言服务 GUID 初始化 特性的新实例 ProvideLanguageExtensionAttribute 。 | 
| ProvideLanguageExtensionAttribute(Type, String) | 使用语言服务类的类型 ProvideLanguageExtensionAttribute 初始化 特性的新实例。 | 
属性
| Extension | 返回关联的文件扩展名。 | 
| LanguageService | 返回语言 GUID。 | 
| TypeId | 重写 TypeID 属性,使 RegistrationAttribute 派生类能够与 System.ComponentModel.TypeDescriptor.GetAttributes 一起使用 (...) 。仅当派生自此属性的属性需要对可应用于类的实例使用更好的控件时,它才必须重写此属性。(继承自 RegistrationAttribute) | 
方法
| GetPackageRegKeyPath(Guid) | 获取相对于 VSPackage 的应用程序) 注册表根目录 (注册表路径。(继承自 RegistrationAttribute) | 
| Register(RegistrationAttribute+RegistrationContext) | 将文件扩展名和语言服务 GUID 放入注册表。 | 
| Unregister(RegistrationAttribute+RegistrationContext) | 从注册表中删除文件扩展名和语言服务 GUID。 |