public static void FillChildNodes(this IEnumerable <IOguObject> children, List <UserGraphTreeNode> childNodes, UserGraphControlObjectMask listMask, Func <IOguObject, bool> filter = null, Action <IOguObject, UserGraphTreeNode> addedAction = null) { children.ForEach(child => { if (((int)child.ObjectType & (int)listMask) != 0) { bool canAdd = true; if (filter != null) { canAdd = filter(child); } if (canAdd) { UserGraphTreeNode treeNode = child.ToTreeNode(); if (addedAction != null) { addedAction(child, treeNode); } childNodes.Add(treeNode); } } } ); }
private static void FillUserInfo(this IUser obj, UserGraphTreeNode treeNode) { obj.IsNotNull(user => { treeNode.Open = true; treeNode.IconSkin = "user"; }); }
private static void FillGroupInfo(this IGroup obj, UserGraphTreeNode treeNode) { obj.IsNotNull(group => { treeNode.Open = true; treeNode.IsParent = false; treeNode.IconSkin = "user"; }); }
private static void FillOrganizationInfo(this IOrganization obj, UserGraphTreeNode treeNode) { obj.IsNotNull(org => { treeNode.Open = false; treeNode.IsParent = true; treeNode.IconSkin = treeNode.IsParent ? "depart" : "person"; }); }
public static UserGraphTreeNode ToTreeNode(this IOguObject obj) { UserGraphTreeNode result = null; if (obj != null) { result = new UserGraphTreeNode(); result.ID = obj.ID; result.Name = obj.DisplayName.IsNotEmpty() ? obj.DisplayName : obj.Name; //result.Data = obj.ToWrappedObject(); result.Data = obj; (obj as IUser).FillUserInfo(result); (obj as IOrganization).FillOrganizationInfo(result); (obj as IGroup).FillGroupInfo(result); } return(result); }