parent
3bf98d2b34
commit
aa97e4d777
|
|
@ -929,15 +929,31 @@ functions
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (Dependencies.Count > 0)
|
return GetOrder(new List<RepositoryInfo>(), this);
|
||||||
{
|
|
||||||
return 1 + Dependencies.Max(d => d.Order);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static int GetOrder(List<RepositoryInfo> visited, RepositoryInfo info)
|
||||||
|
{
|
||||||
|
if (visited.Contains(info))
|
||||||
|
{
|
||||||
|
throw new Exception("A cyclic dependency between the following repositories has been detected: " +
|
||||||
|
string.Join(" -> ", visited));
|
||||||
|
}
|
||||||
|
|
||||||
|
visited.Add(info);
|
||||||
|
|
||||||
|
var order = 0;
|
||||||
|
foreach (var dependency in info.Dependencies)
|
||||||
|
{
|
||||||
|
order = Math.Max(order, GetOrder(visited, dependency));
|
||||||
|
}
|
||||||
|
|
||||||
|
visited.RemoveAt(visited.Count - 1);
|
||||||
|
|
||||||
|
return order + 1;
|
||||||
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return Name;
|
return Name;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue