• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Permission类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Permission的典型用法代码示例。如果您正苦于以下问题:C# Permission类的具体用法?C# Permission怎么用?C# Permission使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Permission类属于命名空间,在下文中一共展示了Permission类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Add

        public ActionResult Add(IdentityRole model)
        {
            try
            {
                db.Roles.Add(model);
                db.SaveChanges();
                var Projectdb = new ProjectMvcDbContext();
                foreach (var p in Projectdb.WebActions)
                {
                    var perm = new Permission
                    {
                        Allow = false,
                        RoleId = model.Id,
                        WebActionId = p.Id
                    };
                    Projectdb.Permissions.Add(perm);
                }

                Projectdb.SaveChanges();
                return RedirectToAction("Index");
            }
            catch (Exception Ex)
            {
                ModelState.AddModelError("", Ex.Message);
                ViewBag.Role = db.Roles;
                return View("Index", model);
            }
        }
开发者ID:SamYao779,项目名称:DemoCodeProjectMVC5,代码行数:28,代码来源:RoleController.cs


示例2: CheckPermissionStatusAsync

        /// <summary>
        /// Determines whether this instance has permission the specified permission.
        /// </summary>
        /// <returns><c>true</c> if this instance has permission the specified permission; otherwise, <c>false</c>.</returns>
        /// <param name="permission">Permission to check.</param>
        public Task<PermissionStatus> CheckPermissionStatusAsync(Permission permission)
        {
            var names = GetManifestNames(permission);

            //if isn't an android specific group then go ahead and return true;
            if (names == null)
            {
                Debug.WriteLine("No android specific permissions needed for: " + permission);
                return Task.FromResult(PermissionStatus.Granted);
            }

            //if no permissions were found then there is an issue and persmission is not set in Android manifest
            if (names.Count == 0)
            {
                Debug.WriteLine("No permissions found in manifest for: " + permission);
                return Task.FromResult(PermissionStatus.Unknown);
            }

            Context context = CrossCurrentActivity.Current.Activity ?? Application.Context;
            if (context == null)
            {
                Debug.WriteLine("Unable to detect current Activity or App Context. Please ensure Plugin.CurrentActivity is installed in your Android project and your Application class is registering with Application.IActivityLifecycleCallbacks.");
                return Task.FromResult(PermissionStatus.Unknown);  
            }

            foreach (var name in names)
            {
                if (ContextCompat.CheckSelfPermission(context, name) == Android.Content.PM.Permission.Denied)
                    return Task.FromResult(PermissionStatus.Denied);
            }
            return Task.FromResult(PermissionStatus.Granted);
        }
开发者ID:alesvi,项目名称:Xamarin.Plugins,代码行数:37,代码来源:PermissionsImplementation.cs


示例3: Page_Init

    protected void Page_Init(object sender, EventArgs e)
    {
        ctx = new AriClinicContext("AriClinicContext");
        // security control, it must be a user logged
        if (Session["User"] == null)
            Response.Redirect("Default.aspx");
        else
        {
            user = CntAriCli.GetUser((Session["User"] as User).UserId, ctx);
            Process proc = (from p in ctx.Processes
                            where p.Code == "professional"
                            select p).FirstOrDefault<Process>();
            per = CntAriCli.GetPermission(user.UserGroup, proc, ctx);
            btnAccept.Visible = per.Modify;
        }

        // 
        if (Request.QueryString["ProfessionalId"] != null)
        {
            professionalId = Int32.Parse(Request.QueryString["ProfessionalId"]);
            prof = CntAriCli.GetProfessional(professionalId, ctx);
            LoadData(prof);
        }
        else
        {
            LoadUserCombo(null);
            LoadTypeCombo(null);
            LoadTaxWithholdingTypeCombo(null);
        }

    }
开发者ID:ragare62,项目名称:AriClinic,代码行数:31,代码来源:ProfessionalForm.aspx.cs


示例4: GrantPermissionOperation

 public GrantPermissionOperation(string table, string user, Permission permission)
   : base(null)
 {
     Table = table;
     User = user;
     Permission = permission;
 }
