コード例 #1
0
        private SentinelValue(AugmentedValue augmentedValue)
        {
            Kind = augmentedValue.Kind;
            var byteString = augmentedValue.ToByteString();

            _protoFactory = () => Value.Parser.ParseFrom(byteString);
        }
コード例 #2
0
        internal static SentinelValue ForIncrement(Value value)
        {
            GaxPreconditions.CheckNotNull(value, nameof(value));
            AugmentedValue augmented = new AugmentedValue {
                Kind = SentinelKind.NumericIncrement, Increment = value
            };

            return(new SentinelValue(augmented));
        }
コード例 #3
0
        internal static SentinelValue ForArrayValue(SentinelKind sentinelKind, object[] values)
        {
            GaxPreconditions.CheckNotNull(values, nameof(values));
            ArrayValue array = ValueSerializer.Serialize(values).ArrayValue;

            // This is just checking that the simple approach we've taken in the previous line
            // really did what we expect.
            GaxPreconditions.CheckState(array != null, "Input wasn't serialized as an array");
            AugmentedValue augmented = new AugmentedValue {
                Kind = sentinelKind, Array = array
            };

            return(new SentinelValue(augmented));
        }
コード例 #4
0
        internal static SentinelValue ForArrayValue(SerializationContext context, SentinelKind sentinelKind, object[] values)
        {
            GaxPreconditions.CheckNotNull(values, nameof(values));
            ArrayValue array = ValueSerializer.Serialize(context, values).ArrayValue;

            // This is just checking that the simple approach we've taken in the previous line
            // really did what we expect.
            GaxPreconditions.CheckState(array != null, "Input wasn't serialized as an array");
            GaxPreconditions.CheckState(!array.Values.Any(FindNestedSentinels), "Sentinel values cannot be nested in array union/remove values.");
            AugmentedValue augmented = new AugmentedValue {
                Kind = sentinelKind, Array = array
            };

            return(new SentinelValue(augmented));
        }