Lawo.EmberPlusSharp.Ember.EmberReader.ReadContentsAsString C# (CSharp) Méthode

ReadContentsAsString() public méthode

Reads the contents of the current data value as a string.
An error occurred while parsing the EmBER-encoded data, see /// for more information. /// /// The value of is not equal to , /// or /// The contents of the current data value has already been read. /// /// has been called.
public ReadContentsAsString ( ) : string
Résultat string
        public string ReadContentsAsString()
        {
            this.AssertCanReadContents(Ember.InnerNumber.Utf8String);
            return this.readBuffer.ReadUtf8(this.ContentsLength.GetValueOrDefault());
        }

Usage Example

Exemple #1
0
        public void ExceptionTest()
        {
            TestStandardExceptionConstructors <EmberException>();

            AssertThrow <ArgumentNullException>(() => new EmberReader(null, 1).Dispose());
            AssertEmberException("Incorrect length at position 3.", 0x60, 0x03, 0x0D, 0x01, 0xFF, 0x00);

            using (var stream = new MemoryStream(new byte[] { 0x60, 0x03, 0x01, 0x01, 0xFF }))
                using (var reader = new EmberReader(stream, 1))
                {
                    reader.Read();
                    AssertThrow <InvalidOperationException>(() => reader.ReadContentsAsString());
                    reader.ReadContentsAsBoolean();
                }

            AssertEmberException(
                "Unexpected Universal class for outer identifier at position 0.", 0x01, 0x03, 0x01, 0x01, 0xFF);

            AssertEmberException("Unexpected end of stream.", 0x60);

            AssertEmberException("Unexpected end of stream.", 0x60, 0x05, 0x04, 0x03, 0xFF, 0xFE);

            AssertEmberException(
                "Unexpected end of stream at position 9.", 0x60, 0x08, 0x30, 0x06, 0x60, 0x03, 0x01, 0x01, 0xFF);

            AssertEmberException("Unexpected End-of-contents identifier at position 2.", 0x60, 0x02, 0x00, 0x00);

            AssertEmberException("Unexpected number in universal identifier at position 2.", 0x60, 0x03, 0x03, 0x01, 0xFF);

            AssertEmberException("Unexpected context-specific or private identifier at position 2.", 0x60, 0x03, 0x83, 0x01, 0xFF);
            AssertEmberException("Unexpected context-specific or private identifier at position 2.", 0x60, 0x03, 0xC3, 0x01, 0xFF);

            AssertEmberException("Unexpected length for End-of-contents identifier at position 0.", 0x00, 0x01);

            AssertEmberException("Unexpected excess End-of-contents identifier at position 0.", 0x00, 0x00);

            AssertEmberException(
                "Unexpected End-of-contents identifier at position 6 for definite length at position 1.",
                0x60, 0x06, 0x30, 0x80, 0x00, 0x00, 0x00, 0x00);

            AssertEmberException("Unexpected constructed encoding at position 2.", 0x60, 0x03, 0x21, 0x01, 0xFF);

            AssertEmberException(
                "Unexpected indefinite length for primitive data value at position 2.", 0x60, 0x03, 0x01, 0x80, 0xFF);

            AssertEmberException("Unexpected encoding for Real at position 4.", 0x60, 0x03, 0x09, 0x01, 0x00);

            AssertEmberException("Incorrect length for Real at position 4.", 0x60, 0x04, 0x09, 0x02, 0x80, 0x00);

            AssertEmberException(
                "The exponent of the Real at position 4 exceeds the expected range.",
                0x60, 0x06, 0x09, 0x04, 0x81, 0x04, 0x01, 0x01);

            AssertEmberException(
                "The exponent of the Real at position 4 exceeds the expected range.",
                0x60, 0x06, 0x09, 0x04, 0x81, 0xFC, 0x01, 0x01);

            AssertEmberException(
                "The mantissa of the Real at position 4 is zero.", 0x60, 0x05, 0x09, 0x03, 0x80, 0x00, 0x00);

            AssertEmberException(
                "The length at position 1 exceeds the expected range.", 0x60, 0x84, 0x80, 0x00, 0x00, 0x00);

            AssertEmberException("Unexpected zero length for integer.", 0x60, 0x02, 0x02, 0x00);

            ReadAll(0x60, 0x0A, 0x02, 0x08, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF);
            AssertEmberException(
                "The integer, length or exponent at position 4 exceeds the expected range.",
                0x60, 0x0B, 0x02, 0x09, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF);

            ReadAll(0x60, 0x0A, 0x02, 0x08, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
            AssertEmberException(
                "The integer, length or exponent at position 4 exceeds the expected range.",
                0x60, 0x0B, 0x02, 0x09, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);

            ReadAll(0x7F, 0x87, 0xFF, 0xFF, 0xFF, 0x7F, 0x03, 0x01, 0x01, 0xFF);
            AssertEmberException(
                "The identifier number or subidentifier at position 1 exceeds the expected range.",
                0x7F, 0x8F, 0xFF, 0xFF, 0xFF, 0x7F, 0x03, 0x01, 0x01, 0xFF);
        }
All Usage Examples Of Lawo.EmberPlusSharp.Ember.EmberReader::ReadContentsAsString