AddInToken AddInToken AddInToken AddInToken Class

定义

表示可激活的外接程序。Represents an add-in that can be activated.

public ref class AddInToken sealed : System::Collections::Generic::IEnumerable<System::AddIn::Hosting::QualificationDataItem>
[System.Serializable]
public sealed class AddInToken : System.Collections.Generic.IEnumerable<System.AddIn.Hosting.QualificationDataItem>
type AddInToken = class
    interface seq<QualificationDataItem>
    interface IEnumerable
Public NotInheritable Class AddInToken
Implements IEnumerable(Of QualificationDataItem)
继承
AddInTokenAddInTokenAddInTokenAddInToken
属性
实现

示例

本部分包含两个示例。This section contains two examples. 第一个示例将激活使用ChooseAddIn方法选择的外接程序, 第二个示例ChooseAddIn演示方法。The first example activates an add-in that has been selected by using the ChooseAddIn method, and the second example shows the ChooseAddIn method.

示例1Example 1

下面的示例演示如何使用标记激活外接程序。The following example shows how to activate an add-in with a token.

//Ask the user which add-in they would like to use.
AddInToken selectedToken = ChooseAddIn(tokens);

//Activate the selected AddInToken in a new
//application domain with the Internet trust level.
Calculator CalcAddIn = selectedToken.Activate<Calculator>(AddInSecurityLevel.Internet);
            
//Run the add-in using a custom method.
RunCalculator(CalcAddIn);
'Ask the user which add-in they would like to use.
Dim selectedToken As AddInToken = ChooseAddIn(tokens)
'Activate the selected AddInToken in a new
'application domain with the Internet trust level.
Dim CalcAddIn As Calculator = selectedToken.Activate(Of Calculator)(AddInSecurityLevel.Internet)
'Run the add-in using a custom method.
RunCalculator(CalcAddIn)

示例2Example 2

下面的示例演示了用于ChooseAddIn AddInToken枚举集合的自定义方法。The following example shows the custom ChooseAddIn method, which enumerates an AddInToken collection. 用户从该集合中选择一个令牌以激活相应的外接程序。The user selects a token from this collection to activate the corresponding add-in.

// Method to select a token by 
// enumeratng the AddInToken collection.
private static AddInToken ChooseAddIn(Collection<AddInToken> tokens)
{
    if (tokens.Count == 0)
    {
        Console.WriteLine("No add-ins are available");
        return null;
    }

    Console.WriteLine("Available add-ins: ");

	// Show the token properties for each token 
	// in the AddInToken collection (tokens),
	// preceded by the add-in number in [] brackets.
    int tokNumber = 1;
	foreach (AddInToken tok in tokens)
	{
		Console.WriteLine(String.Format("\t[{0}]: {1} - {2}\n\t{3}\n\t\t {4}\n\t\t {5} - {6}",
			tokNumber.ToString(), 
			tok.Name,
			tok.AddInFullName,
			tok.AssemblyName,
			tok.Description,
			tok.Version,
			tok.Publisher));
        tokNumber++;
	}

    Console.WriteLine("Which calculator do you want to use?");
    String line = Console.ReadLine();
    int selection;
    if (Int32.TryParse(line, out selection))
    {
        if (selection <= tokens.Count)
        {
            return tokens[selection - 1];
        }
    }
    Console.WriteLine("Invalid selection: {0}. Please choose again.", line);
    return ChooseAddIn(tokens);
}
' Method to select a token by 
' enumeratng the AddInToken collection.

