public override object Clone() { var result = MemberwiseClone() as Permission; result.AssignedScopes = AssignedScopes?.Select(x => x.Clone()).OfType <PermissionScope>().ToList(); return(result); }
public virtual Claim ToClaim(JsonSerializerSettings jsonSettings) { var result = Name; if (!AssignedScopes.IsNullOrEmpty()) { result += _scopeCharSeparator + JsonConvert.SerializeObject(AssignedScopes, jsonSettings); } return(new Claim(PlatformConstants.Security.Claims.PermissionClaimType, result)); }
/// <summary> /// Generate permissions string with scope combination /// </summary> public IEnumerable <string> GetPermissionWithScopeCombinationNames() { var retVal = new List <string>(); if (AssignedScopes != null && AssignedScopes.Any()) { retVal.AddRange(AssignedScopes.Select(x => Id + ":" + x.ToString())); } else { retVal.Add(Id); } return(retVal); }
public virtual void Patch(Permission target) { target.Name = Name; target.ModuleId = ModuleId; target.GroupName = GroupName; if (!AssignedScopes.IsNullOrEmpty()) { AssignedScopes.Patch(target.AssignedScopes, (sourceScope, targetScope) => sourceScope.Patch(targetScope)); } if (!AvailableScopes.IsNullOrEmpty()) { AvailableScopes.Patch(target.AvailableScopes, (sourceScope, targetScope) => sourceScope.Patch(targetScope)); } }
protected override IEnumerable <object> GetEqualityComponents() { yield return(Name); yield return(ModuleId); if (!AssignedScopes.IsNullOrEmpty()) { foreach (var scope in AssignedScopes) { yield return(scope); } } }
public virtual object Clone() { var clone = (Permission)MemberwiseClone(); if (AssignedScopes != null) { clone.AssignedScopes = new List <PermissionScope>(AssignedScopes.Select(x => x.Clone() as PermissionScope)); } if (AvailableScopes != null) { clone.AvailableScopes = new List <PermissionScope>(AvailableScopes.Select(x => x.Clone() as PermissionScope)); } return(clone); }