本文整理汇总了C#中Permission.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Permission.ToString方法的具体用法?C# Permission.ToString怎么用?C# Permission.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Permission
的用法示例。
在下文中一共展示了Permission.ToString方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPermissionString
public static string GetPermissionString(Permission permission)
{
string result = null;
if (permission == Permission.Security)
result = "Security";
else if (permission == Permission.Data)
result = "Data";
else result = permission.ToString();
return result;
}
示例2: PermissionStorageView
/// <summary>
/// PermissionStorageView constructor.
/// </summary>
/// <param name="perm"></param>
public PermissionStorageView(Permission perm)
{
m_prmId = (Int32)perm;
m_prmname = perm.ToString();
}
示例3: PermissionStorageView
/// <summary>
/// PermissionStorageView constructor.
/// </summary>
/// <param name="perm"></param>
public PermissionStorageView(Permission perm)
{
_permissionId = (int)perm;
_permissionName = perm.ToString();
}
示例4: myMenuItemCreatePermission_Click
void myMenuItemCreatePermission_Click(object sender, EventArgs e)
{
Permission permission = new Permission();
permission.Id = "Here is your permission Id";
permission.PermissionMode = PermissionMode.Read;
permission.ResourceLink = "your resource link";
string x = permission.ToString();
Program.GetMain().SetCrudContext(this, OperationType.Create, ResourceType.Permission, x, this.CreatePermissionAsync);
}
示例5: IsAuthorized
public bool IsAuthorized(IPrincipal user, Permission permission)
{
return user.Identity.Name == permission.ToString();
}
示例6: EnsurePermission
//-----------------------------------------------------------------------------------------------
/// <summary>
/// Check if the permission was set
///
/// </summary>
/// <param name="sc"></param>
/// <param name="perm"></param>
protected void EnsurePermission(SecurityCredentials sc, Permission perm)
{
bool result = ManagerStorageFactory.ManagerStorage().CheckPermission(sc, perm);
if (!result)
{
logger.Debug("User"+sc.Username+" doesnt have permission "+perm.ToString());
throw new AuthorizationException(
string.Format("User '{0}' is not associated with permission '{1}'", sc.Username, perm.ToString()),
null
);
}
}
示例7: Authenticate
public string Authenticate(Permission permission)
{
return (this as IAuthRepository).CreateAuthTokenIfNecessary(permission.ToString(), true).Id;
}
示例8: InsertUserDocument
/// <summary>
/// Inserts a userdocument in the database
/// </summary>
/// <param name="user">user "end" of userdocument relation</param>
/// <param name="docID">document "end" of userdocument relation</param>
/// <param name="permission">relation type, what level of authentication the user has to the specified document</param>
public void InsertUserDocument(User user, int docID, Permission.Permissions permission)
{
string query = "INSERT INTO userdocument (userID, documentID, permission) VALUES('" + user.id + "', '" + docID + "', '" + permission.ToString() +"')";
ExecuteQuery(query);
}
示例9: ObtainPermissionAsync
public Task<PermissionStatus> ObtainPermissionAsync(Permission permission)
{
return Task.Run(async () =>
{
string rationale = null;
if (permission == Permission.Camera)
rationale = "Sensus uses the camera to scan participation barcodes. Sensus will not record images or video.";
else if (permission == Permission.Location)
rationale = "Sensus uses GPS to collect location information for studies you have enrolled in.";
else if (permission == Permission.Microphone)
rationale = "Sensus uses the microphone to collect sound level information for studies you have enrolled in. Sensus will not record audio.";
else if (permission == Permission.Phone)
rationale = "Sensus monitors telephone call metadata for studies you have enrolled in. Sensus will not record audio from calls.";
else if (permission == Permission.Sensors)
rationale = "Sensus uses movement sensors to collect various types of information for studies you have enrolled in.";
else if (permission == Permission.Storage)
rationale = "Sensus must be able to write to your device's storage for proper operation. Please grant this permission.";
if (await CrossPermissions.Current.CheckPermissionStatusAsync(permission) == PermissionStatus.Granted)
return PermissionStatus.Granted;
else
{
// the Permissions plugin requires a main activity to be present on android. ensure this below.
BringToForeground();
if (rationale != null && await CrossPermissions.Current.ShouldShowRequestPermissionRationaleAsync(permission))
{
ManualResetEvent rationaleDialogWait = new ManualResetEvent(false);
Device.BeginInvokeOnMainThread(async () =>
{
await (App.Current as App).ProtocolsPage.DisplayAlert("Permission Request", "On the next screen, Sensus will request access to your device's " + permission.ToString().ToUpper() + ". " + rationale, "OK");
rationaleDialogWait.Set();
});
rationaleDialogWait.WaitOne();
}
return (await CrossPermissions.Current.RequestPermissionsAsync(new Permission[] { permission }))[permission];
}
});
}
示例10: HasPermission
public static bool HasPermission(this IPrincipal principal, Permission permission)
{
return principal.IsInRole(permission.ToString());
}