Example #1
0
        /// <summary>
        /// Loads an instance of xml.
        /// Load updated to handle validation when instance doc refers to schema.
        /// </summary>
        /// <param name="file">Xml instance document</param>
        /// <returns></returns>
        public void Load(string file)
        {
            this.Clear();
            loader = new DomLoader(this.site);
            StopFileWatch();

            Uri uri = new Uri(file, UriKind.RelativeOrAbsolute);
            if (!uri.IsAbsoluteUri) {
                Uri resolved = new Uri(new Uri(Directory.GetCurrentDirectory() + "\\"), uri);
                file = resolved.LocalPath;
            }

            this.filename = file;
            this.lastModified = this.LastModTime;
            this.dirty = false;
            StartFileWatch();

            XmlReaderSettings settings = GetReaderSettings();
            settings.ValidationEventHandler += new ValidationEventHandler(OnValidationEvent);
            using (XmlReader reader = XmlReader.Create(file, settings)) {
                this.Document = loader.Load(reader);
            }
            this.xsltFilename = this.loader.XsltFileName;

            // calling this event will cause the XmlTreeView to populate
            FireModelChanged(ModelChangeType.Reloaded, this.doc);
        }
Example #2
0
 public XmlCache(IServiceProvider site, ISynchronizeInvoke sync)
 {
     this.loader = new DomLoader(site);
     this.schemaCache = new SchemaCache(site);
     this.site = site;
     this.sync = sync;
     this.Document = new XmlDocument();
     this.timer.Tick += new EventHandler(Reload);
     this.timer.Interval = 1000;
     this.timer.Enabled = false;
 }