本文整理汇总了C#中System.Web.Security.MembershipUserCollection.OfType方法的典型用法代码示例。如果您正苦于以下问题:C# MembershipUserCollection.OfType方法的具体用法?C# MembershipUserCollection.OfType怎么用?C# MembershipUserCollection.OfType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.Security.MembershipUserCollection
的用法示例。
在下文中一共展示了MembershipUserCollection.OfType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PaginateUserCollection
protected MembershipUserCollection PaginateUserCollection(MembershipUserCollection source, int pageIndex,
int pageSize, out int totalRecords)
{
_logger.Debug(d => d("PaginateUserCollection(MembershipUserCollection, {0}, {1}, out int)", pageIndex, pageSize));
totalRecords = source.Count;
if (pageSize < 0) throw new ArgumentException("The page size cannot be less than zero.");
if (pageSize == 0) return source;
_logger.Debug(d => d("The MembershipUserCollection source contains {0} record(s).", source.Count));
if (totalRecords > pageSize)
{
var firstRecord = pageIndex * pageSize;
var newCollection = new MembershipUserCollection();
foreach (var user in source.OfType<MembershipUser>().Skip(firstRecord).Take(pageSize))
{
newCollection.Add(user);
}
_logger.Debug(d => d("The returning MembershipUserCollection contains {0} record(s).", newCollection.Count));
return newCollection;
}
return source;
}