Private Shared Function ChooseAddIn(ByVal tokens As System.Collections.ObjectModel.Collection(Of AddInToken)) As AddInToken
    If (tokens.Count = 0) Then
        Console.WriteLine("No add-ins are available")
        Return Nothing
    End If
    Console.WriteLine("Available add-ins: ")
    ' Show the token properties for each token 
    ' in the AddInToken collection (tokens),
    ' preceded by the add-in number in [] brackets.

    Dim tokNumber As Integer = 1
    For Each tok As AddInToken In tokens
        Console.WriteLine(vbTab & "{0}: {1} - {2}" & _
                vbLf & vbTab & "{3}" & _
                vbLf & vbTab & "{4}" & _
                vbLf & vbTab & "{5} - {6}", _
                tokNumber.ToString, tok.Name, _
                tok.AddInFullName, tok.AssemblyName, _
                tok.Description, tok.Version, tok.Publisher)
        tokNumber = tokNumber + 1
    Next
    Console.WriteLine("Which calculator do you want to use?")
    Dim line As String = Console.ReadLine
    Dim selection As Integer
    If Int32.TryParse(line, selection) Then
        If (selection <= tokens.Count) Then
            Return tokens((selection - 1))
        End If
    End If
    Console.WriteLine("Invalid selection: {0}. Please choose again.", line)
    Return ChooseAddIn(tokens)

End Function

注解

AddInToken对象表示可激活的外接程序及其关联的管道段。An AddInToken object represents an add-in, and its associated pipeline segments, that can be activated. 标记包含它所表示的外接程序的名称、程序集名称、说明、发布者和版本。The token contains the name, assembly name, description, publisher, and version of the add-in that it represents.

AddInStore.FindAddIns使用方法获取表示外接程序的标记的集合, 这些外接程序的管道与指定的宿主视图匹配。Use the AddInStore.FindAddIns method to get a collection of tokens that represent add-ins whose pipelines match a specified host view. AddInStore.FindAddIn使用方法获取标记的集合, 该集合表示与指定宿主视图匹配的指定外接程序的所有管道。Use the AddInStore.FindAddIn method to get a collection of tokens that represent all the pipelines for a specified add-in that match a specified host view.

若要激活外接程序, 请将表示所需外接程序的令牌传递给Activate方法。To activate an add-in, pass the token that represents the desired add-in to the Activate method. 此方法返回表示外接程序的宿主视图的类型的实例。This method returns an instance of the type that represents the host view of the add-in.

Activate方法具有多个重载。The Activate method has several overloads. 当你使用不需要应用程序域名称作为其参数之一的重载时, 将自动创建外接程序的新应用程序域。When you use an overload that does not require the name of an application domain as one of its parameters, a new application domain for the add-in is automatically created.

您可以使用语言集成查询 (LINQ) 扩展方法对执行查询AddInToken, 将令牌视为QualificationDataItem结构的集合。You can use Language-Integrated Query (LINQ) extension methods to perform queries on an AddInToken, treating the token as a collection of QualificationDataItem structures.

属性

AddInFullName AddInFullName AddInFullName AddInFullName

获取外接程序的命名空间和类型。Gets the namespace and type of the add-in.

AssemblyName AssemblyName AssemblyName AssemblyName

获取包含外接程序的程序集的名称。Gets the name of the assembly that contains the add-in.

Description Description Description Description

获取外接程序的说明。Gets the description of the add-in.

EnableDirectConnect EnableDirectConnect EnableDirectConnect EnableDirectConnect

获取或设置一个值,该值指示在条件允许时外接程序是否应直接连接到它们的宿主。Gets or sets a value that indicates whether add-ins should be directly connected to their hosts when conditions permit.

Name Name Name Name

获取外接程序的名称。Gets the name of the add-in.

Publisher Publisher Publisher Publisher

获取外接程序的发布者。Gets the publisher of the add-in.

QualificationData QualificationData QualificationData QualificationData

获取与当前标记关联的各个管线段的相关数据的字典。Gets a dictionary of data about the segments in the pipeline associated with the current token.

Version Version Version Version

获取 AddInAttribute 特性中指定的外接程序版本。Gets the version of the add-in, as specified in the AddInAttribute attribute.

方法

Activate<T>(AddInEnvironment) Activate<T>(AddInEnvironment) Activate<T>(AddInEnvironment) Activate<T>(AddInEnvironment)

