} // end GetParent /// <summary> /// Returns a list of children. This list is empty in case of an error or if no children are there to be delivered /// </summary> /// <returns> /// List of this element's children. If the element has no children, the list is empty /// </returns> /// <include /// file='TBNS.doc.xml' /// path='//class[@name="DaAddressSpaceElement"]/ /// method[@name="GetChildren"]/doc/*' /// /> public override ArrayList GetChildren() { ArrayList children = new ArrayList(); IntPtr ptrData = IntPtr.Zero; int count = 0; int res = OTBFunctions.OTSGetChildren(m_objectHandle, (byte) EnumAddressSpaceElementType.DA, out count, out ptrData); if (ResultCode.SUCCEEDED(res)) { if (count > 0) { int size = Marshal.SizeOf(typeof (OTObjectData)); lock (Application.Instance.DaAddressSpaceRoot.ElementSyncRoot) { for (int i = 0; i < count; i++) { IntPtr currentPtr = new IntPtr(ptrData.ToInt64() + size*i); OTObjectData myData = (OTObjectData) Marshal.PtrToStructure(currentPtr, typeof (OTObjectData)); children.Add( Application.Instance.DaAddressSpaceRoot.GetElementFromArray(myData.m_userData) as DaAddressSpaceElement); } // end for } } // end if OTBFunctions.OTFreeMemory(ptrData); } // end if return children; } // end GetChildren
/// <summary> /// retrieves the parent from a handle /// </summary> internal AddressSpaceElement GetParent(uint aHandle) { if (aHandle == 0) { return m_root; } // end if OTObjectData parent = new OTObjectData(); IntPtr pParent = Marshal.AllocCoTaskMem(Marshal.SizeOf(parent)); Marshal.StructureToPtr(parent, pParent, false); if ((uint) EnumResultCode.S_OK != OTBFunctions.OTSGetParent(aHandle, pParent)) { return null; } // end if parent = (OTObjectData) Marshal.PtrToStructure(pParent, typeof (OTObjectData)); Marshal.FreeCoTaskMem(pParent); AddressSpaceElement elementParent = GetElementFromArray(parent.m_userData); if (elementParent == null) { return m_root; } // end if return elementParent; } // end getParent