|
using System;
using System.Collections.Generic;
using System.Text;
using Bulasoft.Common.Elements;
using System.Xml;
namespace Bulasoft.Common.Serialization
{
public class ReaderWriterBase
{
public ReaderWriterBase(XmlDocument doc)
{
_xmlDocument = doc;
}
protected IElement CurrentElement
{
get
{
if (CurrentContext != null)
return CurrentContext.Element;
else
return null;
}
}
public XmlElement CurrentXmlElement
{
get
{
if (CurrentContext != null)
return CurrentContext.XmlElement;
else
return null;
}
}
protected Stack<SerializationContext> savedContext = new Stack<SerializationContext>();
private XmlDocument _xmlDocument;
public XmlDocument XmlDocument
{
get { return _xmlDocument; }
}
private SerializationContext _currentContext;
public SerializationContext CurrentContext
{
get { return _currentContext; }
}
public void RestoreContext()
{
if (savedContext.Count != 0)
{
_currentContext = savedContext.Pop();
}
}
public void SaveContext()
{
if (CurrentContext != null)
savedContext.Push(CurrentContext);
SerializationContext ctx = new SerializationContext();
if (CurrentContext != null)
{
ctx.CacheEntry = CurrentContext.CacheEntry;
ctx.Element = CurrentContext.Element;
ctx.XmlElement = CurrentContext.XmlElement;
}
_currentContext = ctx;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.