The IndirectConversion is used to chain multiple transformations together to create a multi-stage transformation. IndirectConversion instances are created during the search process to find a conversion path between two releases.
Наследование: Conversion
Пример #1
0
        /// <summary>
        /// Recursively explores the <see cref="Release"/> definitions to determine
        /// the shortest conversion path between two releases.
        /// </summary>
        /// <param name="source">The source <see cref="Release"/> for the search.</param>
        /// <param name="target">The target <see cref="Release"/> for the search.</param>
        /// <param name="stack">A <see cref="Stack"/> used to detect cycles.</param>
        /// <returns>A <B>Conversion</B> that transforms between the source and
        /// target releases or <c>null</c> if no conversion is possible.</returns>
        private static Conversion DepthFirstSearch(Release source, Release target, Stack stack)
        {
            Conversion best = null;

            if (!stack.Contains(source))
            {
                stack.Push(source);

                foreach (Conversion first in source.SourceConversions)
                {
                    Release    release = first.TargetRelease;
                    Conversion result  = null;

                    if (release == target)
                    {
                        result = first;
                    }
                    else
                    {
                        Conversion second = DepthFirstSearch(release, target, stack);
                        if (second != null)
                        {
                            result = new IndirectConversion(first, second);
                        }
                    }

                    if (result != null)
                    {
                        if ((best == null) || (result.Complexity < best.Complexity))
                        {
                            best = result;
                        }
                    }
                }
                stack.Pop();
            }
            return(best);
        }
Пример #2
0
        /// <summary>
        /// Recursively explores the <see cref="Release"/> definitions to determine
        /// the shortest conversion path between two releases.
        /// </summary>
        /// <param name="source">The source <see cref="Release"/> for the search.</param>
        /// <param name="target">The target <see cref="Release"/> for the search.</param>
        /// <param name="stack">A <see cref="Stack"/> used to detect cycles.</param>
        /// <returns>A <B>Conversion</B> that transforms between the source and
        /// target releases or <c>null</c> if no conversion is possible.</returns>
        private static Conversion DepthFirstSearch(Release source, Release target, Stack stack)
        {
            Conversion	best = null;

            if (!stack.Contains (source)) {
                stack.Push (source);

                foreach (Conversion first in source.SourceConversions) {
                    Release		release = first.TargetRelease;
                    Conversion	result	= null;

                    if (release == target)
                        result = first;
                    else {
                        Conversion second = DepthFirstSearch (release, target, stack);
                            if (second != null)
                        result = new IndirectConversion (first, second);
                    }

                    if (result != null) {
                        if ((best == null)||(result.Complexity < best.Complexity))
                            best = result;
                    }
                }
                stack.Pop ();
            }
            return (best);
        }