Exemple #1
0
        // ----------------< perform In Coming dependency using Complete TypeTable >----------------
        public void dependencyAnalysisAll(string directoryName)
        {
            List <string> pattern = new List <string>();

            pattern.Add("*.cs");

            FileManager fm = new FileManager();

            string[] files = fm.getFiles(pathNameForFatching, pattern, true).ToArray();

            if (files.Length != 0)
            {
                try
                {
                    Analyzer.doRelationAnalysis(files);
                    List <ElemRelation> relationship = Analyzer.getRelationshipTable();

                    PackageDependency  pd      = new PackageDependency();
                    List <ElemPackage> package = pd.getPackageDependency();

                    RemoveDuplicate     rd            = new RemoveDuplicate();
                    List <ElemRelation> relationship1 = rd.removeDuplicate(relationship);
                    List <ElemPackage>  package1      = rd.removePDuplicate(package);

                    List <ElemRelation> relationshipTo = new List <ElemRelation>();
                    foreach (ElemRelation er in relationship1)
                    {
                        if (Path.GetDirectoryName(er.filenameto).Equals(directoryName))
                        {
                            relationshipTo.Add(er);
                        }
                    }

                    List <ElemPackage> packageTo = new List <ElemPackage>();
                    foreach (ElemPackage ep in package)
                    {
                        if (Path.GetDirectoryName(ep.filenameto).Equals(directoryName))
                        {
                            ElemPackage e = new ElemPackage();
                            e.filenamefrom = ep.filenamefrom;
                            e.filenameto   = ep.filenameto;
                            packageTo.Add(e);
                        }
                    }

                    XMLEncoderDecoder xe = new XMLEncoderDecoder();
                    dependencyAllResult = xe.dependencyResultXML(relationshipTo, packageTo);
                }
                catch { }
            }
            else
            {
                return;
            }
        }
        public List <ElemPackage> getPackageDependency()
        {
            List <ElemRelation>         relation = RepositoryForRelation.storageForRelationship_;
            List <ElemPackage>          package  = new List <ElemPackage>();
            Dictionary <string, string> package1 = new Dictionary <string, string>();

            try
            {
                //foreach (ElemRelation e in relation)
                //{
                //if (!e.filenamefrom.Equals(e.filenameto))
                //{
                //    package1.Add(e.filenamefrom,e.filenameto);
                //}

                //}

                foreach (ElemRelation e in relation)
                {
                    ElemPackage ep = new ElemPackage();
                    if (!e.filenamefrom.Equals(e.filenameto))
                    {
                        ep.filenamefrom = e.filenamefrom;
                        ep.filenameto   = e.filenameto;
                        package.Add(ep);
                    }
                }

                //foreach (ElemRelation e in relation)
                //{
                //    if (!e.filenamefrom.Equals(e.filenameto))
                //    {
                //        foreach (ElemPackage v in package)
                //        {
                //            if (!v.filenamefrom.Equals(e.filenamefrom) && !v.filenameto.Equals(e.filenameto))
                //            {
                //                ElemPackage ep=new ElemPackage();
                //                ep.filenamefrom=e.filenamefrom;
                //                ep.filenameto=e.filenameto;
                //                package.Add(ep);
                //            }
                //        }
                //    }
                //}
            }
            catch { }
            return(package);
        }
        static void Main(string[] args)
        {
            string[]      dir  = Directory.GetDirectories(Path.GetFullPath("../../../TESTFOLDER"));
            List <string> dir1 = new List <string>();

            foreach (string d in dir)
            {
                dir1.Add(d);
            }
            XMLEncoderDecoder xed = new XMLEncoderDecoder();

            Console.Write("ProjectList:\n{0}", xed.projectXML(dir1));

            repositoryForTestUP();
            Console.Write("\nType Table XML:\n{0}", xed.typeTableXML(RepositoryForOutput.storageForOutput_));

            List <ElemPackage> package = new List <ElemPackage>();
            ElemPackage        ep      = new ElemPackage();

            ep.filenamefrom = "file1";
            ep.filenameto   = "file2";
            ElemPackage ep1 = new ElemPackage();

            ep1.filenamefrom = "file3";
            ep1.filenameto   = "file4";
            package.Add(ep);
            package.Add(ep1);
            Console.Write("\nDependency Result XML:\n{0}", xed.dependencyResultXML(RepositoryForRelation.storageForRelationship_, package));

            List <Elem> type = xed.typeTableDecoding(xed.typeTableXML(RepositoryForOutput.storageForOutput_));

            foreach (Elem e in type)
            {
                Console.Write("\n {0} {1} {2} {3}", e.filename, e.namespacename, e.type, e.name);
            }
        }