开发者ID:Infro-CommonLibrary,项目名称:CommonCSharp,代码行数:7,代码来源:GrantPermissionOperation.cs


示例5: HasPermission

        public bool HasPermission(Permission permission, HttpContextBase httpContext)
        {
            // get the list of roles that the user must have some overlap with to have the permission
            HashSet<string> rolesRequired = _rolePermissions[permission];

            foreach(var role in _allRoles)
            {
                if (httpContext.User.IsInRole(role) && rolesRequired.Contains(role))
                {
                    return true;
                }
            }

            // fallback for no roles -- give them at least Read Only status

            bool userHasAtLeastOneRole = false;
            foreach(var role in _allRoles)
            {
                if (httpContext.User.IsInRole(role))
                {
                    userHasAtLeastOneRole = true;
                    break;
                }
            }

            if (!userHasAtLeastOneRole)
            {
                if (rolesRequired.Contains(READ_ONLY_ROLE_NAME))
                {
                    return true;
                }
            }

            return false;
        }
开发者ID:smartpcr,项目名称:azure-iot-remote-monitoring,代码行数:35,代码来源:RolePermissions.cs


示例6: GetLimitIndex

 static int GetLimitIndex( Rank rank, Permission permission ) {
     if( rank.HasLimitSet( permission ) ) {
         return rank.GetLimit( permission ).Index + 1;
     } else {
         return 0;
     }
 }
开发者ID:fragmer,项目名称:fCraft,代码行数:7,代码来源:PermissionLimitBox.cs


示例7: Remap

        public Permission Remap(Permission permission)
        {
            if ((permission & From) == From)
                return (permission ^ From) | To;

            return permission;
        }
开发者ID:Jobu,项目名称:n2cms,代码行数:7,代码来源:PermissionRemapAttribute.cs


示例8: Authorizes

        public virtual bool Authorizes(IPrincipal user, ContentItem item, Permission permission)
        {
            if(item != null && permission == Permission.Read && !item.IsAuthorized(user))
                return false;

            return MapsTo(permission) && Contains(user);
        }
开发者ID:Biswo,项目名称:n2cms,代码行数:7,代码来源:PermissionMap.cs


示例9: GetRoles

        /// <summary>Gets roles allowed for a certain permission stored in a content item.</summary>
        /// <param name="item">The item whose permitted roles get.</param>
        /// <param name="permission">The permission asked for.</param>
        /// <returns>Permitted roles.</returns>
        public static IEnumerable<string> GetRoles(ContentItem item, Permission permission)
        {
            List<string> roles = null;
            foreach (Permission permissionLevel in SplitPermission(permission))
            {
                if(permissionLevel == Permission.Read)
                {
                    foreach(AuthorizedRole role in item.AuthorizedRoles)
                    {
                        AddTo(ref roles, role.Role);
                    }
                    continue;
                }

                DetailCollection roleDetails = item.GetDetailCollection(AuthorizedRolesPrefix + permissionLevel, false);
                if (roleDetails == null)
                    continue;

                foreach(string role in roleDetails)
                {
                    roles = AddTo(ref roles, role);
                }
            }
            return roles;
        }
开发者ID:Jobu,项目名称:n2cms,代码行数:29,代码来源:DynamicPermissionMap.cs


示例10: Page_Init

 protected void Page_Init(object sender, EventArgs e)
 {
     ctx = new AriClinicContext("AriClinicContext");
     // security control, it must be a user logged
     if (Session["User"] == null)
         Response.Redirect("Default.aspx");
     else
     {
         user = CntAriCli.GetUser((Session["User"] as User).UserId, ctx);
         Process proc = (from p in ctx.Processes
                         where p.Code == "policy"
                         select p).FirstOrDefault<Process>();
         per = CntAriCli.GetPermission(user.UserGroup, proc, ctx);
         btnAccept.Visible = per.Modify;
     }
     // 
     if (Request.QueryString["CustomerId"] != null)
     {
         patientId = Int32.Parse(Request.QueryString["CustomerId"]);
         pat = CntAriCli.GetCustomer(patientId, ctx);
         txtCustomer.Text = pat.FullName;
     }
     // 
     if (Request.QueryString["PolicyId"] != null)
     {
         policyId = Int32.Parse(Request.QueryString["PolicyId"]);
         pol = CntAriCli.GetPolicy(policyId, ctx);
         LoadData(pol);
     }
     else
     {
         LoadTypeCombo(null);
         LoadInsuranceCombo(null);
     }
 }
