コード例 #1
0
 public void Add(string schema, SchemaParser parser)
 {
     if (!_map.ContainsKey(schema))
     {
         _map.Add(schema, parser);
     }
 }
コード例 #2
0
        private void expandImports(SchemaMap map)
        {
            foreach (IXsdNode node in GetAllNodes())
            {
                XsdImportInclude inc = node as XsdImportInclude;
                if (inc != null)
                {
                    string sl = inc.SchemaLocation;
                    if (map != null)
                    {
                        if (!(sl.Contains("/") || sl.Contains("\\")))
                        {
                            sl = Path.Combine(Path.GetDirectoryName(_filename), sl);
                        }
                        SchemaParser schema = map.Get(sl);
                        if (schema == null)
                        {
                            if (map.OpenAllDontAsk)
                            {
                                schema = new SchemaParser(sl, map);
                                map.Add(sl, schema);
                            }
                            else
                            {
                                Cursor cursor = Mouse.OverrideCursor;
                                Mouse.OverrideCursor = null;
                                TaskDialogResult res = TaskDialog.Show(
                                    new TaskDialogOptions
                                {
                                    AllowDialogCancellation = true,
                                    Owner           = Application.Current.MainWindow,
                                    Title           = "Update xsd location",
                                    MainInstruction =
                                        "Open schema " + sl + " ?",
                                    //Content = "Old location:\n" + Data.ValidationData.Xsd + "\nUpdated location:\n" + newXsdLocation,
                                    CommandButtons = new[] { "Yes", "Yes, all", "No" },
                                    MainIcon       = VistaTaskDialogIcon.Information,
                                    //ExpandedInfo = "Source: " + source.XPath + "\nTarget: " + target.XPath
                                });

                                switch (res.CommandButtonResult)
                                {
                                case 0:     //yes
                                    schema = new SchemaParser(sl, map);
                                    map.Add(sl, schema);
                                    break;

                                case 1:     //open all
                                    map.OpenAllDontAsk = true;
                                    schema             = new SchemaParser(sl, map);
                                    map.Add(sl, schema);
                                    break;

                                case 2:     //no
                                case null:  //cancel
                                    break;
                                }
                                Mouse.OverrideCursor = cursor;
                            }
                        }
                        if (schema != null)
                        {
                            var xn = schema.GetVirtualRoot();
                            ((XsdNode)node).AddKids(xn);
                        }
                    }
                }
            }
        }