public void Sign(XmlSigningNodeWriter writer) { switch (this.type) { case ValueHandleType.Empty: return; case ValueHandleType.Int8: case ValueHandleType.Int16: case ValueHandleType.Int32: writer.WriteInt32Text(this.ToInt()); return; case ValueHandleType.Int64: writer.WriteInt64Text(this.GetInt64()); return; case ValueHandleType.UInt64: writer.WriteUInt64Text(this.GetUInt64()); return; case ValueHandleType.Single: writer.WriteFloatText(this.GetSingle()); return; case ValueHandleType.Double: writer.WriteDoubleText(this.GetDouble()); return; case ValueHandleType.Decimal: writer.WriteDecimalText(this.GetDecimal()); return; case ValueHandleType.DateTime: writer.WriteDateTimeText(this.ToDateTime()); return; case ValueHandleType.TimeSpan: writer.WriteTimeSpanText(this.ToTimeSpan()); return; case ValueHandleType.Guid: writer.WriteGuidText(this.ToGuid()); return; case ValueHandleType.UniqueId: writer.WriteUniqueIdText(this.ToUniqueId()); return; case ValueHandleType.UTF8: writer.WriteEscapedText(this.bufferReader.Buffer, this.offset, this.length); return; case ValueHandleType.Base64: writer.WriteBase64Text(this.bufferReader.Buffer, 0, this.bufferReader.Buffer, this.offset, this.length); return; } writer.WriteEscapedText(this.GetString()); }
public void Sign(XmlSigningNodeWriter writer) { switch (type) { case ValueHandleType.Int8: case ValueHandleType.Int16: case ValueHandleType.Int32: writer.WriteInt32Text(ToInt()); break; case ValueHandleType.Int64: writer.WriteInt64Text(GetInt64()); break; case ValueHandleType.UInt64: writer.WriteUInt64Text(GetUInt64()); break; case ValueHandleType.Single: writer.WriteFloatText(GetSingle()); break; case ValueHandleType.Double: writer.WriteDoubleText(GetDouble()); break; case ValueHandleType.Decimal: writer.WriteDecimalText(GetDecimal()); break; case ValueHandleType.DateTime: writer.WriteDateTimeText(ToDateTime()); break; case ValueHandleType.Empty: break; case ValueHandleType.UTF8: writer.WriteEscapedText(bufferReader.Buffer, offset, length); break; case ValueHandleType.Base64: writer.WriteBase64Text(bufferReader.Buffer, 0, bufferReader.Buffer, offset, length); break; case ValueHandleType.UniqueId: writer.WriteUniqueIdText(ToUniqueId()); break; case ValueHandleType.Guid: writer.WriteGuidText(ToGuid()); break; case ValueHandleType.TimeSpan: writer.WriteTimeSpanText(ToTimeSpan()); break; default: writer.WriteEscapedText(GetString()); break; } }
public void Sign(XmlSigningNodeWriter writer) { switch (_type) { case ValueHandleType.Int8: case ValueHandleType.Int16: case ValueHandleType.Int32: writer.WriteInt32Text(ToInt()); break; case ValueHandleType.Int64: writer.WriteInt64Text(GetInt64()); break; case ValueHandleType.UInt64: writer.WriteUInt64Text(GetUInt64()); break; case ValueHandleType.Single: writer.WriteFloatText(GetSingle()); break; case ValueHandleType.Double: writer.WriteDoubleText(GetDouble()); break; case ValueHandleType.Decimal: writer.WriteDecimalText(GetDecimal()); break; case ValueHandleType.DateTime: writer.WriteDateTimeText(ToDateTime()); break; case ValueHandleType.Empty: break; case ValueHandleType.UTF8: writer.WriteEscapedText(_bufferReader.Buffer, _offset, _length); break; case ValueHandleType.Base64: writer.WriteBase64Text(_bufferReader.Buffer, 0, _bufferReader.Buffer, _offset, _length); break; case ValueHandleType.UniqueId: writer.WriteUniqueIdText(ToUniqueId()); break; case ValueHandleType.Guid: writer.WriteGuidText(ToGuid()); break; case ValueHandleType.TimeSpan: writer.WriteTimeSpanText(ToTimeSpan()); break; default: writer.WriteEscapedText(GetString()); break; } }
public void Sign(XmlSigningNodeWriter writer) { for (int i = 0; i < nsCount; i++) { PrefixHandle prefix = namespaces[i].Prefix; bool found = false; for (int j = i + 1; j < nsCount; j++) { if (Equals(prefix, namespaces[j].Prefix)) { found = true; break; } } if (!found) { int prefixOffset, prefixLength; byte[] prefixBuffer = prefix.GetString(out prefixOffset, out prefixLength); int nsOffset, nsLength; byte[] nsBuffer = namespaces[i].Uri.GetString(out nsOffset, out nsLength); writer.WriteXmlnsAttribute(prefixBuffer, prefixOffset, prefixLength, nsBuffer, nsOffset, nsLength); } } }
public override void StartCanonicalization(Stream stream, bool includeComments, string[] inclusivePrefixes) { if (signing) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.XmlCanonicalizationStarted))); if (signingWriter == null) signingWriter = CreateSigningNodeWriter(); signingWriter.SetOutput(XmlNodeWriter.Null, stream, includeComments, inclusivePrefixes); nsMgr.Sign(signingWriter); signing = true; }
void SignNode(XmlSigningNodeWriter writer) { switch (node.NodeType) { case XmlNodeType.None: break; case XmlNodeType.Element: SignStartElement(writer); for (int i = 0; i < attributeCount; i++) SignAttribute(writer, attributeNodes[i]); writer.WriteEndStartElement(node.IsEmptyElement); break; case XmlNodeType.Text: case XmlNodeType.Whitespace: case XmlNodeType.SignificantWhitespace: case XmlNodeType.CDATA: node.Value.Sign(writer); break; case XmlNodeType.XmlDeclaration: writer.WriteDeclaration(); break; case XmlNodeType.Comment: writer.WriteComment(node.Value.GetString()); break; case XmlNodeType.EndElement: SignEndElement(writer); break; default: throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException()); } }
void SignEndElement(XmlSigningNodeWriter writer) { int prefixOffset, prefixLength; byte[] prefixBuffer = node.Prefix.GetString(out prefixOffset, out prefixLength); int localNameOffset, localNameLength; byte[] localNameBuffer = node.LocalName.GetString(out localNameOffset, out localNameLength); writer.WriteEndElement(prefixBuffer, prefixOffset, prefixLength, localNameBuffer, localNameOffset, localNameLength); }
void SignAttribute(XmlSigningNodeWriter writer, XmlAttributeNode attributeNode) { QNameType qnameType = attributeNode.QNameType; if (qnameType == QNameType.Normal) { int prefixOffset, prefixLength; byte[] prefixBuffer = attributeNode.Prefix.GetString(out prefixOffset, out prefixLength); int localNameOffset, localNameLength; byte[] localNameBuffer = attributeNode.LocalName.GetString(out localNameOffset, out localNameLength); writer.WriteStartAttribute(prefixBuffer, prefixOffset, prefixLength, localNameBuffer, localNameOffset, localNameLength); attributeNode.Value.Sign(writer); writer.WriteEndAttribute(); } else { Fx.Assert(qnameType == QNameType.Xmlns, ""); int prefixOffset, prefixLength; byte[] prefixBuffer = attributeNode.Namespace.Prefix.GetString(out prefixOffset, out prefixLength); int nsOffset, nsLength; byte[] nsBuffer = attributeNode.Namespace.Uri.GetString(out nsOffset, out nsLength); writer.WriteXmlnsAttribute(prefixBuffer, prefixOffset, prefixLength, nsBuffer, nsOffset, nsLength); } }
public override void StartCanonicalization(Stream stream, bool includeComments, string[] inclusivePrefixes) { if (IsClosed) ThrowClosed(); if (Signing) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.XmlCanonicalizationStarted))); FlushElement(); if (signingWriter == null) signingWriter = CreateSigningNodeWriter(); signingWriter.SetOutput(writer, stream, includeComments, inclusivePrefixes); writer = signingWriter; SignScope(signingWriter.CanonicalWriter); }
public override void StartCanonicalization(Stream stream, bool includeComments, string[] inclusivePrefixes) { if (this.IsClosed) { this.ThrowClosed(); } if (this.Signing) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.Runtime.Serialization.SR.GetString("XmlCanonicalizationStarted"))); } this.FlushElement(); if (this.signingWriter == null) { this.signingWriter = this.CreateSigningNodeWriter(); } this.signingWriter.SetOutput(this.writer, stream, includeComments, inclusivePrefixes); this.writer = this.signingWriter; this.SignScope(this.signingWriter.CanonicalWriter); }