Esempio n. 1
0
        public void Compare()
        {
            this.Cursor = Cursors.AppStarting;

            try
            {
                Status = new KeyValuePair <string, int>("Comparing schemas...", 0);

                // The main diff tree
                DiffBuilder builder = new DiffBuilder();
                builder.Comparing += new XmlSchemaLoadingHandler(delegate(object sender, float perc)
                {
                    if (StatusChanged != null)
                    {
                        StatusChanged(this, new StatusChangedEventArgs()
                        {
                            Text = "Comparing schemas...", Progress = (int)(perc * 100)
                        });
                    }
                });
                schemaSet1 = LoadSchemaSet(schema1);
                schemaSet2 = LoadSchemaSet(schema2);
                DiffTree differenceTree = builder.BuildTree(schemaSet1, schemaSet2);

                // SEt the initial schema elemnts
                schemaObjectA.SchemaObject = schemaSet1.Elements[0];
                schemaObjectB.SchemaObject = schemaSet2.Elements[0];
                schemaObjectA.Title        = schema1;
                schemaObjectB.Title        = schema2;

                // Draw the difference tree
                trvOverview.Nodes.Clear();

                // Add the nodes
                TreeNode node = trvOverview.Nodes.Add("root", "Comparison Summary", "root", "root");
                node.Tag = differenceTree;
                ShowDiffTreeNodes(differenceTree.Nodes, node, "/");
                //trvOverview.Nodes[0].Expand();

                Status = new KeyValuePair <string, int>("Comparison Complete...", 100);

                if (differenceTree.CountDifferences() == 0)
                {
                    throw new NoDifferenceException();
                }
            }
            catch (NoDifferenceException e)
            {
                Status = new KeyValuePair <string, int>("Identical schemas encountered.", 0);

                if (MessageBox.Show(
                        String.Format("The schemas '{0}' and '{1}' are identical in structure. Do you still want to see the summary?", schema1, schema2),
                        "Identical Schemas", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1) == DialogResult.No)
                {
                    throw;
                }
            }
            catch (Exception e)
            {
                frmErrorDialog dlg = new frmErrorDialog();
                dlg.Message = "Could not complete comparison";
                dlg.Details = e.ToString();
                dlg.ShowDialog();
                Status = new KeyValuePair <string, int>("Error occured", 0);
                throw;
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
Esempio n. 2
0
 internal UnityDiffTree()
 {
     mInnerTree = new DiffTree();
     mMetaCache = new MetaCache();
 }
Esempio n. 3
0
 public UnityDiffTree()
 {
     mInnerTree = new DiffTree();
     mMetaCache = new MetaCache();
 }