|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Text;
using System.Xml;
namespace System.Security.Cryptography.Xml
{
// the class that provides node subset state and canonicalization function to XmlCDataSection
internal sealed class CanonicalXmlCDataSection : XmlCDataSection, ICanonicalizableNode
{
private bool _isInNodeSet;
public CanonicalXmlCDataSection(string? data, XmlDocument doc, bool defaultNodeSetInclusionState) : base(data, doc)
{
_isInNodeSet = defaultNodeSetInclusionState;
}
public bool IsInNodeSet
{
get { return _isInNodeSet; }
set { _isInNodeSet = value; }
}
public void Write(StringBuilder strBuilder, DocPosition docPos, AncestralNamespaceContextManager anc)
{
if (IsInNodeSet)
strBuilder.Append(Utils.EscapeCData(Data));
}
public void WriteHash(HashAlgorithm hash, DocPosition docPos, AncestralNamespaceContextManager anc)
{
if (IsInNodeSet)
{
byte[] rgbData = Encoding.UTF8.GetBytes(Utils.EscapeCData(Data));
hash.TransformBlock(rgbData, 0, rgbData.Length, rgbData, 0);
}
}
}
}
|