Mvp.Xml.XPointer.XPointerReader.CreateAndCacheDocument C# (CSharp) Method

CreateAndCacheDocument() private method

private CreateAndCacheDocument ( XmlReader r ) : XPathDocument
r XmlReader
return System.Xml.XPath.XPathDocument
        private XPathDocument CreateAndCacheDocument(XmlReader r)
        {
            string uri = r.BaseURI;
            XPathDocument doc = new XPathDocument(r, XmlSpace.Preserve);
            r.Close();

            //Can't cache documents with empty base URI
            if (!string.IsNullOrEmpty(uri))
            {
                lock (_cache)
                {
                    if (!_cache.ContainsKey(uri))
                        _cache.Add(uri, new WeakReference(doc));
                }
            }
            return doc;
        }