ContextAttributes.Add(String, String, vsContextAttributeType) Метод
Определение
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Добавляет в коллекцию ContextAttributes пару имя/значение.
public:
EnvDTE::ContextAttribute ^ Add(System::String ^ AttributeName, System::String ^ AttributeValue, EnvDTE::vsContextAttributeType Type);
public:
EnvDTE::ContextAttribute ^ Add(Platform::String ^ AttributeName, Platform::String ^ AttributeValue, EnvDTE::vsContextAttributeType Type);
EnvDTE::ContextAttribute Add(std::wstring const & AttributeName, std::wstring const & AttributeValue, EnvDTE::vsContextAttributeType Type);
[System.Runtime.InteropServices.DispId(4)]
public EnvDTE.ContextAttribute Add (string AttributeName, string AttributeValue, EnvDTE.vsContextAttributeType Type);
[<System.Runtime.InteropServices.DispId(4)>]
abstract member Add : string * string * EnvDTE.vsContextAttributeType -> EnvDTE.ContextAttribute
Public Function Add (AttributeName As String, AttributeValue As String, Type As vsContextAttributeType) As ContextAttribute
Параметры
- AttributeName
- String
Обязательный. Имя нового атрибута.
- AttributeValue
- String
Обязательный. Значение нового атрибута.
Обязательный. Константа vsContextAttributeType, показывает тип нового атрибута.
Возвращаемое значение
Объект ContextAttribute.
- Атрибуты
Примеры
Sub AddExample()
' Get a reference to Solution Explorer.
Dim SolnEx As Window = DTE.Windows.Item _
(Constants.vsWindowKindSolutionExplorer)
Dim CA As ContextAttribute
' List the current attributes associated with Solution Explorer.
ListAttr(SolnEx, CA)
' Associate a new F1 keyword with Solution Explorer.
SolnEx.ContextAttributes.Add("ANewKeyword", 900, _
vsContextAttributeType.vsContextAttributeLookupF1)
ListAttr(SolnEx, CA)
' Delete the new F1 keyword from Solution Explorer.
SolnEx.ContextAttributes.Item(3).Remove()
ListAttr(SolnEx, CA)
End Sub
Sub ListAttr(ByVal SolnEx As Object, ByVal CA As ContextAttribute)
' Support function for CATest(). Lists the current attributes
' associated with Solution Explorer.
Dim msg As String
MsgBox("Number of context attributes in Solution Explorer: " & _
SolnEx.ContextAttributes.Count)
For Each CA In SolnEx.ContextAttributes
msg = msg & CA.Name & Chr(13)
Next
MsgBox(msg)
msg = ""
End Sub
Комментарии
Add позволяет добавить новый атрибут в коллекцию (контейнер контекста) или создать ключевые слова.
Примечание
Если объект коллекции, для которого вызывается метод Type , имеет значение vsContextAttributesGlobal , то этот метод завершается с ошибкой E_NOTIMPL .