public Requires ( |
||
resource | The resource. | |
return | void |
public void BasicResourceResolution() { DependencyGraph g = new DependencyGraph(); Resource res = new Resource(g, "resource"); OrderedProcess a = new OrderedProcess(g, "A"); OrderedProcess b = new OrderedProcess(g, "B"); OrderedProcess c = new OrderedProcess(g, "C"); a.Before(b); a.Before(c); b.Requires(res); c.Requires(res); IEnumerable<IEnumerable<OrderedProcess>> s = g.CalculateSort(); Assert.AreEqual(3, s.Count()); Assert.AreEqual(1, s.Skip(0).First().Count()); Assert.AreEqual(a, s.Skip(0).First().First()); Assert.AreEqual(1, s.Skip(1).First().Count()); Assert.IsTrue(s.Skip(1).First().First() == b || s.Skip(1).First().First() == c); Assert.AreEqual(1, s.Skip(0).First().Count()); Assert.IsTrue(s.Skip(2).First().First() == b || s.Skip(2).First().First() == c); Assert.AreNotEqual(s.Skip(1).First().First(), s.Skip(2).First().First()); }
/// <summary> /// Indicates that this resource is used by the given process /// </summary> /// <param name="process">The process.</param> /// <returns></returns> public void UsedBy(OrderedProcess process) { DependencyGraph.CheckGraph(this, process); if (users.Add(process)) process.Requires(this); }
/// <summary> /// Indicates that this resource is used by the given process /// </summary> /// <param name="process">The process.</param> /// <returns></returns> public void UsedBy(OrderedProcess process) { DependencyGraph.CheckGraph(this, process); if (users.Add(process)) { process.Requires(this); } }