Esempio n. 1
0
        /// <summary>
        /// Process the schema object
        /// </summary>
        private void ProcessSchemaObject()
        {
            if (schemaObject == null)
            {
                lblError.Visible = true;
                lblError.Text    = "Object not available";
                return;
            }
            else
            {
                lblError.Visible = false;
            }

            DiffBuilder builder  = new DiffBuilder();
            IDiffNode   diffNode = builder.BuildTree(SchemaObject);

            trvObjectView.Visible = false;
            trvObjectView.Nodes.Clear();
            ShowDiffTreeNodes(new List <IDiffNode>()
            {
                diffNode
            }, null, trvObjectView);
            if (trvObjectView.Nodes.Count > 0)
            {
                trvObjectView.Nodes[0].Expand();
            }
            trvObjectView.Visible = true;
        }
Esempio n. 2
0
        /// <summary>
        /// Process schema
        /// </summary>
        private void ProcessSchema(XmlSchemaSet value)
        {
            lblError.Visible = value == null;

            // Elements
            DiffBuilder builder = new DiffBuilder();

            builder.TreatSequenceAsNode = true;

            List <IDiffNode> diffNodes = new List <IDiffNode>();

            if (value.Elements == null || value.Elements.Count == 0)
            {
                throw new InvalidOperationException("This view requires that a schema have at least one root element!");
            }

            foreach (XmlSchemaElement xse in value.Elements)
            {
                diffNodes.Add(builder.BuildTree(xse));
            }

            trvObjectView.Visible = false;
            trvObjectView.Nodes.Clear();
            ShowDiffTreeNodes(diffNodes, null, trvObjectView);
            trvObjectView.Nodes[0].Expand();
            trvObjectView.Visible = true;
        }
Esempio n. 3
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;
            }
        }