/// <summary> /// Indicates that all the members of the enumerable must happen after the single predecessor /// </summary> /// <param name="followers">The followers.</param> /// <param name="predecessor">The predecessor.</param> /// <returns>the predecessor</returns> public static OrderedProcess <T> After <T>(this IEnumerable <OrderedProcess <T> > followers, OrderedProcess <T> predecessor) { predecessor.Before(followers); return(predecessor); }
/// <summary> /// Indicates that all members of the enumerable must happen before the single follower /// </summary> /// <param name="predecessors">The predecessors.</param> /// <param name="follower">The follower.</param> /// <returns>the followers</returns> public static OrderedProcess <T> Before <T>(this IEnumerable <OrderedProcess <T> > predecessors, OrderedProcess <T> follower) { follower.After(predecessors); return(follower); }
internal static void CheckGraph(Resource <T> a, OrderedProcess <T> b) { if (a.Graph != b.Graph) { throw new ArgumentException( $"Resource {a} is not associated with the same graph as process {b}"); } }
/// <summary> /// Indicates that this resource is used by the given process /// </summary> /// <param name="process">The process.</param> /// <returns></returns> public void UsedBy(OrderedProcess <T> process) { DependencyGraph <T> .CheckGraph(this, process); if (_users.Add(process)) { process.Requires(this); } }
/// <summary> /// Indicates that this process should execute after another /// </summary> /// <param value="predecessor">The predecessor.</param> /// <returns>returns this process</returns> public OrderedProcess <T> After(OrderedProcess <T> predecessor) { DependencyGraph <T> .CheckGraph(this, predecessor); if (_predecessors.Add(predecessor)) { predecessor.Before(this); } return(predecessor); }
/// <summary> /// Indicates that this process should execute before another /// </summary> /// <param value="follower">The ancestor.</param> /// <returns>returns this process</returns> public OrderedProcess <T> Before(OrderedProcess <T> follower) { DependencyGraph <T> .CheckGraph(this, follower); if (_followers.Add(follower)) { follower.After(this); } return(follower); }
public bool Equals(OrderedProcess <T> x, OrderedProcess <T> y) { if (x == null && y == null) { return(true); } if (x == null || y == null) { return(false); } return(Comparer.Equals(x.Value, y.Value)); }
public static void InitializeMaps <TType>(DependencyGraph <TType> graph, IEnumerable <TType> items, Dictionary <Type, HashSet <Type> > typeMap, Dictionary <Type, HashSet <OrderedProcess <TType> > > processMap) { foreach (var item in items) { var process = new OrderedProcess <TType>(graph, item); var type = item.GetType(); var deps = GetDependencies(type); UpdateTypeMap(typeMap, type, deps); UpdateProcessMap(processMap, type, process); } }
public static void UpdateProcessMap <TType>(Dictionary <Type, HashSet <OrderedProcess <TType> > > processMap, Type type, OrderedProcess <TType> process) { if (processMap.ContainsKey(type)) { var set = processMap[type]; set.Add(process); } else { processMap[type] = new HashSet <OrderedProcess <TType> > { process }; } }
public int GetHashCode(OrderedProcess <T> obj) { return(obj.Value.GetHashCode()); }
internal bool Add(OrderedProcess <T> orderedProcess) { return(_processes.Add(orderedProcess)); }