RegisterEditorExtensionAttribute(Object, String, Int32) 构造函数

定义

RegisterEditorExtensionAttribute为提供的工厂类型和扩展初始化新的。Initializes a new RegisterEditorExtensionAttribute for the supplied factory type and extension.

public:
 RegisterEditorExtensionAttribute(System::Object ^ factoryType, System::String ^ extension, int priority);
public:
 RegisterEditorExtensionAttribute(Platform::Object ^ factoryType, Platform::String ^ extension, int priority);
 RegisterEditorExtensionAttribute(winrt::Windows::Foundation::IInspectable const & factoryType, std::wstring const & extension, int priority);
public RegisterEditorExtensionAttribute (object factoryType, string extension, int priority);
new Microsoft.VisualStudio.Shell.RegisterEditorExtensionAttribute : obj * string * int -> Microsoft.VisualStudio.Shell.RegisterEditorExtensionAttribute
Public Sub New (factoryType As Object, extension As String, priority As Integer)

参数

factoryType
Object

以下类型之一:以字符串形式表示的编辑器工厂的类型。编辑器工厂的 GUID。编辑器工厂的类型。One of following types:The type of the editor factory expressed as a string.The GUID of the editor factory.The type of the editor factory.

extension
String

要与编辑器工厂关联的文件扩展名。The file extension to associate with the editor factory. 此扩展应包含前缀 "."。This extension should include the prefix ".".

priority
Int32

此编辑器工厂的优先级。The priority of this editor factory. 具有较高优先级数字的编辑器有机会首先读取文件。Editors with higher priority numbers are given a chance to read a file first. 如果失败,将使用按优先级排列的下一个编辑器。Upon failure, the next editor in priority order is used.

例外

如果传入了,则此方法 ArgumentNullException 将引发:出厂 GUID 值 factoryTypenullThis method throws an ArgumentNullException if:Factory GUID value passed in factoryType is null. extensionnullextension is null.

如果为,则此方法将引发 ArgumentException :无法将工厂 guid 字符串转换为 GUID 对象。This method throws an ArgumentException if:The factory GUID string cannot be converted to a GUID object. 扩展名不以 "." 开头。Extension does not begin with a ".".

示例

下面的 c # 代码将 RegisterEditorExtension 属性应用于名为 BasicEditor 的 VSPackage。The following C# code applies the RegisterEditorExtension attribute to a VSPackage named BasicEditor.

using Microsoft.VisualStudio.Shell;  
using MSVSIP = Microsoft.VisualStudio.Shell;  
[MSVSIP.RegisterEditorExtension(typeof(EditorFactory), ".myext", 32, "{A2FE74E1-B743-11d0-AE1A-00A0C90FFFC3}", "..\\..\\Templates", 106)]  
public class BasicEditor : MSVSIP.Package {}  

注解

如果你无权访问编辑器工厂,则此构造函数很有用,因为它是在其他地方实现的。This constructor is useful if you do not have access to the editor factory because it is implemented elsewhere.

适用于