Exemplo n.º 1
0
        public void Leave(object level, VisitArgs args)
        {
            if (args.Type == LevelType.Root) return;

            if (level != null) {
                var reservation = _reservations.Pop();
                _writer.Write(reservation);
                BinaryZPacker.Pack(_stream, 0);
            }
        }
Exemplo n.º 2
0
        public void VisitValue(byte? value, VisitArgs args)
        {
            if (args.Metadata.Index > 0)
                BinaryZPacker.Pack(_stream, args.Metadata.Index);

            if (value == null) {
                _stream.WriteByte(BinaryZPacker.Null);
                return;
            }

            _stream.WriteByte((Byte)BinaryInformation.Byte.FixedLength);
            _stream.WriteByte(value.Value);
        }
Exemplo n.º 3
0
 public bool TryVisitValue(VisitArgs args, out short? value)
 {
     if (args.Metadata.Index > 0 && !MoveToIndex(args.Metadata.Index)) {
         value = null;
         return false;
     }
     var length = _reader.ReadByte();
     if (length == BinaryZPacker.Null) {
         value = null;
         return true;
     }
     value = (Int16)BinaryPV64Packer.UnpackS(_stream, length);
     return true;
 }
Exemplo n.º 4
0
        public void Leave(VisitArgs args)
        {
            if (_endOfLevel) {
                _endOfLevel = false;
                return;
            }

            if (args.Type == LevelType.Root) return;
            if (args.Type.IsCollection()) return;
            if (args.Type.IsDictionary()) return;

            MoveToIndex(UInt32.MaxValue);
            _endOfLevel = false;
        }
Exemplo n.º 5
0
        public void VisitValue(short? value, VisitArgs args)
        {
            if (args.Metadata.Index > 0)
                BinaryZPacker.Pack(_stream, args.Metadata.Index);

            if (value == null) {
                _stream.WriteByte(BinaryZPacker.Null);
                return;
            }

            var length = BinaryPV64Packer.GetSLength(value.Value);
            _stream.WriteByte(length);
            BinaryPV64Packer.PackS(_stream, value.Value, length);
        }
Exemplo n.º 6
0
        public void Visit(object level, VisitArgs args)
        {
            if (args.Type == LevelType.Root) return;

            if (args.Metadata.Index > 0)
                BinaryZPacker.Pack(_stream, args.Metadata.Index);

            if (level == null) {
                _stream.WriteByte(BinaryZPacker.Null);
                return;
            }

            _stream.WriteByte(BinaryZPacker.VariabelLength);
            _reservations.Push(_writer.Reserve());
        }
Exemplo n.º 7
0
        public ValueState TryVisit(VisitArgs args)
        {
            if (args.Type == LevelType.Root) return ValueState.Found;

            if (args.Metadata.Index > 0 && !MoveToIndex(args.Metadata.Index))
                return ValueState.NotFound;

            var byteLength = _reader.ReadByte();
            if (byteLength == BinaryZPacker.Null) return ValueState.Null;
            if (byteLength != BinaryZPacker.VariabelLength)
                throw new UnexpectedLengthException(args, byteLength);

            _reader.Skip(4);

            return ValueState.Found;
        }
Exemplo n.º 8
0
        public bool TryVisitValue(VisitArgs args, out byte? value)
        {
            if (args.Metadata.Index > 0 && !MoveToIndex(args.Metadata.Index)) {
                value = null;
                return false;
            }
            var length = _reader.ReadByte();
            if (length == BinaryZPacker.Null) {
                value = null;
                return true;
            }
            if (length != BinaryInformation.Byte.FixedLength)
                throw new UnexpectedLengthException(args, length);

            value = (Byte)_stream.ReadByte();
            return true;
        }
Exemplo n.º 9
0
 public IdentifierHardCodedTraveller(IVisitArgsFactory factory)
 {
     _argsId0   = factory.Construct("Id");
     _argsType1 = factory.Construct("Type");
 }
