Exemple #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;
        }
 public void VisitValue(decimal? value, VisitArgs args)
 {
     Statistics.VisitDecimalCount++;
     _statistics.AckVisited(args);
 }
 public void VisitValue(float? value, VisitArgs args)
 {
     Statistics.VisitSingleCount++;
     _statistics.AckVisited(args);
 }
 public void VisitValue(ulong? value, VisitArgs args)
 {
     Statistics.VisitUInt64Count++;
     _statistics.AckVisited(args);
 }
 public void VisitValue(short? value, VisitArgs args)
 {
     Statistics.VisitInt16Count++;
     _statistics.AckVisited(args);
 }
 public void Visit(object level, VisitArgs args)
 {
     Statistics.VisitCount++;
     _statistics.AckVisited(args);
 }
 public void VisitValue(Guid? value, VisitArgs args)
 {
     Statistics.VisitGuidCount++;
     _statistics.AckVisited(args);
 }
 public void VisitValue(DateTime? value, VisitArgs args)
 {
     Statistics.VisitDateTimeCount++;
     _statistics.AckVisited(args);
 }
Exemple #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);
 }
Exemple #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);
 }
Exemple #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);
 }
Exemple #12
0
 public bool TryVisitValue(VisitArgs args, out decimal? value)
 {
     _statistics.AckVisited(args);
     _statistics.VisitDecimalCount++;
     value = ReadOnlyNull ? (decimal?)null : 42.5563M;
     return ShouldRead(args);
 }
Exemple #13
0
 public bool TryVisitValue(VisitArgs args, out double? value)
 {
     _statistics.AckVisited(args);
     _statistics.VisitDoubleCount++;
     value = ReadOnlyNull ? (double?)null : 42.7d;
     return ShouldRead(args);
 }
Exemple #14
0
 public bool TryVisitValue(VisitArgs args, out float? value)
 {
     _statistics.AckVisited(args);
     _statistics.VisitSingleCount++;
     value = ReadOnlyNull ? (float?)null : 42.3f;
     return ShouldRead(args);
 }
Exemple #15
0
 public bool TryVisitValue(VisitArgs args, out bool? value)
 {
     _statistics.AckVisited(args);
     _statistics.VisitBooleanCount++;
     value = ReadOnlyNull ? (bool?)null : true;
     return ShouldRead(args);
 }
Exemple #16
0
 public void VisitValue(TimeSpan? value, VisitArgs args)
 {
     Statistics.VisitTimeSpanCount++;
     _statistics.AckVisited(args);
 }
Exemple #17
0
 public bool TryVisitValue(VisitArgs args, out Guid? value)
 {
     _statistics.AckVisited(args);
     _statistics.VisitGuidCount++;
     value = ReadOnlyNull ? (Guid?)null : Guid.Empty;
     return ShouldRead(args);
 }
Exemple #18
0
 public void VisitValue(string value, VisitArgs args)
 {
     Statistics.VisitStringCount++;
     _statistics.AckVisited(args);
 }
Exemple #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);
 }
Exemple #20
0
 public void Leave(object level, VisitArgs args)
 {
     Statistics.LeaveCount++;
 }
Exemple #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;
        }
Exemple #22
0
 public void VisitValue(byte? value, VisitArgs args)
 {
     Statistics.VisitByteCount++;
     _statistics.AckVisited(args);
 }
Exemple #23
0
 public void Leave(VisitArgs args)
 {
     var expectedArgs = _args.Pop();
     Assert.AreEqual(expectedArgs, args);
     _statistics.LeaveCount++;
 }
Exemple #24
0
 public void VisitValue(uint? value, VisitArgs args)
 {
     Statistics.VisitUInt32Count++;
     _statistics.AckVisited(args);
 }
Exemple #25
0
 public bool TryVisitValue(VisitArgs args, out byte? value)
 {
     _statistics.AckVisited(args);
     _statistics.VisitByteCount++;
     value = ReadOnlyNull ? (byte?) null : 42;
     return ShouldRead(args);
 }
Exemple #26
0
 public void VisitValue(bool? value, VisitArgs args)
 {
     Statistics.VisitBooleanCount++;
     _statistics.AckVisited(args);
 }
Exemple #27
0
 public bool TryVisitValue(VisitArgs args, out short? value)
 {
     _statistics.AckVisited(args);
     _statistics.VisitInt16Count++;
     value = ReadOnlyNull ? (short?)null : ++_nextInt16;
     return ShouldRead(args);
 }
Exemple #28
0
 public void VisitValue(double? value, VisitArgs args)
 {
     Statistics.VisitDoubleCount++;
     _statistics.AckVisited(args);
 }
Exemple #29
0
 public void AckVisited(VisitArgs args)
 {
     _visitedArgs.Add(args);
 }
 public UnexpectedLengthException(VisitArgs args, uint length)
     : this(args.Name, args.Metadata.Index, length)
 {
 }
Exemple #31
0
 public UnexpectedLengthException(VisitArgs args, uint length) : this(args.Name, args.Index, length)
 {
 }