本文整理汇总了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.
}
示例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;
}
}
示例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;
}
示例4: IsUserInRole
public async Task<bool> IsUserInRole(string userId, Roles role)
{
return await UserManager.IsInRoleAsync(userId, role.ToString());
}
示例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());
}
示例6: Role
/// <summary>
/// Construct instance representing the given Roles enumeration value.
/// </summary>
public Role( Roles role ) : this( (int) role, role.ToString() )
{
}
示例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;
}