本文整理汇总了C#中DotNetOpenAuth.OpenId.RelyingParty.OpenIdRelyingParty.FilterEndpoint方法的典型用法代码示例。如果您正苦于以下问题:C# OpenIdRelyingParty.FilterEndpoint方法的具体用法?C# OpenIdRelyingParty.FilterEndpoint怎么用?C# OpenIdRelyingParty.FilterEndpoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DotNetOpenAuth.OpenId.RelyingParty.OpenIdRelyingParty
的用法示例。
在下文中一共展示了OpenIdRelyingParty.FilterEndpoint方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FilterAndSortEndpoints
/// <summary>
/// Returns a filtered and sorted list of the available OP endpoints for a discovered Identifier.
/// </summary>
/// <param name="endpoints">The endpoints.</param>
/// <param name="relyingParty">The relying party.</param>
/// <returns>A filtered and sorted list of endpoints; may be empty if the input was empty or the filter removed all endpoints.</returns>
private static List<IdentifierDiscoveryResult> FilterAndSortEndpoints(IEnumerable<IdentifierDiscoveryResult> endpoints, OpenIdRelyingParty relyingParty) {
Requires.NotNull(endpoints, "endpoints");
Requires.NotNull(relyingParty, "relyingParty");
bool anyFilteredOut = false;
var filteredEndpoints = new List<IdentifierDiscoveryResult>();
foreach (var endpoint in endpoints) {
if (relyingParty.FilterEndpoint(endpoint)) {
filteredEndpoints.Add(endpoint);
} else {
anyFilteredOut = true;
}
}
// Sort endpoints so that the first one in the list is the most preferred one.
filteredEndpoints.OrderBy(ep => ep, relyingParty.EndpointOrder);
var endpointList = new List<IdentifierDiscoveryResult>(filteredEndpoints.Count);
foreach (var endpoint in filteredEndpoints) {
endpointList.Add(endpoint);
}
if (anyFilteredOut) {
Logger.Yadis.DebugFormat("Some endpoints were filtered out. Total endpoints remaining: {0}", filteredEndpoints.Count);
}
if (Logger.Yadis.IsDebugEnabled) {
if (MessagingUtilities.AreEquivalent(endpoints, endpointList)) {
Logger.Yadis.Debug("Filtering and sorting of endpoints did not affect the list.");
} else {
Logger.Yadis.Debug("After filtering and sorting service endpoints, this is the new prioritized list:");
Logger.Yadis.Debug(Util.ToStringDeferred(filteredEndpoints, true));
}
}
return endpointList;
}