private static void WireupDependencies(Assembly asm) { // The stacks are used to avoid cycles among the dependency declarations. if (!IsAssemblyWired(asm) && !__assemblies.Contains(asm)) { __assemblies.Push(asm); try { // Assemblies may have dependencies declared. foreach (WireupDependencyAttribute d in asm.GetCustomAttributes(typeof(WireupDependencyAttribute), false)) { Type t = d.ReliantType; WireupDependencies(t.Assembly); if (typeof(IWireupCommand).IsAssignableFrom(t) && !__types.Contains(t)) InvokeWireupCommand(t); } // Execute the wireup commands declared for the assembly... foreach (WireupAttribute w in asm.GetCustomAttributes(typeof(WireupAttribute), false)) { Type t = w.CommandType; if (!__types.Contains(t)) InvokeWireupCommand(t); } if (!IsAssemblyWired(asm)) __asmTracking.Add(asm.GetSafeLock(), null); } finally { __assemblies.Pop(); } } }
private static bool IsAssemblyWired(Assembly asm) { return __asmTracking.ContainsKey(asm.GetSafeLock()); }