Exemple #1
0
        internal override CounterOperation ReadJson(BlittableJsonReader blittableReader)
        {
            var result = new CounterOperation();

            do
            {
                blittableReader.Read();
                if (blittableReader.TokenType == JsonToken.EndObject)
                {
                    return(result);
                }
                if (blittableReader.TokenType != JsonToken.PropertyName)
                {
                    throw new InvalidOperationException("Expected PropertyName, Got " + blittableReader.TokenType);
                }

                var property = (string)blittableReader.Value;
                switch (property)
                {
                case nameof(CounterOperation.CounterName):
                    result.CounterName = blittableReader.ReadAsString();
                    break;

                case nameof(CounterOperation.Delta):
                    blittableReader.Read();
                    result.Delta = (long)blittableReader.Value;
                    break;

                case nameof(CounterOperation.Type):
                    result.Type = Enum.Parse <CounterOperationType>(blittableReader.ReadAsString());
                    break;

                case nameof(CounterOperation.DocumentId):
                    result.DocumentId = blittableReader.ReadAsString();
                    break;

                case nameof(CounterOperation.ChangeVector):
                    result.ChangeVector = blittableReader.ReadAsString();
                    break;
                }
            } while (true);
        }