本文整理汇总了C#中Permissions.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Permissions.ToString方法的具体用法?C# Permissions.ToString怎么用?C# Permissions.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Permissions
的用法示例。
在下文中一共展示了Permissions.ToString方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Verify_Convert
static void Verify_Convert(Permissions requiredPermission, Permissions userPermissions, Visibility expected)
{
//------------Setup for test--------------------------
var converter = new NavigationViewModelPermissionVisibilityConverter();
//------------Execute Test---------------------------
var actual = converter.Convert(userPermissions, typeof(Visibility), requiredPermission.ToString(), CultureInfo.CurrentCulture);
//------------Assert Results-------------------------
Assert.AreEqual(expected, actual);
}
开发者ID:NatashaSchutte,项目名称:Warewolf-ESB,代码行数:11,代码来源:NavigationViewModelPermissionVisibilityConverterTests.cs
示例2: GetTasks
/// <summary>Get the tasks for selected <see cref="Permissions"/>.</summary>
/// <param name="permissions">The permissions to get the tasks for.</param>
/// <returns>Returns a list of tasks for the <paramref name="permissions" />.</returns>
public List<string> GetTasks(Permissions permissions)
{
string key = String.Format("Section-Tasks-{0}--{1}", this.Identity, permissions.ToString());
// checks to see if the tasks have been cached for these permissions
// this is nessisary because this opperation is a potentially
// intensive operation
if (Common.Cache.IsCached(key) == false) {
List<string> tlist = new List<string>();
// add the view page task if it has the permissions
// this is default for all sections
ConfigurationTask viewPage = ConfigurationTask.ViewPageTask;
if (viewPage.CheckAccess(permissions))
tlist.Add(viewPage.Name);
// go through each task and check the access
foreach (ConfigurationTask task in this.Module.Config.Tasks) {
if (task.CheckAccess(permissions))
tlist.Add(task.Name);
}
// add to cache
Common.Cache.Add(key, tlist);
}
List<string> list = Common.Cache[key] as List<string>;
// if it has no tasks is null then no tasks are returned
return (list != null) ? list : new List<string>();
}
示例3: CheckPermission
private bool CheckPermission( Permissions prm,
User.User _user,
ref string answer_msg )
{
AccessFile.ReadAccessFile( acc_object, _user );
if ( !(acc_object is DataBase || acc_object is DataContainer) ) {
answer_msg = " This object must be a Database or a DataContainer! ";
return false;
}
var user_level = ( acc_object as IStructureAccess ).GetLevel( _user );
foreach ( var acc in accesses ) {
if ( acc.User.Credentials.Login == _user.Credentials.Login ) {
if ( prm == Permissions.CREATE_SUBS ) {
answer_msg = prm.ToString() + " - OK!";
return true;
}
if ( prm == Permissions.WRITE ) {
if ( user_level == Access.AccessLevel.ADMIN ||
user_level == Access.AccessLevel.READ_WRITE ||
user_level == Access.AccessLevel.READ_WRITE_DROP )
{
answer_msg = prm.ToString() + " - OK!";
return true;
}
} else if ( prm == Permissions.READ ) {
if ( user_level == Access.AccessLevel.ADMIN ||
user_level == Access.AccessLevel.READ_WRITE ||
user_level == Access.AccessLevel.READ_WRITE_DROP ||
user_level == Access.AccessLevel.READ_ONLY )
{
answer_msg = prm.ToString() + " - OK!";
return true;
}
} else if ( prm == Permissions.DROP ) {
if ( user_level == Access.AccessLevel.ADMIN ||
user_level == Access.AccessLevel.READ_WRITE_DROP )
{
answer_msg = prm.ToString() + " - OK!";
return true;
}
} else if ( prm == Permissions.DELETE ) {
if ( user_level == Access.AccessLevel.ADMIN ||
user_level == Access.AccessLevel.READ_WRITE ||
user_level == Access.AccessLevel.READ_WRITE_DROP )
{
answer_msg = prm.ToString() + " - OK!";
return true;
}
}
}
}
answer_msg = " Access denied for user: "+_user.Credentials.Login +
". You don't have a \""+prm.ToString()+"\" access! ";
return false;
}
示例4: NoAccessMessage
internal void NoAccessMessage( Permissions permission )
{
Message( Color.Red, "You do not have access to this command." );
Message( Color.Red, "You need " + permission.ToString() + " permission." );
}
示例5: GetRoles
/// <summary>Get the roles for selected permissions.</summary>
/// <param name="permissions">The permissions to get the roles for.</param>
/// <returns>Returns a list of roles for the <paramref name="permissions">permissions</paramref>.</returns>
public List<string> GetRoles(Permissions permissions)
{
string key = String.Format("Portlet-Roles-{0}--{1}", this.Identity, permissions.ToString());
// checks to see if the roles have been cached for these permissions
// this is nessisary because RolesDictionary.GetRoles is a potentially
// intensive operation
if (Common.Cache.IsCached(key) == false) {
List<string> rlist = this.Roles.GetRoles(permissions.ToString().Replace(", ", Common.Delimiter.ToString()).Split(Common.Delimiter));
// add to cache
Common.Cache.Add(key, rlist);
}
List<string> list = Common.Cache[key] as List<string>;
// if it has no tasks is null then no tasks are returned
return (list != null) ? list : new List<string>();
}
示例6: UpdateRoleForPortlet
public override void UpdateRoleForPortlet(string role, Permissions permissions, PortletInfo portlet)
{
Common.DatabaseProvider.UpdateRoleForPortlet(role, permissions.ToString().Replace(", ", Common.Delimiter.ToString()).Split(Common.Delimiter), portlet);
}