示例#1
0
 /// <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);
 }
示例#2
0
        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);
            }
        }
示例#3
0
        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);
        }
示例#4
0
        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;
        }
示例#5
0
        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);
        }
示例#6
0
        /// <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;
        }