Confuser.Core/DependencyResolver.cs
/// <summary>
///     Sort the protection according to their dependency.
/// </summary>
/// <returns>Sorted protections with respect to dependencies.</returns>
/// <exception cref="T:CircularDependencyException">
///     The protections contain circular dependencies.
/// </exception>
// Token: 0x06000139 RID: 313 RVA: 0x0000A85C File Offset: 0x00008A5C
Sort the protection according to their dependency.
Sort the protection according to their dependency .
public IList<Protection> SortDependency()
		{
			List<DependencyResolver.DependencyGraphEdge> edges = new List<DependencyResolver.DependencyGraphEdge>();
			HashSet<Protection> roots = new HashSet<Protection>(this.protections);
			Dictionary<string, Protection> id2prot = this.protections.ToDictionary((Protection prot) => prot.FullId, (Protection prot) => prot);
			foreach (Protection prot2 in this.protections)
			{
				Type protType = prot2.GetType();
				BeforeProtectionAttribute before = protType.GetCustomAttributes(typeof(BeforeProtectionAttribute), false).Cast<BeforeProtectionAttribute>().SingleOrDefault<BeforeProtectionAttribute>();
				if (before != null)
				{
					IEnumerable<Protection> targets = from id in before.Ids
					select id2prot[id];
					foreach (Protection target in targets)
					{
						edges.Add(new DependencyResolver.DependencyGraphEdge(prot2, target));
						roots.Remove(target);
					}
				}
				AfterProtectionAttribute after = protType.GetCustomAttributes(typeof(AfterProtectionAttribute), false).Cast<AfterProtectionAttribute>().SingleOrDefault<AfterProtectionAttribute>();
				if (after != null)
				{
					IEnumerable<Protection> targets2 = from id in after.Ids
					select id2prot[id];
					foreach (Protection target2 in targets2)
					{
						edges.Add(new DependencyResolver.DependencyGraphEdge(target2, prot2));
						roots.Remove(prot2);
					}
				}
			}
			IEnumerable<Protection> sorted = this.SortGraph(roots, edges);
			return sorted.ToList<Protection>();
		}
public IList < Protection > SortDependency ( ) { List < DependencyResolver . DependencyGraphEdge > edges = new List < DependencyResolver . DependencyGraphEdge > ( ) ; HashSet < Protection > roots = new HashSet < Protection > ( this . protections ) ; Dictionary < string , Protection > id2prot = this . protections . ToDictionary ( ( Protection prot ) => prot . FullId , ( Protection prot ) => prot ) ; foreach ( Protection prot2 in this . protections ) { Type protType = prot2 . GetType ( ) ; BeforeProtectionAttribute before = protType . GetCustomAttributes ( typeof ( BeforeProtectionAttribute ) , false ) . Cast < BeforeProtectionAttribute > ( ) . SingleOrDefault < BeforeProtectionAttribute > ( ) ; if ( before != null ) { IEnumerable < Protection > targets = from id in before . Ids select id2prot [ id ] ; foreach ( Protection target in targets ) { edges . Add ( new DependencyResolver . DependencyGraphEdge ( prot2 , target ) ) ; roots . Remove ( target ) ; } } AfterProtectionAttribute after = protType . GetCustomAttributes ( typeof ( AfterProtectionAttribute ) , false ) . Cast < AfterProtectionAttribute > ( ) . SingleOrDefault < AfterProtectionAttribute > ( ) ; if ( after != null ) { IEnumerable < Protection > targets2 = from id in after . Ids select id2prot [ id ] ; foreach ( Protection target2 in targets2 ) { edges . Add ( new DependencyResolver . DependencyGraphEdge ( target2 , prot2 ) ) ; roots . Remove ( prot2 ) ; } } } IEnumerable < Protection > sorted = this . SortGraph ( roots , edges ) ; return sorted . ToList < Protection > ( ) ; }
Sort the protection according to their dependency.
Sort the protection according to their dependency .
Sorted protections with respect to dependencies.
Sorted protections with respect to dependencies .
The protections contain circular dependencies.
The protections contain circular dependencies .