Пример #1
0
        public PlyWriter WriteValue <T>(T value) where T : IConvertible, IFormattable
        {
            EnsureNotClosed();
            EnsureHeaderIsWritten();
            EnsureWriteCallIsValid <T>();

            WriteValueInternal(value);

            _iterator.MoveNext();
            return(this);
        }
Пример #2
0
        public T ReadProperty <T>()
        {
            PlyProperty expected = _iterator.CurrentProperty;

            if (expected is PlyArrayProperty)
            {
                throw ExceptionFactory.GetTryingToReadValueWhenArrayExpectedException(expected);
            }

            _iterator.MoveNext();
            return(ReadPropertyInternal <T>(expected));
        }
Пример #3
0
        public void KeepsTrackOfElements()
        {
            var iterator = new PlyHeaderIterator(ValidHeader);

            Assert.IsTrue(iterator.IsOnFirstElement);
            Assert.IsTrue(iterator.IsOnFirstProperty);
            Assert.IsFalse(iterator.IsIterationDone);
            Assert.AreEqual(iterator.CurrentProperty, ValidHeader.Elements[0].Properties[0]);

            iterator.MoveNext();
            Assert.IsFalse(iterator.IsOnFirstElement);
            Assert.IsFalse(iterator.IsOnFirstProperty);
            Assert.IsFalse(iterator.IsIterationDone);
            Assert.AreEqual(iterator.CurrentElement, 0);
            Assert.AreEqual(iterator.CurrentProperty, ValidHeader.Elements[0].Properties[1]);

            iterator.MoveNext();
            iterator.MoveNext();
            Assert.AreEqual(iterator.CurrentElement, 0);
            Assert.AreEqual(iterator.CurrentProperty, ValidHeader.Elements[0].Properties[0]);

            iterator.MoveNext();
            iterator.MoveNext();
            iterator.MoveNext();
            Assert.IsFalse(iterator.IsOnFirstElement);
            Assert.AreEqual(iterator.CurrentProperty, ValidHeader.Elements[1].Properties[0]);
            Assert.IsTrue(iterator.IsOnFirstProperty);
            iterator.MoveNext();
            iterator.MoveNext();
            Assert.IsTrue(iterator.IsIterationDone);
        }