开发者ID:ragare62,项目名称:AriClinic,代码行数:35,代码来源:PolicyForm.aspx.cs


示例11: Page_Init

    protected void Page_Init(object sender, EventArgs e)
    {
        ctx = new AriClinicContext("AriClinicContext");
        // security control, it must be a user logged
        if (Session["User"] == null)
            Response.Redirect("Default.aspx");
        else
        {
            user = (User)Session["User"];
            user = CntAriCli.GetUser(user.UserId, ctx);
            Process proc = (from p in ctx.Processes
                            where p.Code == "visitreason"
                            select p).FirstOrDefault<Process>();
            per = CntAriCli.GetPermission(user.UserGroup, proc, ctx);
            btnAccept.Visible = per.Modify;
        }

        // 
        if (Request.QueryString["VisitReasonId"] != null)
        {
            visitReasonId = Int32.Parse(Request.QueryString["VisitReasonId"]);
            visitReason = CntAriCli.GetVisitReason(visitReasonId, ctx);
            LoadData(visitReason);
        }
    }
开发者ID:ragare62,项目名称:AriClinic,代码行数:25,代码来源:VisitReasonForm.aspx.cs


示例12: Page_Init

 protected void Page_Init(object sender, EventArgs e)
 {
     ctx = new AriClinicContext("AriClinicContext");
     // security control, it must be a user logged
     if (Session["User"] == null)
         Response.Redirect("Default.aspx");
     else
     {
         user = CntAriCli.GetUser((Session["User"] as User).UserId, ctx);
         Process proc = (from p in ctx.Processes
                         where p.Code == "scat"
                         select p).FirstOrDefault<Process>();
         per = CntAriCli.GetPermission(user.UserGroup, proc, ctx);
     }
     //cheks if is call from customer form tabs
     if (type == "InTab")
     {
         HtmlControl tt = (HtmlControl)this.FindControl("TitleArea");
         tt.Attributes["class"] = "ghost";
         // hide patient column
         RadGrid1.Columns.FindByDataField("Patient.FullName").Visible = false;
     }
     // cheks if is call from another form
     if (Request.QueryString["Type"] != null)
         type = Request.QueryString["Type"];
     // translate filters
     CntWeb.TranslateRadGridFilters(RadGrid1);
 }
开发者ID:ragare62,项目名称:AriClinic,代码行数:28,代码来源:ServiceGrid.aspx.cs


示例13: GrantPermission

        /// <summary>
        /// 为指定<see cref="IGrantee" />授予特定的<see cref="Permission" />。
        /// 目前只支持被授权者为<see cref="GroupGrantee.AllUsers" />。
        /// </summary>
        /// <param name="grantee">被授权者。</param>
        /// <param name="permission">被授予的权限。</param>
        internal void GrantPermission(IGrantee grantee, Permission permission)
        {
            if (grantee == null)
                throw new ArgumentNullException("grantee");

            _grants.Add(new Grant(grantee, permission), true);
        }
开发者ID:jefth,项目名称:aliyun-oss-csharp-sdk,代码行数:13,代码来源:AccessControlList.cs


示例14: CanMapFullPermission

        public void CanMapFullPermission(Permission expectedPermission)
        {
            var map = new PermissionMap { Permissions = Permission.Full, Roles = new[] { "rolename" } };

            Assert.That(map.MapsTo(expectedPermission), Is.True);
            Assert.That(map.Authorizes(user, item, expectedPermission), Is.True);
        }
开发者ID:JohnsonYuan,项目名称:n2cms,代码行数:7,代码来源:PermissionMapTests.cs


示例15: PermissionUnitTest

 public PermissionUnitTest()
 {
     List<Permission> permList = Permission.index();
     Assert.IsNotNull(permList);
     Assert.IsTrue(permList.Count > 0);
     testPermission = permList[0];
 }
