Exemplo n.º 1
0
        public void Serialize(Stream output, XPathItemFactory itemFactory, XmlQualifiedName method)
        {
            if (this.Content == null) throw new InvalidOperationException("Content cannot be null.");

             XPathItem item = this.Content;

             if (method == ExtensionMethods.Base64Binary) {

            byte[] buffer = (!item.IsNode && item.XmlType.TypeCode == XmlTypeCode.Base64Binary) ?
               (byte[])item.TypedValue
               : Convert.FromBase64String(item.Value);

            output.Write(buffer, 0, buffer.Length);

             } else if (method == ExtensionMethods.HexBinary) {

            byte[] buffer = (!item.IsNode && item.XmlType.TypeCode == XmlTypeCode.HexBinary) ?
               (byte[])item.TypedValue :
               fromBinHexString(item.Value);

            output.Write(buffer, 0, buffer.Length);

             } else {

            var serialization = new XPathSerializationOptions {
               Indent = this.Indent,
               OmitXmlDeclaration = this.OmitXmlDeclaration,
               MediaType = this.MediaType,
               Method = method,
               DocTypePublic = this.DocTypePublic,
               DocTypeSystem = this.DocTypeSystem,
               Encoding = this.Encoding,
               ByteOrderMark = this.ByteOrderMark
            };

            itemFactory.Serialize(item, output, serialization);
             }
        }
Exemplo n.º 2
0
        public void Serialize(TextWriter output, XPathItemFactory itemFactory)
        {
            if (this.Content == null) {
            return;
             }

             var serialization = new XPathSerializationOptions {
            Method = this.Method,
             };

             itemFactory.Serialize(this.Content, output, serialization);
        }