コード例 #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
ファイル: Program.cs プロジェクト: zlphoenix/LearnCSharp
        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
ファイル: Program.cs プロジェクト: zlphoenix/LearnCSharp
        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
ファイル: Program.cs プロジェクト: zlphoenix/LearnCSharp
        /// <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;
        }