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


C# User.IsInRole方法代码示例

本文整理汇总了C#中User.IsInRole方法的典型用法代码示例。如果您正苦于以下问题:C# User.IsInRole方法的具体用法?C# User.IsInRole怎么用?C# User.IsInRole使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在User的用法示例。


在下文中一共展示了User.IsInRole方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FillField

        public override string FillField(BaseDataMap map, object importRow,
            ref User user,
            string importValue,
            out bool updatedField)
        {
            updatedField = false;
            var errorMessage = String.Empty;
            var shouldBeMemberOfRole = !String.IsNullOrEmpty(importValue) &&
                                       importValue.Trim() == TrueValue;
            var role = InitializeRoleFromString(RoleName, ref errorMessage);
            if (role != null)
            {
                if (!user.IsInRole(role) && shouldBeMemberOfRole)
                {
                    user.Roles.Add(role);
                    updatedField = true;
                }
                else if (user.IsInRole(role) && !shouldBeMemberOfRole)
                {
                    user.Roles.Remove(role);
                    updatedField = true;

                }
            }
            return errorMessage;
        }
开发者ID:NetlabSharedSource,项目名称:SitecoreUserSync,代码行数:26,代码来源:ToRoleMembership.cs

示例2: CreateIndexViewModel

 private DashboardViewModel CreateIndexViewModel(User user, Team team, IRepository repository)
 {
     var model = new DashboardViewModel();
       model.UserIsAdmin = user.IsInRole(Roles.Administrators);
       model.UserFullName = user.FullName;
       model.SkillLevelCalculation = new SkillLevelCalculationViewModel(user, repository);
       if (null != team) {
     model.CurrentSeasonStats = GetCurrentSeasonStatsViewModel(user, team);
     model.HasCurrentSeasonStats = model.CurrentSeasonStats != null;
     model.LastMeetStats = GetLastMeetStats(user, team);
     model.HasLastMeetStats = model.LastMeetStats != null;
     model.SeasonResults = GetSeasonResults(user, team);
     model.HasSeasonResults = model.SeasonResults != null;
       }
       return model;
 }
开发者ID:pwideman,项目名称:ClubPool,代码行数:16,代码来源:DashboardController.cs

示例3: IsInRole_is_always_false

 public void IsInRole_is_always_false()
 {
     user = new Guest();
     user.IsInRole("anything").Should().BeFalse();
 }
开发者ID:jarrettmeyer,项目名称:portfolio-mvc,代码行数:5,代码来源:Guest_Tests.cs

示例4: AddUserToStandardRoles

 protected virtual void AddUserToStandardRoles(User user, object importRow)
 {
     // Add standardroles
     foreach (var role in AddUserToWhatStandardRoles)
     {
         if (!user.IsInRole(role))
         {
             user.Roles.Add(role);
         }
     }
 }
开发者ID:NetlabSharedSource,项目名称:SitecoreUserSync,代码行数:11,代码来源:BaseDataMap.cs

示例5: UpdateRolesOnUser

 protected virtual bool UpdateRolesOnUser(User user, object importRow)
 {
     bool updatedRoles = false;
     // Change roles membership
     foreach (var role in OnPresentInImportAddToRoles)
     {
         if (!user.IsInRole(role))
         {
             user.Roles.Add(role);
             updatedRoles = true;
         }
     }
     foreach (var role in OnPresentInImportRemoveFromRoles)
     {
         if (user.IsInRole(role))
         {
             user.Roles.Remove(role);
             updatedRoles = true;
         }
     }
     return updatedRoles;
 }
开发者ID:NetlabSharedSource,项目名称:SitecoreUserSync,代码行数:22,代码来源:BaseDataMap.cs

示例6: ProcessUserNotPresentInImport

 protected virtual void ProcessUserNotPresentInImport(User user, ref string errorMessage)
 {
     if (user != null)
     {
         foreach (var role in OnNotPresentInImportAddToRoles)
         {
             if (!user.IsInRole(role))
             {
                 user.Roles.Add(role);
             }
         }
         foreach (var role in OnNotPresentInImportRemoveFromRoles)
         {
             if (user.IsInRole(role))
             {
                 user.Roles.Remove(role);
             }
         }
         if (IsDeleteUsersWithMembershipInStandardRolesOnly)
         {
             DeleteUsersWithMembershipInStandardRolesOnly(user, ref errorMessage);
         }
     }
     else
     {
         errorMessage +=
             String.Format(
                 "The user was null. Therefore the ProcessUserNotPresentInImport method could not be completed.");
     }
 }
开发者ID:NetlabSharedSource,项目名称:SitecoreUserSync,代码行数:30,代码来源:BaseDataMap.cs

示例7: IsInRole_returns_true

 public void IsInRole_returns_true()
 {
     user = new User();
     user.IsInRole("anything").Should().BeTrue();
 }
开发者ID:jarrettmeyer,项目名称:portfolio-mvc,代码行数:5,代码来源:User_Tests.cs

示例8: UserCanEnterMatchResults

 public virtual bool UserCanEnterMatchResults(User user)
 {
     if (null == user) {
     return false;
       }
       // first check to see if this user is a member of the teams in the meet
       if (Teams.Where(t => t.Players.Contains(user)).Any()) {
     return true;
       }
       // next, check for role access
       if (user.IsInRole(Roles.Administrators) ||
       user.IsInRole(Roles.Officers)) {
     return true;
       }
       // if we haven't met any of these criteria, return false
       return false;
 }
开发者ID:pwideman,项目名称:ClubPool,代码行数:17,代码来源:Meet.cs


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