Exemplo n.º 10
0
        public void VisitValue(Guid? value, VisitArgs args)
        {
            if (args.Metadata.Index > 0)
                BinaryZPacker.Pack(_stream, args.Metadata.Index);

            if (value == null) {
                _stream.WriteByte(BinaryZPacker.Null);
                return;
            }

            _stream.WriteByte((Byte)BinaryInformation.Guid.FixedLength);
            var bytes = BinaryInformation.Guid.Converter.Convert(value.Value);
            _stream.Write(bytes, 0, bytes.Length);
        }
Exemplo n.º 11
0
        public void VisitValue(DateTime? value, VisitArgs args)
        {
            if (args.Metadata.Index > 0)
                BinaryZPacker.Pack(_stream, args.Metadata.Index);

            if (value == null) {
                _stream.WriteByte(BinaryZPacker.Null);
                return;
            }

            if (value.Value.Kind != DateTimeKind.Utc)
                value = value.Value.ToUniversalTime();

            var length = BinaryPV64Packer.GetSLength(value.Value.Ticks);
            _stream.WriteByte(length);
            BinaryPV64Packer.PackS(_stream, value.Value.Ticks, length);
        }
Exemplo n.º 12
0
 public bool TryVisitValue(VisitArgs args, out TimeSpan?value)
 {
     return(TryVisitString(args, s => TimeSpan.Parse(s), out value));
 }
Exemplo n.º 13
0
 public bool TryVisitValue(VisitArgs args, out double?value)
 {
     return(TryVisitNumber(args, v => (double?)v, out value));
 }
Exemplo n.º 14
0
 public bool TryVisitValue(VisitArgs args, out ulong?value)
 {
     return(TryVisitNumber(args, v => (ulong?)v, out value));
 }
Exemplo n.º 15
0
 public void Leave(object level, VisitArgs args)
 {
     Statistics.LeaveCount++;
 }
Exemplo n.º 16
0
 public void Visit(object level, VisitArgs args)
 {
     Statistics.VisitCount++;
     _statistics.AckVisited(args);
 }
Exemplo n.º 17
0
 public void VisitValue(Guid?value, VisitArgs args)
 {
     Statistics.VisitGuidCount++;
     _statistics.AckVisited(args);
 }
Exemplo n.º 18
0
 public void VisitValue(string value, VisitArgs args)
 {
     Statistics.VisitStringCount++;
     _statistics.AckVisited(args);
 }
Exemplo n.º 19
0
 public void VisitValue(DateTime?value, VisitArgs args)
 {
     Statistics.VisitDateTimeCount++;
     _statistics.AckVisited(args);
 }
Exemplo n.º 20
0
        public bool TryVisitValue(VisitArgs args, out byte[] value)
        {
            if (args.Metadata.Index > 0 && !MoveToIndex(args.Metadata.Index)) {
                value = null;
                return false;
            }
            var length = _reader.ReadByte();
            if (length == BinaryZPacker.Null) {
                value = null;
                return true;
            }

            var lengthToRead = length == BinaryZPacker.VariabelLength ? _reader.ReadV() : length;

            value = _reader.ReadBlob(lengthToRead);
            return true;
        }
Exemplo n.º 21
0
 public void VisitValue(decimal?value, VisitArgs args)
 {
     Statistics.VisitDecimalCount++;
     _statistics.AckVisited(args);
 }
Exemplo n.º 22
0
 public void VisitValue(TimeSpan?value, VisitArgs args)
 {
     Statistics.VisitTimeSpanCount++;
     _statistics.AckVisited(args);
 }
Exemplo n.º 23
0
 public void VisitValue(byte?value, VisitArgs args)
 {
     Statistics.VisitByteCount++;
     _statistics.AckVisited(args);
 }
Exemplo n.º 24
0
 public bool TryVisitValue(VisitArgs args, out float?value)
 {
     return(TryVisitNumber(args, v => (float?)v, out value));
 }
Exemplo n.º 25
0
 public void VisitValue(short?value, VisitArgs args)
 {
     Statistics.VisitInt16Count++;
     _statistics.AckVisited(args);
 }
