Esempio n. 1
0
        public bool DeepCompare()
        {
            bool   isIdentical = false;
            var    deepex      = new DeepEx();
            string workingDir  = @"E:\Jszomor\source\repos\jszomorCAD\jCAD.PID_Builder";            // company desktop
            //string workingDir = @"C:\Users\JANO\source\repos\jszomorCAD\jCAD.PID_Builder"; // home laptop
            //string workingDir = @"C:\Users\Jszomor\source\repos\jszomorCAD\jCAD.PID_Builder"; // company laptop

            var JsonCompareFile  = Path.Combine(workingDir, "JsonCompareResult.txt");
            var JsonPIDBuild     = Path.Combine(workingDir, "JsonPIDBuild.json");
            var JsonPIDBuildCopy = Path.Combine(workingDir, "JsonPIDBuildCopy.json");

            var blockDeserialize = new BlockDeserializer();
            var jsonPID1         = blockDeserialize.ReadJsonData(JsonPIDBuild);
            var jsonPID2         = blockDeserialize.ReadJsonData(JsonPIDBuildCopy);

            BlockCollector(jsonPID1, jsonPID2, deepex);
            LineCollector(jsonPID1, jsonPID2, deepex);

            if (jsonPID1.Blocks.Count != jsonPID2.Blocks.Count || jsonPID1.Lines.Count != jsonPID2.Lines.Count)
            {
                deepex.Comments.Insert(0, "Differences:");
                deepex.Comments.Add("Length is not equal!");
            }

            if (deepex.Comments.Count == 0)
            {
                deepex.Comments.Add("Files are eqvivalent!");
                isIdentical = true;
            }
            else
            {
                if (deepex.Comments.Contains("Differences:") == false)
                {
                    deepex.Comments.Insert(0, "Differences:");
                }

                deepex.Comments.Add("Files are not eqvivalent!");
            }
            CommentCollector(deepex.Comments, JsonCompareFile);
            return(isIdentical);
        }
Esempio n. 2
0
        public void BlockCollector(JsonPID jsonPID1, JsonPID jsonPID2, DeepEx deepEx)
        {
            var dictBlock1 = new Dictionary <int, JsonBlockProperty>();
            var dictBlock2 = new Dictionary <int, JsonBlockProperty>();

            for (int i = 0; i < jsonPID1.Blocks.Count; i++)
            {
                try
                {
                    dictBlock1.Add(jsonPID1.Blocks[i].Attributes.Internal_Id, jsonPID1.Blocks[i]);
                }
                catch (ArgumentException ex)
                {
                    Console.Write($"InternalId already exist: {jsonPID1.Blocks[i].Attributes.Internal_Id},{ex}");
                }
            }

            for (int i = 0; i < jsonPID2.Blocks.Count; i++)
            {
                try
                {
                    dictBlock2.Add(jsonPID2.Blocks[i].Attributes.Internal_Id, jsonPID2.Blocks[i]);
                }
                catch (ArgumentException ex)
                {
                    Console.Write($"InternalId already exist: {jsonPID2.Blocks[i].Attributes.Internal_Id},{ex}");
                }
            }
            foreach (var i in dictBlock1)
            {
                if (dictBlock2.TryGetValue(i.Key, out JsonBlockProperty compareValue))
                {
                    deepEx.BlockCompare(i.Value, compareValue);
                    deepEx.BlockCustomCompare(i.Value, compareValue);
                    deepEx.BlockAttributesCompare(i.Value, compareValue);
                }
            }
        }
Esempio n. 3
0
        public void LineCollector(JsonPID jsonPID1, JsonPID jsonPID2, DeepEx deepEx)
        {
            var dictLines1 = new Dictionary <int, JsonLineProperty>();
            var dictLines2 = new Dictionary <int, JsonLineProperty>();

            for (int i = 0; i < jsonPID1.Lines.Count; i++)
            {
                try
                {
                    dictLines1.Add(jsonPID1.Lines[i].Internal_Id, jsonPID1.Lines[i]);
                }
                catch (ArgumentException ex)
                {
                    Console.Write($"InternalId already exist: {jsonPID1.Lines[i].Internal_Id},{ex}");
                }
            }
            for (int i = 0; i < jsonPID2.Lines.Count; i++)
            {
                try
                {
                    dictLines1.Add(jsonPID2.Lines[i].Internal_Id, jsonPID1.Lines[i]);
                }
                catch (ArgumentException ex)
                {
                    Console.Write($"InternalId already exist: {jsonPID2.Lines[i].Internal_Id},{ex}");
                }
            }

            foreach (var i in dictLines1)
            {
                if (dictLines2.TryGetValue(i.Key, out JsonLineProperty compareValue))
                {
                    //deepEx.LineTypeComparer(i.Value, compareValue);
                    deepEx.LineCompare(i.Value, compareValue);
                }
            }
        }