コード例 #1
0
        public static FHXCompareResultList CompareObjects(FHXObject a, FHXObject b)
        {
            FHXCompareResultList res = new FHXCompareResultList();

            List <FHXParameter> psa = a.GetAllParameters();
            List <FHXParameter> psb = b.GetAllParameters();

            foreach (var pa in psa)
            {
                string rpath = pa.RelativePath(a);
                //Check if b contains the parameter
                if (psb.Any(i => i.RelativePath(b) == rpath))
                {
                    //If it contains it
                    //FHXParameter pb = psb.Single(i => i.RelativePath(b) == rpath);
                    FHXParameter pb = psb.Where(i => i.RelativePath(b) == rpath).ToArray()[0];
                    if (pa.Value != pb.Value)
                    {
                        res.Add(a, pa, FHXCompareType.DIFFERENT);
                        res.Add(b, pb, FHXCompareType.DIFFERENT);
                    }
                }
                else
                {
                    //If not
                    res.Add(a, pa, FHXCompareType.IN);
                }
            }

            foreach (var pb in psb)
            {
                string rpath = pb.RelativePath(b);
                //Check if b contains the parameter
                if (!psb.Any(i => i.RelativePath(b) == rpath))
                {
                    //If not
                    res.Add(b, pb, FHXCompareType.IN);
                }
            }

            return(res);
        }
コード例 #2
0
ファイル: FHXExporter.cs プロジェクト: FuSoftware/FHXTools
        public static void ExportParameters(FHXObject obj, string file, bool recursive = true)
        {
            using (var pkg = new ExcelPackage())
            {
                var wbk = pkg.Workbook;
                var sht = wbk.Worksheets.Add("Parameters");

                sht.Cells[1, 1].Value = "Path";
                sht.Cells[1, 2].Value = "Value";

                List <FHXParameter> parameters = obj.GetAllParameters();
                int i = 2;

                foreach (var p in parameters)
                {
                    sht.Cells[i, 1].Value = p.Path;
                    sht.Cells[i, 2].Value = p.Value;
                    i++;
                }

                pkg.SaveAs(new FileInfo(file));
            }
        }
コード例 #3
0
        public static Dictionary <string, List <FHXSearchResult> > CheckAffectations(string[] affectations, FHXObject root)
        {
            Stopwatch sw = new Stopwatch();

            sw.Start();
            long counter = 0;
            long max     = affectations.Length;
            //max = 26;
            Dictionary <string, List <FHXSearchResult> > results = new Dictionary <string, List <FHXSearchResult> >();
            List <FHXParameter> ps = root.GetAllParameters().Where(p => p.Name == "REF").ToList();


            Parallel.For(0, max, (i) =>
            {
                results[affectations[i]] = CheckAffectation(affectations[i], root, null, ps);
                Interlocked.Increment(ref counter);
                if (counter % 25 == 0)
                {
                    Console.WriteLine("Processed {0}/{1}", counter, affectations.Length);
                }
            });

            /*
             * for (long i=0; i < max; i++){
             *  results[affectations[i]] = CheckAffectation(affectations[i], root, null, ps);
             *  counter++;
             *  if (counter % 25 == 0)
             *  {
             *      Console.WriteLine("Processed {0}/{1}", counter, affectations.Length);
             *  }
             * };
             */
            sw.Stop();
            Console.WriteLine("Looked up affectations in {0} ms", sw.ElapsedMilliseconds);

            return(results);
        }
コード例 #4
0
 public static string Extract(FHXObject root, string path)
 {
     return(Extract(root.GetAllParameters(), path));
 }
コード例 #5
0
 public static List <string> ExtractList(FHXObject root, List <string> path)
 {
     return(ExtractList(root.GetAllParameters(), path));
 }
コード例 #6
0
 public static List <FHXParameter> ExtractPattern(FHXObject root, dynamic script)
 {
     return(ExtractPattern(root.GetAllParameters(), script));
 }