/// <summary> /// Build the partial containment tree of a <see cref="Thing"/> starting from one of its container /// </summary> /// <param name="thing">The <see cref="Thing"/> which containment tree is computed</param> /// <param name="container">One of its container in the containment tree in the current <see cref="ISession"/></param> private static void AddContainerPartialTree(this Thing thing, Poco container) { var tmpContainer = container; while (!(tmpContainer is CDP4Common.CommonData.TopContainer)) { tmpContainer = tmpContainer.Container; if (tmpContainer == null) { throw new NullReferenceException(string.Format("The containment tree is broken for the {0} with id {1}.", thing.ClassKind, thing.Iid)); } thing.AddContainer(tmpContainer.ClassKind, tmpContainer.Iid); } }
/// <summary> /// Build the full containment tree for a <see cref="Thing"/> from its associated <see cref="Poco"/> /// </summary> /// <param name="thing">The <see cref="Thing"/> which containment tree is computed</param> /// <param name="cachedThing">Its associated <see cref="Poco"/> in the current <see cref="ISession"/></param> private static void AddContainerCompleteTree(this Thing thing, Poco cachedThing) { var container = cachedThing.Container; if (container == null) { throw new NullReferenceException(string.Format("The container of the {0} with id {1} is null.", thing.ClassKind, thing.Iid)); } thing.AddContainer(container.ClassKind, container.Iid); while (!(container is CDP4Common.CommonData.TopContainer)) { container = container.Container; if (container == null) { throw new NullReferenceException(string.Format("The containment tree is broken for the {0} with id {1}.", thing.ClassKind, thing.Iid)); } thing.AddContainer(container.ClassKind, container.Iid); } }