ClaimsIdentity.FindFirst 方法

定义

检索与指定的条件匹配的第一个声明。Retrieves the first claim that matches a specified condition.

重载

FindFirst(Predicate<Claim>)

检所由指定谓词匹配的第一个声明。Retrieves the first claim that is matched by the specified predicate.

FindFirst(String)

检索有指定声明类型的第一个声明。Retrieves the first claim with the specified claim type.

FindFirst(Predicate<Claim>)

检所由指定谓词匹配的第一个声明。Retrieves the first claim that is matched by the specified predicate.

public:
 virtual System::Security::Claims::Claim ^ FindFirst(Predicate<System::Security::Claims::Claim ^> ^ match);
public virtual System.Security.Claims.Claim FindFirst (Predicate<System.Security.Claims.Claim> match);
public virtual System.Security.Claims.Claim? FindFirst (Predicate<System.Security.Claims.Claim> match);
abstract member FindFirst : Predicate<System.Security.Claims.Claim> -> System.Security.Claims.Claim
override this.FindFirst : Predicate<System.Security.Claims.Claim> -> System.Security.Claims.Claim
Public Overridable Function FindFirst (match As Predicate(Of Claim)) As Claim

参数

match
Predicate<Claim>

执行匹配逻辑的函数。The function that performs the matching logic.

返回

Claim

为第一个匹配声明,或者,如果找不到任何匹配,则为 nullThe first matching claim or null if no match is found.

例外

matchnullmatch is null.

适用于

FindFirst(String)

检索有指定声明类型的第一个声明。Retrieves the first claim with the specified claim type.

public:
 virtual System::Security::Claims::Claim ^ FindFirst(System::String ^ type);
public virtual System.Security.Claims.Claim FindFirst (string type);
public virtual System.Security.Claims.Claim? FindFirst (string type);
abstract member FindFirst : string -> System.Security.Claims.Claim
override this.FindFirst : string -> System.Security.Claims.Claim
Public Overridable Function FindFirst (type As String) As Claim

参数

type
String

要匹配的声明类型。The claim type to match.

返回

Claim

为第一个匹配声明,或者,如果找不到任何匹配,则为 nullThe first matching claim or null if no match is found.

例外

typenulltype is null.

注解

比较是在 StringComparison.OrdinalIgnoreCase 模式下完成的。The comparison is done in StringComparison.OrdinalIgnoreCase mode.

适用于