Esempio n. 1
0
        public XmlBinaryStream(XmlWriter writer, XmlBinaryFormat format = XmlBinaryFormat.Base64)
        {
            this.writer = writer;
            switch (format)
            {
            case XmlBinaryFormat.Base64:
                this.writeOperation = writer.WriteBase64;
                break;

            case XmlBinaryFormat.BinHex:
                this.writeOperation = writer.WriteBinHex;
                break;

            default:
                throw new NotSupportedException();
            }
        }
Esempio n. 2
0
        public XmlBinaryStream(XmlReader reader, XmlBinaryFormat format = XmlBinaryFormat.Base64)
        {
            this.reader = reader;
            switch (reader.NodeType)
            {
            case XmlNodeType.Element:
                switch (format)
                {
                case XmlBinaryFormat.Base64:
                    this.readOperation = reader.ReadElementContentAsBase64;
                    break;

                case XmlBinaryFormat.BinHex:
                    this.readOperation = reader.ReadElementContentAsBinHex;
                    break;

                default:
                    throw new NotSupportedException();
                }
                break;

            case XmlNodeType.Attribute:
            case XmlNodeType.Text:
            case XmlNodeType.CDATA:
                switch (format)
                {
                case XmlBinaryFormat.Base64:
                    this.readOperation = reader.ReadContentAsBase64;
                    break;

                case XmlBinaryFormat.BinHex:
                    this.readOperation = reader.ReadContentAsBinHex;
                    break;

                default:
                    throw new NotSupportedException();
                }
                break;

            default:
                throw new ArgumentException("The reader is not in a state where binary data can be read.", "reader");
            }
        }