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

ReadContentsAsObject() public méthode

Reads the contents of the current data value.
/// /// The value of equals false, or /// One of the ReadContents methods has already been called for the current data value. /// /// has been called.
public ReadContentsAsObject ( ) : object
Résultat object
        public object ReadContentsAsObject()
        {
            switch (this.innerNumber)
            {
                case Ember.InnerNumber.Boolean:
                    return this.ReadContentsAsBoolean();
                case Ember.InnerNumber.Integer:
                    return this.ReadContentsAsInt64();
                case Ember.InnerNumber.Octetstring:
                    return this.ReadContentsAsByteArray();
                case Ember.InnerNumber.Real:
                    return this.ReadContentsAsDouble();
                case Ember.InnerNumber.Utf8String:
                    return this.ReadContentsAsString();
                case Ember.InnerNumber.RelativeObjectIdentifier:
                    return this.ReadContentsAsInt32Array();
                default:
                    this.AssertRead();
                    throw new InvalidOperationException(
                        "The current data value does not have a contents with primitive encoding.");
            }
        }

Usage Example

Exemple #1
0
        private static void AssertDecode(int expectedInnerNumber, Action <EmberReader> assertEqual, params byte[] input)
        {
            using (var stream = new MemoryStream(input))
                using (var reader = new EmberReader(stream, 1))
                {
                    AssertThrow <InvalidOperationException>(() => reader.InnerNumber.GetHashCode().Ignore());
                    AssertThrow <InvalidOperationException>(() => reader.OuterId.Ignore());
                    AssertThrow <InvalidOperationException>(() => reader.ReadContentsAsObject());
                    Assert.IsFalse(reader.CanReadContents);
                    Assert.IsTrue(reader.Read());
                    Assert.AreEqual(EmberId.CreateApplication(0), reader.OuterId);
                    Assert.AreEqual(expectedInnerNumber, reader.InnerNumber);
                    assertEqual(reader);
                    AssertThrow <InvalidOperationException>(() => reader.ReadContentsAsObject());
                    Assert.IsFalse(reader.Read());

                    reader.Dispose();
                    Assert.IsFalse(reader.CanReadContents);
                    AssertThrow <ObjectDisposedException>(() => reader.InnerNumber.Ignore());
                    AssertThrow <ObjectDisposedException>(() => reader.OuterId.Ignore());
                    AssertThrow <ObjectDisposedException>(() => reader.ReadContentsAsObject());
                }

            using (var writer = XmlWriter.Create(Console.Out, new XmlWriterSettings()
            {
                Indent = true
            }))
            {
                new EmberConverter(GlowTypes.Instance).ToXml(input, writer);
                Console.WriteLine();
                Console.WriteLine();
            }
        }
All Usage Examples Of Lawo.EmberPlusSharp.Ember.EmberReader::ReadContentsAsObject