Beispiel #1
0
        public ValueState TryVisit(VisitArgs args)
        {
            _statistics.VisitCount++;
            _statistics.AckVisited(args);

            if (!ShouldRead(args)) return ValueState.NotFound;

            _statistics.ExpectedLeaveCount++;
            _args.Push(args);
            return ValueState.Found;
        }
Beispiel #2
0
 public void VisitValue(decimal? value, VisitArgs args)
 {
     Statistics.VisitDecimalCount++;
     _statistics.AckVisited(args);
 }
Beispiel #3
0
 public void VisitValue(float? value, VisitArgs args)
 {
     Statistics.VisitSingleCount++;
     _statistics.AckVisited(args);
 }
Beispiel #4
0
 public void VisitValue(ulong? value, VisitArgs args)
 {
     Statistics.VisitUInt64Count++;
     _statistics.AckVisited(args);
 }
Beispiel #5
0
 public void VisitValue(short? value, VisitArgs args)
 {
     Statistics.VisitInt16Count++;
     _statistics.AckVisited(args);
 }
Beispiel #6
0
 public void Visit(object level, VisitArgs args)
 {
     Statistics.VisitCount++;
     _statistics.AckVisited(args);
 }
Beispiel #7
0
 public void VisitValue(Guid? value, VisitArgs args)
 {
     Statistics.VisitGuidCount++;
     _statistics.AckVisited(args);
 }
Beispiel #8
0
 public void VisitValue(DateTime? value, VisitArgs args)
 {
     Statistics.VisitDateTimeCount++;
     _statistics.AckVisited(args);
 }
Beispiel #9
0
 public bool TryVisitValue(VisitArgs args, out string value)
 {
     _statistics.AckVisited(args);
     _statistics.VisitStringCount++;
     value = ReadOnlyNull ? null : "Hello World - " + Guid.NewGuid();
     return ShouldRead(args);
 }
Beispiel #10
0
 public bool TryVisitValue(VisitArgs args, out DateTime? value)
 {
     _statistics.AckVisited(args);
     _statistics.VisitDateTimeCount++;
     value = ReadOnlyNull ? (DateTime?)null : new DateTime(2001, 01, 07, 13, 30, 42);
     return ShouldRead(args);
 }
Beispiel #11
0
 public bool TryVisitValue(VisitArgs args, out TimeSpan? value)
 {
     _statistics.AckVisited(args);
     _statistics.VisitTimeSpanCount++;
     value = ReadOnlyNull ? (TimeSpan?)null : new TimeSpan(12, 30, 00);
     return ShouldRead(args);
 }
Beispiel #12
0
 public bool TryVisitValue(VisitArgs args, out decimal? value)
 {
     _statistics.AckVisited(args);
     _statistics.VisitDecimalCount++;
     value = ReadOnlyNull ? (decimal?)null : 42.5563M;
     return ShouldRead(args);
 }
Beispiel #13
0
 public bool TryVisitValue(VisitArgs args, out double? value)
 {
     _statistics.AckVisited(args);
     _statistics.VisitDoubleCount++;
     value = ReadOnlyNull ? (double?)null : 42.7d;
     return ShouldRead(args);
 }
Beispiel #14
0
 public bool TryVisitValue(VisitArgs args, out float? value)
 {
     _statistics.AckVisited(args);
     _statistics.VisitSingleCount++;
     value = ReadOnlyNull ? (float?)null : 42.3f;
     return ShouldRead(args);
 }
Beispiel #15
0
 public bool TryVisitValue(VisitArgs args, out bool? value)
 {
     _statistics.AckVisited(args);
     _statistics.VisitBooleanCount++;
     value = ReadOnlyNull ? (bool?)null : true;
     return ShouldRead(args);
 }
Beispiel #16
0
 public void VisitValue(TimeSpan? value, VisitArgs args)
 {
     Statistics.VisitTimeSpanCount++;
     _statistics.AckVisited(args);
 }
Beispiel #17
0
 public bool TryVisitValue(VisitArgs args, out Guid? value)
 {
     _statistics.AckVisited(args);
     _statistics.VisitGuidCount++;
     value = ReadOnlyNull ? (Guid?)null : Guid.Empty;
     return ShouldRead(args);
 }
Beispiel #18
0
 public void VisitValue(string value, VisitArgs args)
 {
     Statistics.VisitStringCount++;
     _statistics.AckVisited(args);
 }
Beispiel #19
0
 public bool TryVisitValue(VisitArgs args, out byte[] value)
 {
     _statistics.AckVisited(args);
     _statistics.VisitBlobCount++;
     value = ReadOnlyNull ? null : new byte[] { 1, 2, 3 };
     return ShouldRead(args);
 }
Beispiel #20
0
 public void Leave(object level, VisitArgs args)
 {
     Statistics.LeaveCount++;
 }
Beispiel #21
0
        private bool ShouldRead(VisitArgs args)
        {
            var key = _args.Count == 0 ? args.Name : string.Concat(_args.Peek().Name, "---", args.Name);
            var visitCount = 0;
            if (_propertyVisitCounts.ContainsKey(key))
                visitCount = ++_propertyVisitCounts[key];
            else
                _propertyVisitCounts.Add(key, ++visitCount);

            if (EnumerationLevelTypes.Contains(args.Type)) {

                if (AllowedVisitCount < 0) {
                    var isValid = (visitCount % 2) == 1;
                    //if (ParentIsNestedCollection())
                    //    isValid = !isValid;
                    return isValid;
                }

                return visitCount <= AllowedVisitCount;
            }

            return true;
        }
Beispiel #22
0
 public void VisitValue(byte? value, VisitArgs args)
 {
     Statistics.VisitByteCount++;
     _statistics.AckVisited(args);
 }
Beispiel #23
0
 public void Leave(VisitArgs args)
 {
     var expectedArgs = _args.Pop();
     Assert.AreEqual(expectedArgs, args);
     _statistics.LeaveCount++;
 }
Beispiel #24
0
 public void VisitValue(uint? value, VisitArgs args)
 {
     Statistics.VisitUInt32Count++;
     _statistics.AckVisited(args);
 }
Beispiel #25
0
 public bool TryVisitValue(VisitArgs args, out byte? value)
 {
     _statistics.AckVisited(args);
     _statistics.VisitByteCount++;
     value = ReadOnlyNull ? (byte?) null : 42;
     return ShouldRead(args);
 }
Beispiel #26
0
 public void VisitValue(bool? value, VisitArgs args)
 {
     Statistics.VisitBooleanCount++;
     _statistics.AckVisited(args);
 }
Beispiel #27
0
 public bool TryVisitValue(VisitArgs args, out short? value)
 {
     _statistics.AckVisited(args);
     _statistics.VisitInt16Count++;
     value = ReadOnlyNull ? (short?)null : ++_nextInt16;
     return ShouldRead(args);
 }
Beispiel #28
0
 public void VisitValue(double? value, VisitArgs args)
 {
     Statistics.VisitDoubleCount++;
     _statistics.AckVisited(args);
 }
Beispiel #29
0
 public void AckVisited(VisitArgs args)
 {
     _visitedArgs.Add(args);
 }
 public UnexpectedLengthException(VisitArgs args, uint length)
     : this(args.Name, args.Metadata.Index, length)
 {
 }
Beispiel #31
0
 public UnexpectedLengthException(VisitArgs args, uint length) : this(args.Name, args.Index, length)
 {
 }