Example #1
0
 private void LoadXPathDocument()
 {
     if (!string.IsNullOrEmpty(this._documentContent))
     {
         StringReader textReader = new StringReader(this._documentContent);
         this._xpathDocument = new XPathDocument(textReader);
     }
     else if (!string.IsNullOrEmpty(this._documentSource))
     {
         VirtualPath path;
         string      str;
         base.ResolvePhysicalOrVirtualPath(this._documentSource, out path, out str);
         CacheInternal cacheInternal = HttpRuntime.CacheInternal;
         string        key           = "p" + ((str != null) ? str : path.VirtualPathString);
         this._xpathDocument = (XPathDocument)cacheInternal.Get(key);
         if (this._xpathDocument == null)
         {
             CacheDependency dependency;
             using (Stream stream = base.OpenFileAndGetDependency(path, str, out dependency))
             {
                 XmlTextReader reader2;
                 if (str == null)
                 {
                     str = path.MapPath();
                 }
                 if (AppSettings.RestrictXmlControls)
                 {
                     reader2 = new NoEntitiesXmlReader(str, stream);
                 }
                 else
                 {
                     reader2 = new XmlTextReader(str, stream);
                 }
                 this._xpathDocument = new XPathDocument(reader2);
             }
             if (dependency != null)
             {
                 using (dependency)
                 {
                     cacheInternal.UtcInsert(key, this._xpathDocument, dependency);
                 }
             }
         }
     }
 }
Example #2
0
 private void LoadXmlDocument()
 {
     if (!string.IsNullOrEmpty(this._documentContent))
     {
         this._document = new XmlDocument();
         this._document.LoadXml(this._documentContent);
     }
     else if (!string.IsNullOrEmpty(this._documentSource))
     {
         string        physicalPath  = base.MapPathSecure(this._documentSource);
         CacheInternal cacheInternal = HttpRuntime.CacheInternal;
         string        key           = "q" + physicalPath;
         this._document = (XmlDocument)cacheInternal.Get(key);
         if (this._document == null)
         {
             CacheDependency dependency;
             using (Stream stream = base.OpenFileAndGetDependency(null, physicalPath, out dependency))
             {
                 XmlTextReader reader;
                 if (AppSettings.RestrictXmlControls)
                 {
                     reader = new NoEntitiesXmlReader(physicalPath, stream);
                 }
                 else
                 {
                     reader = new XmlTextReader(physicalPath, stream);
                 }
                 this._document = new XmlDocument();
                 this._document.Load(reader);
                 cacheInternal.UtcInsert(key, this._document, dependency);
             }
         }
         lock (this._document)
         {
             this._document = (XmlDocument)this._document.CloneNode(true);
         }
     }
 }