/// <summary> /// 深度优先探测环 /// </summary> /// <param name="prjInfo"></param> /// <param name="path"></param> public static PrjInfo Deal(PrjInfo prjInfo, Stack <PrjInfo> path) { foreach (var refAssembly in prjInfo.PrjRef.Where(item => (!root.Contains(item)))) { if (path.Contains(refAssembly)) { //发现环 Console.Write(refAssembly.AssemblyName + "<-"); while (path.Peek() != refAssembly) { Console.Write(path.Pop().AssemblyName + "<-"); } Console.Write(refAssembly.AssemblyName + "\t Resolve it?[Y/n]\n"); //var decide = Console.ReadLine(); //if (decide == "Y") //{ //root.Add(refAssembly); //prjInfoDic.Remove(refAssembly.AssemblyName); return(refAssembly); //} } path.Push(refAssembly); var dealedPrj = Deal(refAssembly, path); if (dealedPrj != null) { return(dealedPrj); } path.Pop(); } return(null); }
private static void AddToDics(PrjInfo prjInfo) { if (!prjInfoDic.ContainsKey(prjInfo.AssemblyName)) { prjInfoDic.Add(prjInfo.AssemblyName, prjInfo); } prjInfoFileNameDic.Add(prjInfo.AssemblyName, prjInfo); if (prjInfo.OriginalRef.Count == 0) { root.Add(prjInfo); } }
public static PrjInfo CreatePrjInfo(string prj) { string dllName = GetFileNameWithoutExt(prj); if (prjInfoDic.ContainsKey(dllName)) { Console.WriteLine($"{dllName}\t{prj} load\t {prjInfoDic[dllName].AssemblyPath} before "); return(null); //已经添加过 } var ass = Assembly.ReflectionOnlyLoadFrom(prj); var prjInfo = new PrjInfo(ass); prjInfo.AssemblyPath = prj; AddToDics(prjInfo); return(prjInfo); }
public static PrjInfo CreatePrjInfo(string prj) { string dllName = GetFileNameWithoutExt(prj); if (prjInfoDic.ContainsKey(dllName)) { Console.WriteLine($"{dllName}\t{prj} load\t {prjInfoDic[dllName].AssemblyPath} before "); return null; //已经添加过 } var ass = Assembly.ReflectionOnlyLoadFrom(prj); var prjInfo = new PrjInfo(ass); prjInfo.AssemblyPath = prj; AddToDics(prjInfo); return prjInfo; }
private static void AddToDics(PrjInfo prjInfo) { if (!prjInfoDic.ContainsKey(prjInfo.AssemblyName)) { prjInfoDic.Add(prjInfo.AssemblyName, prjInfo); } prjInfoFileNameDic.Add(prjInfo.AssemblyName, prjInfo); if (prjInfo.OriginalRef.Count == 0) root.Add(prjInfo); }
/// <summary> /// 深度优先探测环 /// </summary> /// <param name="prjInfo"></param> /// <param name="path"></param> public static PrjInfo Deal(PrjInfo prjInfo, Stack<PrjInfo> path) { foreach (var refAssembly in prjInfo.PrjRef.Where(item => (!root.Contains(item)))) { if (path.Contains(refAssembly)) { //发现环 Console.Write(refAssembly.AssemblyName + "<-"); while (path.Peek() != refAssembly) { Console.Write(path.Pop().AssemblyName + "<-"); } Console.Write(refAssembly.AssemblyName + "\t Resolve it?[Y/n]\n"); //var decide = Console.ReadLine(); //if (decide == "Y") //{ //root.Add(refAssembly); //prjInfoDic.Remove(refAssembly.AssemblyName); return refAssembly; //} } path.Push(refAssembly); var dealedPrj = Deal(refAssembly, path); if (dealedPrj != null) return dealedPrj; path.Pop(); } return null; }