当前位置: 首页>>代码示例>>C#>>正文


C# OpenIdRelyingParty.FilterEndpoint方法代码示例

本文整理汇总了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;
		}
开发者ID:natuangloops,项目名称:DotNetOpenAuth,代码行数:42,代码来源:AuthenticationRequest.cs


注:本文中的DotNetOpenAuth.OpenId.RelyingParty.OpenIdRelyingParty.FilterEndpoint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。