/// <summary> /// (Downwards) Creates a chain of descriptors for all of the snapins that depend on the specified snapin, this is recursive and will graph the entire tree /// </summary> /// <param name="descriptor"></param> /// <param name="descriptors"></param> /// <returns></returns> public static SnapInDescriptorLink CreateDependencyChainForSnapInsThatDependOnThisSnapIn(SnapInDescriptor descriptor, SnapInDescriptor[] descriptors) { // create a new link for the descriptor specified SnapInDescriptorLink link = new SnapInDescriptorLink(descriptor); // find any other descriptors that depend on the specified descriptor passed in foreach(SnapInDescriptor otherDescriptor in descriptors) { foreach(Type dependency in otherDescriptor.Dependencies) { if (Type.Equals(descriptor.Type, dependency)) { // find all of that dependency's chain, and do it recursively (Downwards) SnapInDescriptorLink nextLink = SnapInHostingEngine.CreateDependencyChainForSnapInsThatDependOnThisSnapIn(otherDescriptor, descriptors); link.Links.Add(nextLink); } } } return link; }
/// <summary> /// Follows the link to the end of the chain, recursively, and stops each link after it's dependencies have been stopped /// </summary> /// <param name="link"></param> /// <param name="progressViewer"></param> internal static bool StopLink(SnapInDescriptorLink link, IProgressViewer progressViewer) { if (link != null) { // stop the links that depend on this link first bool linksStopped = true; foreach(SnapInDescriptorLink l in link.Links) { // start this link's dependency chain linksStopped = SnapInHostingEngine.StopLink(l, progressViewer); if (!linksStopped) break; } // if all of the links that depend on this have stopped if (linksStopped) // then finally stop this link, and back out return SnapInHostingEngine.Stop(link.Descriptor, false, progressViewer); } return false; }
/// <summary> /// (Upwards) Creates a chain of descriptors for all of the snapins that this snapin depends upon, this is recursive and will graph the entire tree /// </summary> /// <param name="descriptor"></param> /// <param name="descriptors"></param> /// <returns></returns> public static SnapInDescriptorLink CreateDependencyChainForSnapInsThatThisSnapInDependsOn(SnapInDescriptor descriptor, SnapInDescriptor[] descriptors) { // create a new link for the descriptor specified SnapInDescriptorLink link = new SnapInDescriptorLink(descriptor); // find any descriptors that this descriptor depends on foreach(Type dependency in descriptor.Dependencies) { foreach(SnapInDescriptor otherDescriptor in descriptors) { if (Type.Equals(otherDescriptor.Type, dependency)) { // find all of the dependency's chain, and do it resursiviely (Upwards) SnapInDescriptorLink nextLink = SnapInHostingEngine.CreateDependencyChainForSnapInsThatThisSnapInDependsOn(otherDescriptor, descriptors); link.Links.Add(nextLink); } } } return link; }