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


C# Roles.ToString方法代码示例

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


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

示例1: BaseModule

        /// <summary>
        /// Constructor for BaseModule
        /// </summary>
        /// <param name="modulePath">The base url for this module.</param>
        /// <param name="secured">Defines whether this module is secured.</param>
        /// <param name="role">Defines whether this module is accessible only to user with the specified role</param>
        protected BaseModule(string modulePath = "", bool secured = false, Roles role = Roles.None)
            : base(modulePath)
        {
            this._Secured = secured;

            // If this module is secured
            if (secured) {
                // Enable authentication check
                this.RequiresAuthentication ();
            }

            // If this module requires a specific role
            if (role != Roles.None) {
                // Enable role check
                this.RequiresClaims (new [] { role.ToString () });
            }

            //this.
        }
开发者ID:qginformatique,项目名称:GMATechProject,代码行数:25,代码来源:BaseModule.cs

示例2: IsUserInRole

	public bool IsUserInRole(Roles role)
    {
        if (UserName != "")
        {
            DataTable obj = SqlHelper.ExecuteAdapter("user_IsUserInRole", new SqlParameter[] { new SqlParameter("@UserName", UserName), new SqlParameter("@RoleName", role.ToString()) }, CommandType.StoredProcedure);
            if (obj.Rows.Count > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        else
        {
            return false;
        }
    }
开发者ID:smartabbas,项目名称:governmentvideo.com,代码行数:19,代码来源:CustomRedirects.aspx.cs

示例3: BaseModule

        /// <summary>
        /// Initializes a new instance of <see cref="BaseModule"/>
        /// </summary>
        /// <param name="modulePath">The base url for this module.</param>
        /// <param name="secured">Defines whether this module is secured.</param>
        /// <param name="role">Defines whether this module is accessible only to user with the specified role</param>
        protected BaseModule(IApplication application, string modulePath = "", bool secured = false, Roles role = Roles.None)
            : base(modulePath)
        {
            this._Application = application;
            this._Secured = secured;

            // If this module is secured
            if(secured){
                // Enable authentication check
                this.RequiresAuthentication();

                // If this module requires a specific role
                if(role != Roles.None){
                    // Enable role check
                    this.RequiresClaims(new [] { role.ToString() });
                }
            }

            // Initialize the main application logger
            this._Logger = LogManager.GetLogger("WebApplicationLogger");

            // Before every requests, call the ProtectAgainstCrossScriptingAttacks method
            this.Before += ProtectAgainstCrossScriptingAttacks;
        }
开发者ID:qginformatique,项目名称:GMATechProject,代码行数:30,代码来源:BaseModule.cs

示例4: IsUserInRole

        public async Task<bool> IsUserInRole(string userId, Roles role)
        {

            return await UserManager.IsInRoleAsync(userId, role.ToString());
        }
开发者ID:uaddevelopment,项目名称:INF,代码行数:5,代码来源:AuthRepository.cs

示例5: changeRole

        internal static void changeRole(Account account, Roles role)
        {
            if (account.Login.Equals("admin")) throw new Exception("Невозможно изменить группу");

            account.Role = role;
            DataHelper.UpdateAccount(account);
            DataHelper.logAction(Actions.EditUser, "Группа изменена: " + account.Login + " -> " + role.ToString());
        }
开发者ID:ryazantsevanton,项目名称:Rossapn_newdesign,代码行数:8,代码来源:Account.cs

示例6: Role

		/// <summary>
		/// Construct instance representing the given Roles enumeration value.
		/// </summary>
		public Role( Roles role ) : this( (int) role, role.ToString() )
		{
		}
开发者ID:arangas,项目名称:MediaPortal-1,代码行数:6,代码来源:Role.cs

示例7: RequiresCredentials

 public static bool RequiresCredentials(Roles requiredRole, Action callback)
 {
     if (IsLoggingIn)
     {
         CurrentRequiredAuthenticationContext.Add(new RequiresAuthenticationOrAuthorizationMessage(true, requiredRole.ToString(), callback));
         return false;
     }
     IsLoggingIn = true;
     if ((AuthenticationLoggedInPerson == null) || (AuthenticationLoggedInPerson.PersonID == 0))
     {
         CurrentRequiredAuthenticationContext = new List<IRequiresAuthenticationOrAuthorizationMessage>();
         CurrentRequiredAuthenticationContext.Add(new RequiresAuthenticationOrAuthorizationMessage(true, requiredRole.ToString(), callback));
         ApplicationMessages.RequiresAuthenticationOrAuthorization.Send(true, requiredRole.ToString(), callback);
         return false;
     }
     if (CheckRoleForRights(AuthenticationLoggedInPerson.PersonTypeID, requiredRole))
     {
         IsLoggingIn = false;
         return true;
     }
     CurrentRequiredAuthenticationContext = new List<IRequiresAuthenticationOrAuthorizationMessage>();
     CurrentRequiredAuthenticationContext.Add(new RequiresAuthenticationOrAuthorizationMessage(true, requiredRole.ToString(), callback));
     ApplicationMessages.RequiresAuthenticationOrAuthorization.Send(true, requiredRole.ToString(), callback);
     return false;
 }
开发者ID:Attention,项目名称:NitpickHouseV2,代码行数:25,代码来源:LocalStateContainer.cs


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