在另一个外接程序的环境中激活一个外接程序。Activates an add-in in the environment of another add-in.

Activate<T>(AddInProcess, AddInSecurityLevel) Activate<T>(AddInProcess, AddInSecurityLevel) Activate<T>(AddInProcess, AddInSecurityLevel) Activate<T>(AddInProcess, AddInSecurityLevel)

在外部进程中(且在新应用程序域内)激活具有指定信任级别的外接程序。Activates an add-in in an external process, in a new application domain, and with a specified trust level.

Activate<T>(AddInProcess, PermissionSet) Activate<T>(AddInProcess, PermissionSet) Activate<T>(AddInProcess, PermissionSet) Activate<T>(AddInProcess, PermissionSet)

在外部进程中(且在新应用程序域内)激活具有指定权限集的外接程序。Activates an add-in in an external process, in a new application domain, and with a specified permission set.

Activate<T>(AddInSecurityLevel) Activate<T>(AddInSecurityLevel) Activate<T>(AddInSecurityLevel) Activate<T>(AddInSecurityLevel)

在新应用程序域中激活具有指定信任级别的外接程序。Activates an add-in with a specified trust level in a new application domain.

Activate<T>(AddInSecurityLevel, String) Activate<T>(AddInSecurityLevel, String) Activate<T>(AddInSecurityLevel, String) Activate<T>(AddInSecurityLevel, String)

在具有指定名称和信任级别的新应用程序域中激活外接程序。Activates an add-in in a new application domain with a specified name and trust level.

Activate<T>(AppDomain) Activate<T>(AppDomain) Activate<T>(AppDomain) Activate<T>(AppDomain)

在现有应用程序域中激活外接程序。Activates an add-in in an existing application domain.

Activate<T>(PermissionSet) Activate<T>(PermissionSet) Activate<T>(PermissionSet) Activate<T>(PermissionSet)

在新应用程序域中激活具有指定权限集的外接程序。Activates an add-in with a specified permission set in a new application domain.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

确定指定的对象是否等于当前实例。Determines whether a specified object is equal to the current instance.

GetEnumerator() GetEnumerator() GetEnumerator() GetEnumerator()

返回一个与此标记关联的管线段的限定数据枚举数。Returns an enumerator for the qualification data of the pipeline segments that are associated with this token.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

作为标记的哈希函数。Serves as a hash function for a token.

GetType() GetType() GetType() GetType()

获取当前实例的 TypeGets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

返回一个表示标记的字符串。Returns a string that represents the token.

显式界面实现

IEnumerable.GetEnumerator() IEnumerable.GetEnumerator() IEnumerable.GetEnumerator() IEnumerable.GetEnumerator()

返回一个与此标记关联的管线段的限定数据枚举数。Returns an enumerator for the qualification data of the pipeline segments that are associated with this token.

扩展方法

CopyToDataTable<T>(IEnumerable<T>) CopyToDataTable<T>(IEnumerable<T>) CopyToDataTable<T>(IEnumerable<T>) CopyToDataTable<T>(IEnumerable<T>)

在给定其泛型参数 TDataTable 的输入 DataRow 对象的情况下,返回包含 IEnumerable<T> 对象副本的 DataRowReturns a DataTable that contains copies of the DataRow objects, given an input IEnumerable<T> object where the generic parameter T is DataRow.

CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption)

在给定其泛型参数 TDataRow 的输入 DataTable 对象的情况下,将 IEnumerable<T> 对象复制到指定的 DataRowCopies DataRow objects to the specified DataTable, given an input IEnumerable<T> object where the generic parameter T is DataRow.

CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler)

在给定其泛型参数 TDataRow 的输入 DataTable 对象的情况下,将 IEnumerable<T> 对象复制到指定的 DataRowCopies DataRow objects to the specified DataTable, given an input IEnumerable<T> object where the generic parameter T is DataRow.

Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable)