开发者ID:rs-services,项目名称:RightScaleNetAPI,代码行数:7,代码来源:PermissionUnitTest.cs


示例16: CanMapReadPermission

        public void CanMapReadPermission(Permission expectedPermission, bool expectedResult)
        {
            var map = new PermissionMap { Permissions = Permission.Read, Roles = new[] { "rolename" } };

            Assert.That(map.MapsTo(expectedPermission), Is.EqualTo(expectedResult));
            Assert.That(map.Authorizes(user, item, expectedPermission), Is.EqualTo(expectedResult));
        }
开发者ID:JohnsonYuan,项目名称:n2cms,代码行数:7,代码来源:PermissionMapTests.cs


示例17: Document

 // Primary
 public Document(User owner, string content, string path, Permission.Permissions perm)
 {
     this.permission = perm;
     this.owner = owner;
     this.content = content;
     this.lastChanged = DateTime.Now;
 }
开发者ID:filiphjermind,项目名称:bdsa_projekt,代码行数:8,代码来源:Document.cs


示例18: Page_Init

 protected void Page_Init(object sender, EventArgs e)
 {
     ctx = new AriClinicContext("AriClinicContext");
     // security control, it must be a user logged
     if (Session["User"] == null)
         Response.Redirect("Default.aspx");
     else
     {
         user = CntAriCli.GetUser((Session["User"] as User).UserId, ctx);
         Process proc = (from p in ctx.Processes
                         where p.Code == "policy"
                         select p).FirstOrDefault<Process>();
         per = CntAriCli.GetPermission(user.UserGroup, proc, ctx);
     }
     // cheks if is call from another form
     if (Request.QueryString["Type"] != null)
         type = Request.QueryString["Type"];
     // read the realated patient
     if (Request.QueryString["PatientId"] != null)
     {
         patientId = Int32.Parse(Request.QueryString["PatientId"]);
         pat = CntAriCli.GetPatient(patientId, ctx);
         cus = pat.Customer;
     }
     if (Request.QueryString["CustomerId"] != null)
     {
         customerId = Int32.Parse(Request.QueryString["CustomerId"]);
         cus = CntAriCli.GetCustomer(customerId, ctx);
     }
     // translate filters
     CntWeb.TranslateRadGridFilters(RadGrid1);
 }
开发者ID:ragare62,项目名称:AriClinic,代码行数:32,代码来源:PolicyGrid.aspx.cs


示例19: Page_Init

 protected void Page_Init(object sender, EventArgs e)
 {
     ctx = new AriClinicContext("AriClinicContext");
     // security control, it must be a user logged
     if (Session["User"] == null)
         Response.Redirect("Default.aspx");
     else
     {
         user = CntAriCli.GetUser((Session["User"] as User).UserId, ctx);
         Process proc = (from p in ctx.Processes
                         where p.Code == "user"
                         select p).FirstOrDefault<Process>();
         per = CntAriCli.GetPermission(user.UserGroup, proc, ctx);
         btnAccept.Visible = per.Modify;
         // special for this form
         ddlGroup.Enabled = per.Create;
     }
     // 
     if (Request.QueryString["UserId"] != null)
     {
         userId = Int32.Parse(Request.QueryString["UserId"]);
         User usr = (from u in ctx.Users
                     where u.UserId == userId
                     select u).FirstOrDefault<User>();
         LoadData(usr);
     }
     else
     {
         LoadGroupCombo(null);
         LoadBaseVisitType(null);
         LoadClinic(null);
     }
 }
开发者ID:ragare62,项目名称:AriClinic,代码行数:33,代码来源:UserForm.aspx.cs


示例20: EntityDetails

        /// <summary>
        /// Initializes a new instance of the EntityDetails class.
        /// </summary>
        /// <param name="permission">Permissions of the user on the entity</param>
        public EntityDetails(Permission permission)
        {
            this.UserPermission = permission;

            // Tags should not be null so that empty strings can be passed as value for partial views.
            this.Tags = string.Empty;
        }
开发者ID:faorg,项目名称:wwt-website,代码行数:11,代码来源:EntityDetails.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# PermissionInfo类代码示例发布时间:2022-05-24
下一篇:
C# PeriodicTask类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap