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