[MonoTODO] // FIXME: Check how expanded entity is handled here.
 public TextReader GetRemainder()
 {
     if (entity != null)
     {
         entity.Close();
         entity = null;
         entityNameStack.Pop();
     }
     return(source.GetRemainder());
 }
        public void Resolve()
        {
            if (ActualUri == String.Empty)
            {
                LoadFailed         = true;
                LiteralEntityValue = String.Empty;
                return;
            }

            if (Root.ExternalResources.ContainsKey(ActualUri))
            {
                LiteralEntityValue = (string)Root.ExternalResources [ActualUri];
            }
            Stream s = null;

            try {
                s = resolver.GetEntity(absUri, null, typeof(Stream)) as Stream;
                XmlTextReaderImpl xtr = new XmlTextReaderImpl(ActualUri, s, Root.NameTable);
                // Don't skip Text declaration here. LiteralEntityValue contains it. See spec 4.5
                LiteralEntityValue = xtr.GetRemainder().ReadToEnd();

                Root.ExternalResources.Add(ActualUri, LiteralEntityValue);
                if (Root.ExternalResources.Count > DTDObjectModel.AllowedExternalEntitiesMax)
                {
                    throw new InvalidOperationException("The total amount of external entities exceeded the allowed number.");
                }
            } catch (Exception) {
//				loadException = ex;
                LiteralEntityValue = String.Empty;
                LoadFailed         = true;
//				throw NotWFError ("Cannot resolve external entity. URI is " + ActualUri + " .");
            } finally {
                if (s != null)
                {
                    s.Close();
                }
            }
        }