本文整理汇总了C#中System.Web.Security.MembershipUserCollection.Add方法的典型用法代码示例。如果您正苦于以下问题:C# MembershipUserCollection.Add方法的具体用法?C# MembershipUserCollection.Add怎么用?C# MembershipUserCollection.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.Security.MembershipUserCollection
的用法示例。
在下文中一共展示了MembershipUserCollection.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Page_PreRender
private void Page_PreRender()
{
MembershipUserCollection allUsers = Membership.GetAllUsers();
MembershipUserCollection filteredUsers = new MembershipUserCollection();
if (UserRoles.SelectedIndex > 0)
{
string[] usersInRole = Roles.GetUsersInRole(UserRoles.SelectedValue);
foreach (MembershipUser user in allUsers)
{
foreach (string userInRole in usersInRole)
{
if (userInRole == user.UserName)
{
filteredUsers.Add(user);
break; // Breaks out of the inner foreach loop to avoid unneeded checking.
}
}
}
}
else
{
filteredUsers = allUsers;
}
Users.DataSource = filteredUsers;
Users.DataBind();
}
示例2: GetMembershipUsers
public virtual MembershipUserCollection GetMembershipUsers(string providerName)
{
MembershipUserCollection muc = new MembershipUserCollection();
foreach (User u in Children)
{
muc.Add(u.GetMembershipUser(providerName));
}
return muc;
}
示例3: GetAllUsers
public override MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords)
{
var col = new MembershipUserCollection();
foreach (MembershipUser user in base.GetAllUsers(pageIndex, pageSize, out totalRecords)) {
col.Add(GetUser(user.UserName, false));
}
return col;
}
示例4: GetHybridMembershipUserCollection
private MembershipUserCollection GetHybridMembershipUserCollection(MembershipUserCollection membershipUserCollection) {
if(membershipUserCollection == null) {
return null;
}
var hybridMembershipUserCollection = new MembershipUserCollection();
foreach(System.Web.Security.MembershipUser membershipUser in membershipUserCollection) {
hybridMembershipUserCollection.Add(GetHybridMembershipUser(membershipUser));
}
return hybridMembershipUserCollection;
}
示例5: CreateCollection
public virtual MembershipUserCollection CreateCollection(IEnumerable<IEntry> entries) {
var users = new MembershipUserCollection();
foreach(var result in entries) {
var user = Create(result);
if(user != null) {
users.Add(user);
}
}
return users;
}
示例6: GetAllUsers
public MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords)
{
var collection = new MembershipUserCollection();
foreach (User user in _userMgr.GetAllUsers())
{
collection.Add(new COATMemebershipUser(user));
}
totalRecords = collection.Count;
return collection;
}
示例7: ToMembershipUserCollection
public static MembershipUserCollection ToMembershipUserCollection(this IEnumerable<User> users)
{
MembershipUserCollection membershipUsers = new MembershipUserCollection();
foreach (User user in users)
{
membershipUsers.Add(user.ToMembershipUser());
}
return membershipUsers;
}
示例8: Show
public ActionResult Show()
{
MembershipUserCollection friendsList = new MembershipUserCollection();
var friends = friendshipRepo.ListAllFriendships((Guid)currentUser.ProviderUserKey);
foreach (var f in friends)
{
MembershipUser theFriend = Membership.GetUser(f.FriendId);
friendsList.Add(theFriend);
}
return View(friendsList);
}
示例9: GetOnlineUsers
/// <summary>
/// Return a MembershipUserCollection of currently online users
/// </summary>
/// <returns></returns>
public static MembershipUserCollection GetOnlineUsers()
{
MembershipUserCollection members = System.Web.Security.Membership.GetAllUsers();
MembershipUserCollection onlineMembers = new MembershipUserCollection();
foreach (MembershipUser user in members)
{
if (user.IsOnline)
onlineMembers.Add(user);
}
return onlineMembers;
}
示例10: GetAllUserWithSelectUser
public static MembershipUserCollection GetAllUserWithSelectUser()
{
MembershipUserCollection misUsuariosConOtro = new MembershipUserCollection();
MembershipUserCollection misUsuarios = Membership.GetAllUsers();
if (misUsuarios == null) return null;
MembershipUser miOtroUsuario = null;
foreach (MembershipUser miUsuario in misUsuarios)
{
miOtroUsuario = new MembershipUser(
miUsuario.ProviderName,
"[Seleccione un usuario...]",
miUsuario.ProviderUserKey,
miUsuario.Email,
miUsuario.PasswordQuestion,
miUsuario.Comment,
miUsuario.IsApproved,
miUsuario.IsLockedOut,
miUsuario.CreationDate,
miUsuario.LastLoginDate,
miUsuario.LastActivityDate,
miUsuario.LastPasswordChangedDate,
miUsuario.LastLockoutDate);
break;
}
misUsuariosConOtro.Add(miOtroUsuario);
foreach (MembershipUser miUsuario in misUsuarios)
{
misUsuariosConOtro.Add(miUsuario);
}
return misUsuariosConOtro;
}
示例11: Page_PreRender
private void Page_PreRender()
{
MembershipUserCollection allUsers = Membership.GetAllUsers();
MembershipUserCollection filteredUsers = new MembershipUserCollection();
bool isLockedOut = true;
foreach (MembershipUser user in allUsers)
{
if (user.IsLockedOut == isLockedOut)
{
filteredUsers.Add(user);
}
}
Users.DataSource = filteredUsers;
Users.DataBind();
}
示例12: FindUsersByPredicate
public static MembershipUserCollection FindUsersByPredicate(this Expression<Func<DataAccess.Login, bool>> predicate, int pageIndex, int pageSize, out int totalRecords)
{
MembershipUserCollection returnValue = new MembershipUserCollection();
totalRecords = 0;
using (var db = new DataAccess.CSSDataContext())
{
var logins = db.Logins.Where(predicate);
totalRecords = logins.Count();
foreach (var login in logins.Skip(pageIndex * pageSize).Take(pageSize))
{
returnValue.Add(MembershipUserUtility.CreateMembershipUserFromLogin(login));
}
}
return returnValue;
}
示例13: GetAllMembershipUsers
public static MembershipUserCollection GetAllMembershipUsers(string PROVIDERNAME, int pageIndex, int pageSize, out int totalRecords)
{
DbEntities entities = new DbEntities();
MembershipUserCollection result = new MembershipUserCollection();
try
{
IQueryable<appusers> listaTotalUsuarios = from users in entities.appusers
select users;
foreach (appusers u in listaTotalUsuarios)
{
result.Add(u.GetMembershipUser(PROVIDERNAME));
}
}
catch (Exception e)
{
throw new Exception(string.Format("MSG:{0}\nINNER:{2}\nSTACK:{1}", e.Message, e.StackTrace, e.InnerException));
}
totalRecords = result.Count;
return result;
}
示例14: Page_PreRender
private void Page_PreRender()
{
MembershipUserCollection allUsers = Membership.GetAllUsers();
MembershipUserCollection filteredUsers = new MembershipUserCollection();
bool isActive;
if (active.SelectedValue == "Active")
{
isActive = true;
}
else
{
isActive = false;
}
foreach (MembershipUser user in allUsers)
{
if (user.IsApproved == isActive)
{
filteredUsers.Add(user);
}
}
Users.DataSource = filteredUsers;
Users.DataBind();
}
示例15: FindUsersByName
public override MembershipUserCollection FindUsersByName(string usernameToMatch, int pageIndex, int pageSize, out int totalRecords)
{
var users = new MembershipUserCollection();
var Db = GetDb();
var q = from u in Db.Users select u;
bool left = usernameToMatch.StartsWith("%");
bool right = usernameToMatch.EndsWith("%");
usernameToMatch = usernameToMatch.Trim('%');
if (left && right)
q = q.Where(u => u.Username.Contains(usernameToMatch));
else if (left)
q = q.Where(u => u.Username.EndsWith(usernameToMatch));
else if (right)
q = q.Where(u => u.Username.StartsWith(usernameToMatch));
totalRecords = q.Count();
q = q.OrderBy(u => u.Username).Skip(pageIndex * pageSize).Take(pageSize);
foreach (var u in q)
users.Add(GetMu(u));
return users;
}