XmlReader、XmlWriter

XmlReader

public abstract partial class XmlReader : IDisposable
{
    public virtual void Close()
    {
    }

    public void Dispose()
    {
        Dispose(true);
    }

    protected virtual void Dispose(bool disposing)
    {
        if (disposing && ReadState != ReadState.Closed)
        {
            Close();
        }
    }

    public virtual async Task<object> ReadContentAsObjectAsync()
    {
        if (!CanReadContentAs())
        {
            throw CreateReadContentAsException("ReadContentAsObject");
        }
        return await InternalReadContentAsStringAsync().ConfigureAwait(false);
    }

    public virtual async Task<object> ReadElementContentAsAsync(Type returnType, IXmlNamespaceResolver namespaceResolver)
    {
        if (await SetupReadElementContentAsXxxAsync("ReadElementContentAs").ConfigureAwait(false))
        {
            object value = await ReadContentAsAsync(returnType, namespaceResolver).ConfigureAwait(false);
            await FinishReadElementContentAsXxxAsync().ConfigureAwait(false);
return value; } } }

 

XmlWriter

public abstract partial class XmlWriter : IDisposable
{
    public virtual void Close()
    {
    }

    public void Dispose()
    {
        Dispose(true);
    }

    protected virtual void Dispose(bool disposing)
    {
        if (disposing && WriteState != WriteState.Closed)
        {
            Close();
        }
    }


    private async Task WriteAttributeStringAsyncHelper(Task task, string value)
    {
        await task.ConfigureAwait(false);
        await WriteStringAsync(value).ConfigureAwait(false);
        await WriteEndAttributeAsync().ConfigureAwait(false);
    }
}

 

posted @ 2016-11-23 13:46  茗::流  阅读(144)  评论(0)    收藏  举报
如有雷同,纯属参考。如有侵犯你的版权,请联系我。