Beispiel #1
0
        /// <summary>
        /// Returns a list of the supplied dependencies sorted such that all list entries
        /// appear after all of the entries that they depend on
        /// </summary>
        private IEnumerable <SuppliedDependency> GetSuppliedDependenciesOrdered()
        {
            if (_suppliedDependencies == null || _suppliedDependencies.Count == 0)
            {
                return(Enumerable.Empty <SuppliedDependency>());
            }

            Func <SuppliedDependency, SuppliedDependency, bool> isDependentOn = (d1, d2) =>
            {
                if (d1.DependentSupplies == null || d1.DependentSupplies.Count == 0)
                {
                    return(false);
                }
                if (ReferenceEquals(d2.DataSupply, null))
                {
                    return(false);
                }
                return(d1.DependentSupplies.Any(s => ReferenceEquals(s, d2.DataSupply)));
            };
            var listSorter = new DependencyListSorter <SuppliedDependency>();

            lock (_suppliedDependencies)
            {
#if DETAILED_TRACE
                Trace.WriteLine("Data context builder #" + Id + " sorting dependencies. Original order:");
                foreach (var d in _suppliedDependencies)
                {
                    Trace.WriteLine("    " + d);
                }
#endif
                var sortedList = listSorter.Sort(_suppliedDependencies, isDependentOn);
#if DETAILED_TRACE
                Trace.WriteLine("Data context builder #" + Id + " Order after sorting:");
                foreach (var d in sortedList)
                {
                    Trace.WriteLine("    " + d);
                }
#endif
                return(sortedList);
            }
        }
Beispiel #2
0
 public void Setup()
 {
     Reset();
     _dependencyListSorter = new DependencyListSorter <TestType>();
 }