当前位置: 首页>>代码示例>>C#>>正文


C# Role.Init方法代码示例

本文整理汇总了C#中Role.Init方法的典型用法代码示例。如果您正苦于以下问题:C# Role.Init方法的具体用法?C# Role.Init怎么用?C# Role.Init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Role的用法示例。


在下文中一共展示了Role.Init方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BuildRuntimeData

 public void BuildRuntimeData(EntityModel entityModel, Role role)
 {
     if(role.RuntimeData != null) return;
       role.Init(entityModel);
       role.RuntimeData = new RuntimeRoleData();
       // get refs to 'all' sets
       var allChildRoles = role.RuntimeData.AllChildRoles;
       var allChildGrants = role.RuntimeData.GrantedActivities;
       allChildGrants.UnionWith(role.ActivityGrants); //initialize with direct grants
       //Process child roles; collect roles and grants
       foreach(var child in role.ChildRoles)
     if(allChildRoles.Add(child)) {
       BuildRuntimeData(entityModel, child);
       allChildRoles.UnionWith(child.RuntimeData.AllChildRoles); //merge child roles
       allChildGrants.UnionWith(child.RuntimeData.GrantedActivities); //merge all child grants
     }
       //check there's no circular parent/child relationships
       Util.Check(!allChildRoles.Contains(role),
     "Role {0} is an (indirect) child of itself.", role.Name);
       // Now we merged all activity grants from child roles into one flat set allChildRoles
       // All activity grants from this and all child roles are merged into  allChildGrants
       // What we need to add to allChildGrants is grand-child activities - child activities
       // of direct grants for this role. If this role R has grant G on activity A, and activity
       // A has child activity B, then effectively role R is granted activity B through the same
       // grant G (or its clone). If grant G has conditions (filter, dynamic condition),
       // then activity B is granted to role R with the same conditions.
       // So we grant grand-child activities (B's) through clones of child grant G.
       foreach(var actGrant in role.ActivityGrants) {
     foreach(var grandChild in actGrant.Activity.AllChildActivities) {
       var grandChildGrand = actGrant.CreateSimilarGrant(grandChild);
       allChildGrants.Add(grandChildGrand);
     }
       }
       //Consolidate all permissions in one plane set of (grant/permission) tuples
       foreach(var grant in role.RuntimeData.GrantedActivities) {
     foreach(var perm in grant.Activity.Permissions) {
       role.RuntimeData.GrantedPermissions.Add(new GrantedPermission(perm, grant));
     }
       }
 }
开发者ID:yuanfei05,项目名称:vita,代码行数:40,代码来源:AuthorityBuilder.cs


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