Exemplo n.º 26
0
 public bool TryVisitValue(VisitArgs args, out decimal?value)
 {
     return(TryVisitNumber(args, v => (decimal?)v, out value));
 }
Exemplo n.º 27
0
 public void VisitValue(uint?value, VisitArgs args)
 {
     Statistics.VisitUInt32Count++;
     _statistics.AckVisited(args);
 }
Exemplo n.º 28
0
 public bool TryVisitValue(VisitArgs args, out DateTime?value)
 {
     return(TryVisitString(args,
                           s => DateTime.Parse(s, JsonEncoding.DateTimeFormat,
                                               DateTimeStyles.RoundtripKind), out value));
 }
Exemplo n.º 29
0
 public bool TryVisitValue(VisitArgs args, out DateTime? value)
 {
     if (args.Metadata.Index > 0 && !MoveToIndex(args.Metadata.Index)) {
         value = null;
         return false;
     }
     var length = _reader.ReadByte();
     if (length == BinaryZPacker.Null) {
         value = null;
         return true;
     }
     value = new DateTime(BinaryPV64Packer.UnpackS(_stream, length), DateTimeKind.Utc).ToLocalTime();
     return true;
 }
Exemplo n.º 30
0
        public void VisitValue(string value, VisitArgs args)
        {
            if (args.Metadata.Index > 0)
                BinaryZPacker.Pack(_stream, args.Metadata.Index);

            if (value == null) {
                _stream.WriteByte(BinaryZPacker.Null);
                return;
            }

            if (value.Length < BinaryZPacker.VariabelLength)
                _stream.WriteByte((Byte)value.Length);
            else {
                _stream.WriteByte(BinaryZPacker.VariabelLength);
                BinaryV32Packer.PackU(_stream, (uint)value.Length);
            }
            var bytes = BinaryInformation.String.Converter.Convert(value);
            _stream.Write(bytes, 0, bytes.Length);
        }
Exemplo n.º 31
0
 public ComplexGraphProperty(SerializableProperty property, IGraphType propertyType)
 {
     _property = property;
     _propertyType = propertyType;
     _args = property.CreateVisitArgs();
 }
Exemplo n.º 32
0
        public void VisitValue(byte[] value, VisitArgs args)
        {
            if (args.Metadata.Index > 0)
                BinaryZPacker.Pack(_stream, args.Metadata.Index);

            if (value == null) {
                _stream.WriteByte(BinaryZPacker.Null);
                return;
            }

            if (value.Length < BinaryZPacker.VariabelLength)
                _stream.WriteByte((Byte) value.Length);
            else {
                _stream.WriteByte(BinaryZPacker.VariabelLength);
                BinaryV32Packer.PackU(_stream, (uint)value.Length);
            }
            _stream.Write(value, 0, value.Length);
        }
Exemplo n.º 33
0
 public ComplexGraphProperty(SerializableProperty property, IGraphType propertyType, VisitArgs args)
 {
     _property     = property;
     _propertyType = propertyType;
     _args         = args;
 }
Exemplo n.º 34
0
 public void VisitValue(ulong?value, VisitArgs args)
 {
     Statistics.VisitUInt64Count++;
     _statistics.AckVisited(args);
 }
Exemplo n.º 35
0
 public void VisitValue(double?value, VisitArgs args)
 {
     Statistics.VisitDoubleCount++;
     _statistics.AckVisited(args);
 }
Exemplo n.º 36
0
 public void VisitValue(bool?value, VisitArgs args)
 {
     Statistics.VisitBooleanCount++;
     _statistics.AckVisited(args);
 }
Exemplo n.º 37
0
 public void VisitValue(float?value, VisitArgs args)
 {
     Statistics.VisitSingleCount++;
     _statistics.AckVisited(args);
 }
Exemplo n.º 38
0
 public Int16GraphProperty(SerializableProperty property)
 {
     _property = property;
     _args = property.CreateVisitArgs();
 }
Exemplo n.º 39
0
 public void AckVisited(VisitArgs args)
 {
     _visitedArgs.Add(args);
 }