private void ReadDocumentStreamed(XmlReader xr, Stream sParentStream)
{
Debug.Assert(xr != null);
if(xr == null) throw new ArgumentNullException("xr");
m_ctxGroups.Clear();
m_dictBinPool = new Dictionary<string, ProtectedBinary>();
m_dictBinPoolCopyOnRead = new Dictionary<string, ProtectedBinary>();
KdbContext ctx = KdbContext.Null;
uint uTagCounter = 0;
bool bSupportsStatus = (m_slLogger != null);
try
{
sParentStream.Position.ToString();
sParentStream.Length.ToString();
}
catch(Exception) { bSupportsStatus = false; }
m_bReadNextNode = true;
while(true)
{
if(m_bReadNextNode)
{
if(!xr.Read()) break;
}
else m_bReadNextNode = true;
switch(xr.NodeType)
{
case XmlNodeType.Element:
ctx = ReadXmlElement(ctx, xr);
break;
case XmlNodeType.EndElement:
ctx = EndXmlElement(ctx, xr);
break;
case XmlNodeType.XmlDeclaration:
break; // Ignore
default:
Debug.Assert(false);
break;
}
++uTagCounter;
if(((uTagCounter % 256) == 0) && bSupportsStatus)
m_slLogger.SetProgress((uint)((sParentStream.Position * 100) /
sParentStream.Length));
}
Debug.Assert(ctx == KdbContext.Null);
if(ctx != KdbContext.Null) throw new FormatException();
Debug.Assert(m_ctxGroups.Count == 0);
if(m_ctxGroups.Count != 0) throw new FormatException();
}