private void ProcessParent(object parentKey, IReference <RuntimeGroupLeafObj> parentObj, RuntimeGroupLeafObjReference childObj, bool addToWaitList) { if (parentObj != null) { using (parentObj.PinValue()) { parentObj.Value().AddChild(childObj); } } else { RuntimeGroupRootObj runtimeGroupRootObj = base.m_owner as RuntimeGroupRootObj; runtimeGroupRootObj.AddChild(childObj); if (addToWaitList) { ChildLeafInfo childLeafInfo = null; IDisposable disposable2 = null; try { if (this.m_parentInfo == null) { this.m_parentInfo = this.CreateParentInfo(); } else { this.m_parentInfo.TryGetAndPin(parentKey, out childLeafInfo, out disposable2); } if (childLeafInfo == null) { childLeafInfo = new ChildLeafInfo(); disposable2 = this.m_parentInfo.AddAndPin(parentKey, childLeafInfo); } childLeafInfo.Add(childObj); } finally { if (disposable2 != null) { disposable2.Dispose(); } } } } }
private void ProcessChildren(object thisKey, IReference <RuntimeGroupLeafObj> parentObj, IReference <RuntimeGroupLeafObj> thisObj) { ChildLeafInfo childLeafInfo = null; if (this.m_parentInfo != null) { this.m_parentInfo.TryGetValue(thisKey, out childLeafInfo); } if (childLeafInfo != null) { for (int i = 0; i < childLeafInfo.Count; i++) { RuntimeGroupLeafObjReference runtimeGroupLeafObjReference = ((List <RuntimeGroupLeafObjReference>)childLeafInfo)[i]; using (runtimeGroupLeafObjReference.PinValue()) { RuntimeGroupLeafObj runtimeGroupLeafObj = runtimeGroupLeafObjReference.Value(); bool flag = false; IReference <RuntimeGroupObj> reference = parentObj as IReference <RuntimeGroupObj>; while (reference != null && !flag) { RuntimeGroupLeafObj runtimeGroupLeafObj2 = reference.Value() as RuntimeGroupLeafObj; if (runtimeGroupLeafObj2 == runtimeGroupLeafObj) { flag = true; } reference = ((runtimeGroupLeafObj2 != null) ? runtimeGroupLeafObj2.Parent : null); } if (!flag) { runtimeGroupLeafObj.RemoveFromParent((RuntimeGroupRootObjReference)base.m_owner.SelfReference); using (thisObj.PinValue()) { thisObj.Value().AddChild(runtimeGroupLeafObjReference); } } } } this.m_parentInfo.Remove(thisKey); } }