本文整理汇总了C#中Permissions类的典型用法代码示例。如果您正苦于以下问题:C# Permissions类的具体用法?C# Permissions怎么用?C# Permissions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Permissions类属于命名空间,在下文中一共展示了Permissions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: changeConfigFolder
public static bool changeConfigFolder(Window parent, ASettings settings, string setting_name,
string description, string error_message, Permissions required_permissions) {
string old_path = settings.get(setting_name);
string new_path = null;
System.Windows.Forms.FolderBrowserDialog folderBrowser = new System.Windows.Forms.FolderBrowserDialog();
folderBrowser.ShowNewFolderButton = true;
folderBrowser.Description = description;
folderBrowser.SelectedPath = old_path;
bool try_again = false;
do {
if (folderBrowser.ShowDialog(GetIWin32Window(parent)) == System.Windows.Forms.DialogResult.OK) {
new_path = folderBrowser.SelectedPath;
if (PermissionsHelper.isReadable(new_path)) {
if (required_permissions < Permissions.Write
||PermissionsHelper.isWritable(new_path)) {
settings.set(setting_name, new_path);
return new_path != old_path;
} else {
folderBrowser.Description = error_message;
try_again = true;
}
} else {
folderBrowser.Description = error_message;
try_again = true;
}
} else {
try_again = false;
}
} while (try_again);
return false;
}
示例2: GetString
/// <summary>
/// Converts Permission to string.
/// </summary>
/// <param name="permission">Permission to convert.</param>
/// <returns>String describing permission.</returns>
public static string GetString(Permissions permission)
{
string value = "";
switch (permission)
{
case Permissions.CreateData:
value = "create_data";
break;
case Permissions.ReadData:
value = "read_data";
break;
case Permissions.ReadOwnData:
value = "read_own_data";
break;
case Permissions.UpdateData:
value = "update_data";
break;
case Permissions.UpdateOwnData:
value = "update_own_data";
break;
case Permissions.DeleteData:
value = "delete_data";
break;
case Permissions.DeleteOwnData:
value = "delete_own_data";
break;
}
return value;
}
示例3: GetAuthenticationUrl
public static string GetAuthenticationUrl(string apiKey, string sharedSecret, string frob, Permissions Permissions)
{
var authParams = new Dictionary<string, string>();
authParams.Add("api_key", apiKey);
authParams.Add("perms", "delete");
authParams.Add("frob", frob);
authParams.Add("api_sig", SignArguments(sharedSecret, authParams));
return CreateUrl(Constants.AuthorizationUrl, authParams);
}
示例4: PortletAdminAttribute
/// <summary>Creates a new admin module attribute for an admin module.</summary>
/// <param name="location">Location a URL should point to find module.</param>
/// <param name="title">Title of module.</param>
/// <param name="description">Description of module.</param>
public PortletAdminAttribute(string location, string title, string description, Permissions permissions)
: base(title, description, permissions)
{
// checks to see if location is set
if (location == null || location.Length == 0)
throw new ArgumentException("Location needs to be set for PortletAdminAttribute. Cannot be String.Empty or null.", "folderName");
this._location = location;
}
示例5: Authorize
/// <summary>
/// Adds container-level permission to specified User API client. Requires Backend API key with Admin permission role.
/// </summary>
/// <param name="apiClientId">User API client id.</param>
/// <param name="permission">User API client's permission to add.</param>
/// <param name="projectId">Project id defining project that permission will be added to.</param>
/// <returns>Boolen value indicating success of method.</returns>
public Task<bool> Authorize(string apiClientId, Permissions permission, string projectId)
{
if(apiClientId == null || projectId == null)
throw new ArgumentNullException();
string permissionString = PermissionsParser.GetString(permission);
return _syncanoClient.GetAsync("project.authorize",
new {api_client_id = apiClientId, permission = permissionString, project_id = projectId});
}
示例6: GetPerm
///<summary>Gets a GroupPermission based on the supplied userGroupNum and permType. If not found, then it returns null. Used in FormSecurity when double clicking on a dated permission or when clicking the all button.</summary>
public static GroupPermission GetPerm(long userGroupNum,Permissions permType) {
//No need to check RemotingRole; no call to db.
for(int i=0;i<GroupPermissionC.List.Length;i++){
if(GroupPermissionC.List[i].UserGroupNum==userGroupNum && GroupPermissionC.List[i].PermType==permType){
return GroupPermissionC.List[i].Copy();
}
}
return null;
}
示例7: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
if (!this.Page.IsPostBack)
{
this.id = base.Request.Params["id"];
if ((this.id == null) || (this.id.Trim() == ""))
{
base.Response.Redirect("treelist.aspx?TreeType=" + this.TreeType);
base.Response.End();
}
SysTree tree = new SysTree();
SysNode node = tree.GetNode(int.Parse(this.id));
this.lblID.Text = this.id;
this.lblOrderid.Text = node.OrderID.ToString();
this.lblName.Text = node.TreeText;
if (node.ParentID == 0)
{
this.lblTarget.Text = Site.lblRootDirectory;
}
else
{
this.lblTarget.Text = tree.GetNode(node.ParentID).TreeText;
}
this.lblUrl.Text = node.Url;
this.Image1.ImageUrl = node.ImageUrl;
Permissions permissions = new Permissions();
if (node.PermissionID == -1)
{
this.lblPermission.Text = SysManage.lblPermissionText;
}
else
{
this.lblPermission.Text = permissions.GetPermissionName(node.PermissionID);
}
switch (node.TreeType)
{
case 0:
this.lblTreeType.Text = SysManage.dropBackendSystem;
break;
case 1:
this.lblTreeType.Text = SysManage.dropBackendEnterprise;
break;
case 2:
this.lblTreeType.Text = SysManage.dropBackendAgent;
break;
case 3:
this.lblTreeType.Text = SysManage.dropBackendUser;
break;
}
this.lblEnable.Text = node.Enabled ? SysManage.lblEnableTrue : SysManage.lblEnableFalse;
this.lblDescription.Text = node.Comment;
}
}
示例8: InjectDependencies
private void InjectDependencies()
{
this.Projects = new Projects(_httpWorker);
this.Repositories = new Repositories(_httpWorker);
this.Branches = new Branches(_httpWorker);
this.Commits = new Commits(_httpWorker);
this.PullRequests = new PullRequests(_httpWorker);
Permissions = new Permissions(_httpWorker);
RepoPermissions = new RepoPermissions(_httpWorker);
}
示例9: ServerExplorerItem
public ServerExplorerItem(string displayName, Guid resourceId, ResourceType resourceType,
IList<IExplorerItem> children, Permissions permissions, string resourcePath)
{
DisplayName = displayName;
ResourceId = resourceId;
ResourceType = resourceType;
Children = children;
Permissions = permissions;
ResourcePath = resourcePath;
}
示例10: FetchPeopleWithASpecificPermission
public IEnumerable<Person> FetchPeopleWithASpecificPermission(Permissions permission, int churchId)
{
var permissionInt = (int) permission;
return from pc in Context.PersonChurches
join pr in Context.PermissionRoles
on pc.RoleId equals pr.RoleId
where pr.PermissionId == permissionInt
&& pc.ChurchId == churchId
select pc.Person;
}
示例11: HasPermission
public static bool HasPermission( Permissions needed , User user )
{
if ( user != null )
{
return GetPermissions( user ) >= needed;
}
else
{
return true;
}
}
示例12: MakeLogEntry
///<summary>PatNum can be 0.</summary>
public static void MakeLogEntry(Permissions permType,long patNum,string logText)
{
//No need to check RemotingRole; no call to db.
SecurityLog securityLog=new SecurityLog();
securityLog.PermType=permType;
securityLog.UserNum=Security.CurUser.UserNum;
securityLog.LogText=logText;//"From: "+Environment.MachineName+" - "+logText;
securityLog.CompName=Environment.MachineName;
securityLog.PatNum=patNum;
SecurityLogs.Insert(securityLog);
}
示例13: Get
public List<Permission> Get(Permissions role)
{
var entities = new List<PermissionEntity>();
entities = GenericRepository.GetList<PermissionEntity>(AuthAdminDatabase, PermissionsCollection);
if (entities == null)
return null;
return entities.TranslateToResponse();
}
示例14: UserHasPermission
public static bool UserHasPermission(string module, Permissions permission)
{
if (HttpContext.Current.Session["isAdmin"] != null)
{
return true;
}
List<ModulePermission> permissions = GetModulePermissionsFromSession();
return permissions.Exists(e => e.Module == module && e.Permission == permission);
}
示例15: IsAuthorized
///<summary>Checks to see if current user is authorized. It also checks any date restrictions. If not authorized, it gives a Message box saying so and returns false.</summary>
public static bool IsAuthorized(Permissions perm,DateTime date,bool suppressMessage){
//No need to check RemotingRole; no call to db.
if(Security.CurUser==null) {
if(!suppressMessage) {
MessageBox.Show(Lans.g("Security","Not authorized for")+"\r\n"+GroupPermissions.GetDesc(perm));
}
return false;
}
try {
return IsAuthorized(perm,date,suppressMessage,curUser.UserGroupNum);
}
catch(Exception ex) {
MessageBox.Show(ex.Message);
return false;
}
}