Пример #1
0
        /// <summary>
        /// Load an XmlSchemaSet object
        /// </summary>
        private MohawkCollege.EHR.Util.SimpleXSD.XmlSchemaSet LoadSchemaSet(string fileName)
        {
            List <KeyValuePair <String, XmlSeverityType> > parseErrors = new List <KeyValuePair <String, XmlSeverityType> >();

            MohawkCollege.EHR.Util.SimpleXSD.XmlSchemaSet retVal = new MohawkCollege.EHR.Util.SimpleXSD.XmlSchemaSet();
            retVal.Loading += new XmlSchemaLoadingHandler(retVal_Loading);
            // Read
            retVal.Add(fileName);
            retVal.Load();

            // Any parsing errors or warnings?
            if (parseErrors.Count > 0)
            {
                frmErrorDialog dlg = new frmErrorDialog();
                dlg.Message = String.Format(CultureInfo.CurrentCulture, "Encountered '{0}' warnings and errors processing schema '{1}'...", parseErrors.Count, Path.GetFileName(fileName));
                foreach (KeyValuePair <String, XmlSeverityType> kv in parseErrors)
                {
                    dlg.Details += String.Format("{0}: {1}\r\n", kv.Value, kv.Key);
                }
                dlg.ShowDialog();
            }

            return(retVal);
        }
Пример #2
0
 /// <summary>
 /// Create a new instance of the XmlSchemaType class
 /// </summary>
 public XmlSchemaType(XmlSchemaSet schema, XmlSchemaObject parent) : base(schema, parent)
 {
 }
Пример #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;
            }
        }
Пример #4
0
 /// <summary>
 /// Create a new instance of the XmlSchemaAttribute class
 /// </summary>
 public XmlSchemaAttribute(XmlSchemaSet schema, XmlSchemaObject parent) : base(schema, parent)
 {
 }