public static T FindRecursive <T>(this IEnumerable source, Predicate <ISecureObject> match, ISecureObject parent = null) where T : ISecureObject { ISecureObject found = null; foreach (ISecureObject item in source) { item.ParentUId = parent?.UId; item.Parent = parent; if (match(item)) { found = item; } else { found = item.Children.FindRecursive <T>(match, item); } if (found != null) { break; } } return((T)found); }
public virtual ISecureObject UpsertSecureObject(ISecureObject secureObject) { IList <SecureObject> list = Store.SecureObjects; if (secureObject.ParentUId.HasValue) { SecureObject found = Store.SecureObjects.FindRecursive <SecureObject>(o => o.UId == secureObject.ParentUId); if (found != null) { list = found.Children; } else { throw new KeyNotFoundException($"Could not find SecureContainer with ParentId: {secureObject.ParentUId}"); } } int index = list.FindIndex(o => o.UId == secureObject.UId); if (index >= 0) { list[index].Sync((SecureObject)secureObject, shallow: false); } else { list.Add((SecureObject)secureObject); } return(secureObject); }
public static void ApplySecurity(this Control control, ISecureObject secureObject) { if (secureObject == null) { control.Visible = false; return; } ISecureObject found = secureObject.UniqueName.Equals(control.Name, StringComparison.OrdinalIgnoreCase) ? secureObject : secureObject.FindChild <ISecureObject>(control.Name); if (found != null && found.Security.Results.ContainsRightType(typeof(UIRight))) { control.Visible = found.Security.Results.GetByTypeRight(UIRight.Visible).AccessAllowed; control.Enabled = found.Security.Results.GetByTypeRight(UIRight.Enabled).AccessAllowed; if (control is TextBox textBox) { textBox.ReadOnly = !found.Security.Results.GetByTypeRight(UIRight.Operate).AccessAllowed; } } if (control.HasChildren) { foreach (Control child in control.Controls) { child.ApplySecurity(secureObject); } } }
override public void UpdateSecureObjectParentUId(ISecureObject secureObject, Guid?newParentUId) { base.UpdateSecureObjectParentUId(secureObject, newParentUId); if (SaveChanges) { LockedSaveChanges(); } }
override public ISecureObject UpsertSecureObject(ISecureObject secureObject) { ISecureObject x = base.UpsertSecureObject(secureObject); if (SaveChanges) { LockedSaveChanges(); } return(x); }
public static void EnsureParentUIdRecursive(this ISecureObject secureObject) { if (secureObject?.Children?.Count > 0) { foreach (ISecureObject child in secureObject.Children) { child.Parent = secureObject; child.ParentUId = secureObject.UId; child.EnsureParentUIdRecursive(); } } }
public static SecurityResults EvalSecurity(this ISecureObject secureObject) { secureObject.Security.Eval(); if (secureObject.Children != null && secureObject.Children.Count > 0) { foreach (ISecureObject child in secureObject.Children) { secureObject.Security.CopyTo(child.Security); EvalSecurity(child); } } return(secureObject.Security.Results); }
public void UpsertSecureObject() { SecureObject child = new SecureObject() { UniqueName = "child" }; ISecureObject top = _dal.GetSecureObjectByUniqueName(so.UniqueName); child.ParentUId = top.UId; _dal.UpsertSecureObject(child); ISecureObject found = _dal.GetSecureObjectByUniqueName(child.UniqueName); Assert.IsNotNull(found); bool eq = child.UniqueName.Equals(found.UniqueName); Assert.IsTrue(eq); }
public virtual void UpdateSecureObjectParentUId(ISecureObject secureObject, Guid?newParentUId) { IList <SecureObject> list = Store.SecureObjects; if (secureObject.ParentUId.HasValue) { SecureObject found = Store.SecureObjects.FindRecursive <SecureObject>(o => o.UId == secureObject.ParentUId); if (found != null) { list = found.Children; } else { throw new KeyNotFoundException($"Could not find SecureContainer with ParentId: {secureObject.ParentUId}"); } } int index = list.FindIndex(o => o.UId == secureObject.UId); if (index >= 0) { SecureObject so = list[index]; so.ParentUId = newParentUId; list.RemoveAt(index); IList <SecureObject> newlist = Store.SecureObjects; if (newParentUId.HasValue) { SecureObject found = Store.SecureObjects.FindRecursive <SecureObject>(o => o.UId == newParentUId); if (found != null) { newlist = found.Children; } else { throw new KeyNotFoundException($"Could not find SecureContainer with ParentId: {newParentUId}"); } } newlist.Add(so); } }
void ISuplexDal.UpdateSecureObjectParentUId(ISecureObject secureObject, Guid?newParentUId) { _dal.UpdateSecureObjectParentUId(secureObject, newParentUId); }
ISecureObject ISuplexDal.UpsertSecureObject([FromBody] ISecureObject secureObject) { return(_dal.UpsertSecureObject(secureObject)); }
public async Task UpdateSecureObjectParentUIdAsync(ISecureObject secureObject, Guid?newParentUId) { string requestUri = $"{_rootPath}/so/{newParentUId}/"; await PutAsync(secureObject, requestUri, new JsonAceConverter()).ConfigureAwait(_configureAwaitContinueOnCapturedContext); }
public void UpdateSecureObjectParentUId(ISecureObject secureObject, Guid?newParentUId) { UpdateSecureObjectParentUIdAsync(secureObject, newParentUId).Wait(); }
ISecureObject ISuplexDal.UpsertSecureObject(ISecureObject secureObject) { return(UpsertSecureObjectAsync(secureObject as SecureObject).Result); }