internal static SharedFacet CreateFromPermissions(Permission[] permissions) { if (null == permissions || permissions.Length == 0) { return(null); } SharedFacet facet = new SharedFacet(); SharedScope discoveredScope = SharedScope.None; foreach (var perm in permissions) { if (perm.Link != null && perm.Link.Scope == "organization") { discoveredScope = (SharedScope.Tenant > discoveredScope) ? SharedScope.Tenant : discoveredScope; } else if (perm.Link != null && perm.Link.Scope == "anonymous") { discoveredScope = (SharedScope.Anonymous > discoveredScope) ? SharedScope.Anonymous : discoveredScope; } if (perm.GrantedTo != null) { discoveredScope = (SharedScope.Users > discoveredScope) ? SharedScope.Users : discoveredScope; } } facet.Scope = discoveredScope.ToString().ToLower(); return(facet); }
internal static SharedFacet CreateFromPermissions(Permission[] permissions) { if (null == permissions || permissions.Length == 0) return null; SharedFacet facet = new SharedFacet(); SharedScope discoveredScope = SharedScope.None; foreach (var perm in permissions) { if (perm.Link != null && perm.Link.Scope == "organization") { discoveredScope = (SharedScope.Tenant > discoveredScope) ? SharedScope.Tenant : discoveredScope; } else if (perm.Link != null && perm.Link.Scope == "anonymous") { discoveredScope = (SharedScope.Anonymous > discoveredScope) ? SharedScope.Anonymous : discoveredScope; } if (perm.GrantedTo != null) { discoveredScope = (SharedScope.Users > discoveredScope) ? SharedScope.Users : discoveredScope; } } facet.Scope = discoveredScope.ToString().ToLower(); return facet; }