IEnumerable 的元素强制转换为指定的类型。Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable)

根据指定类型筛选 IEnumerable 的元素。Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable)

启用查询的并行化。Enables parallelization of a query.

AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable)

IEnumerable 转换为 IQueryableConverts an IEnumerable to an IQueryable.

Ancestors<T>(IEnumerable<T>) Ancestors<T>(IEnumerable<T>) Ancestors<T>(IEnumerable<T>) Ancestors<T>(IEnumerable<T>)

返回元素集合,其中包含源集合中每个节点的上级。Returns a collection of elements that contains the ancestors of every node in the source collection.

Ancestors<T>(IEnumerable<T>, XName) Ancestors<T>(IEnumerable<T>, XName) Ancestors<T>(IEnumerable<T>, XName) Ancestors<T>(IEnumerable<T>, XName)

返回经过筛选的元素集合,其中包含源集合中每个节点的上级。Returns a filtered collection of elements that contains the ancestors of every node in the source collection. 集合中仅包括具有匹配 XName 的元素。Only elements that have a matching XName are included in the collection.

DescendantNodes<T>(IEnumerable<T>) DescendantNodes<T>(IEnumerable<T>) DescendantNodes<T>(IEnumerable<T>) DescendantNodes<T>(IEnumerable<T>)

返回源集合中每个文档和元素的子代节点的集合。Returns a collection of the descendant nodes of every document and element in the source collection.

Descendants<T>(IEnumerable<T>) Descendants<T>(IEnumerable<T>) Descendants<T>(IEnumerable<T>) Descendants<T>(IEnumerable<T>)

返回元素集合,其中包含源集合中每个元素和文档的子代元素。Returns a collection of elements that contains the descendant elements of every element and document in the source collection.

Descendants<T>(IEnumerable<T>, XName) Descendants<T>(IEnumerable<T>, XName) Descendants<T>(IEnumerable<T>, XName) Descendants<T>(IEnumerable<T>, XName)

返回经过筛选的元素集合,其中包含源集合中每个元素和文档的子代元素。Returns a filtered collection of elements that contains the descendant elements of every element and document in the source collection. 集合中仅包括具有匹配 XName 的元素。Only elements that have a matching XName are included in the collection.

Elements<T>(IEnumerable<T>) Elements<T>(IEnumerable<T>) Elements<T>(IEnumerable<T>) Elements<T>(IEnumerable<T>)

返回源集合中每个元素和文档的子元素的集合。Returns a collection of the child elements of every element and document in the source collection.

Elements<T>(IEnumerable<T>, XName) Elements<T>(IEnumerable<T>, XName) Elements<T>(IEnumerable<T>, XName) Elements<T>(IEnumerable<T>, XName)

返回源集合中经过筛选的每个元素和文档的子元素集合。Returns a filtered collection of the child elements of every element and document in the source collection. 集合中仅包括具有匹配 XName 的元素。Only elements that have a matching XName are included in the collection.

InDocumentOrder<T>(IEnumerable<T>) InDocumentOrder<T>(IEnumerable<T>) InDocumentOrder<T>(IEnumerable<T>) InDocumentOrder<T>(IEnumerable<T>)

返回节点集合(其中包含源集合中的所有节点),并按文档顺序排列。Returns a collection of nodes that contains all nodes in the source collection, sorted in document order.

Nodes<T>(IEnumerable<T>) Nodes<T>(IEnumerable<T>) Nodes<T>(IEnumerable<T>) Nodes<T>(IEnumerable<T>)

返回源集合中每个文档和元素的子节点集合。Returns a collection of the child nodes of every document and element in the source collection.

Remove<T>(IEnumerable<T>) Remove<T>(IEnumerable<T>) Remove<T>(IEnumerable<T>) Remove<T>(IEnumerable<T>)

将源集合中的每个节点从其父节点中移除。Removes every node in the source collection from its parent node.

适用于

另请参阅