Exemple #4
0
        // --------< Decode Package Dependency Result from the XML string >---------

        public List <ElemPackage> packageDependencyResult(string result)
        {
            XDocument doc = XDocument.Parse(result.ToString());
            var       qp  = from x in
                            doc.Elements("Dependency")
                            .Elements("Package")
                            .Elements()
                            select x;
            List <ElemPackage> packageTest = new List <ElemPackage>();
            ElemPackage        el          = null;
            int t = 0;

            foreach (var elem in qp)
            {
                if (t == 0)
                {
                    el = new ElemPackage();
                }
                if (elem.Name.ToString().Equals("PackageFrom"))
                {
                    el.filenamefrom = elem.Value;
                    t++;
                }
                if (elem.Name.ToString().Equals("PackageTo"))
                {
                    el.filenameto = elem.Value;
                    t++;
                }
                if (t == 2)
                {
                    packageTest.Add(el);
                    t = 0;
                }
            }
            return(packageTest);
        }
        // --------< Decode Package Dependency Result from the XML string >---------

        public List<ElemPackage> packageDependencyResult(string result)
        {
            XDocument doc = XDocument.Parse(result.ToString());
            var qp = from x in
                         doc.Elements("Dependency")
                         .Elements("Package")
                     .Elements()
                     select x;
           List<ElemPackage> packageTest = new List<ElemPackage>();
           ElemPackage el = null;
           int t = 0;
           foreach (var elem in qp)
           {
               if (t == 0)
               {
                   el = new ElemPackage();
               }
               if (elem.Name.ToString().Equals("PackageFrom"))
               {
                   el.filenamefrom = elem.Value;
                   t++;
               }
               if (elem.Name.ToString().Equals("PackageTo"))
               {
                   el.filenameto = elem.Value;
                   t++;
               }              
               if (t == 2)
               {
                   packageTest.Add(el);
                   t = 0;
               }
           }
            return packageTest;
        }
        public List<ElemPackage> getPackageDependency()
        {
            List<ElemRelation> relation = RepositoryForRelation.storageForRelationship_;
            List<ElemPackage> package=new List<ElemPackage>();
            Dictionary<string, string> package1 = new Dictionary<string, string>();
            try
            {
                //foreach (ElemRelation e in relation)
                //{
                //if (!e.filenamefrom.Equals(e.filenameto))
                //{
                //    package1.Add(e.filenamefrom,e.filenameto);
                //}

                //}

                foreach (ElemRelation e in relation)
                {
                    ElemPackage ep = new ElemPackage();
                    if (!e.filenamefrom.Equals(e.filenameto))
                    {
                        ep.filenamefrom = e.filenamefrom;
                        ep.filenameto = e.filenameto;
                        package.Add(ep);
                    }
                }

                //foreach (ElemRelation e in relation)
                //{
                //    if (!e.filenamefrom.Equals(e.filenameto))
                //    {
                //        foreach (ElemPackage v in package)
                //        {
                //            if (!v.filenamefrom.Equals(e.filenamefrom) && !v.filenameto.Equals(e.filenameto))
                //            {
                //                ElemPackage ep=new ElemPackage();
                //                ep.filenamefrom=e.filenamefrom;
                //                ep.filenameto=e.filenameto;
                //                package.Add(ep);
                //            }
                //        }
                //    }
                //}
            }
            catch { }
            return package;
        }
        static void Main(string[] args)
        {
            string[] dir = Directory.GetDirectories(Path.GetFullPath("../../../TESTFOLDER"));
            List<string> dir1 = new List<string>();
            foreach (string d in dir)
                dir1.Add(d);
            XMLEncoderDecoder xed=new XMLEncoderDecoder();
            Console.Write("ProjectList:\n{0}", xed.projectXML(dir1));

            repositoryForTestUP();
            Console.Write("\nType Table XML:\n{0}", xed.typeTableXML(RepositoryForOutput.storageForOutput_));

            List<ElemPackage> package = new List<ElemPackage>();
            ElemPackage ep = new ElemPackage();
            ep.filenamefrom = "file1";
            ep.filenameto = "file2";
            ElemPackage ep1 = new ElemPackage();
            ep1.filenamefrom = "file3";
            ep1.filenameto = "file4";
            package.Add(ep);
            package.Add(ep1);
            Console.Write("\nDependency Result XML:\n{0}", xed.dependencyResultXML(RepositoryForRelation.storageForRelationship_,package));

            List<Elem> type = xed.typeTableDecoding(xed.typeTableXML(RepositoryForOutput.storageForOutput_));
            foreach (Elem e in type)
                Console.Write("\n {0} {1} {2} {3}", e.filename, e.namespacename, e.type, e.name);
        }