Esempio n. 1
0
        internal static ConsistencyPolicy DeserializeConsistencyPolicy(JsonElement element)
        {
            DefaultConsistencyLevel defaultConsistencyLevel = default;
            Optional <long>         maxStalenessPrefix      = default;
            Optional <int>          maxIntervalInSeconds    = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("defaultConsistencyLevel"))
                {
                    defaultConsistencyLevel = property.Value.GetString().ToDefaultConsistencyLevel();
                    continue;
                }
                if (property.NameEquals("maxStalenessPrefix"))
                {
                    maxStalenessPrefix = property.Value.GetInt64();
                    continue;
                }
                if (property.NameEquals("maxIntervalInSeconds"))
                {
                    maxIntervalInSeconds = property.Value.GetInt32();
                    continue;
                }
            }
            return(new ConsistencyPolicy(defaultConsistencyLevel, Optional.ToNullable(maxStalenessPrefix), Optional.ToNullable(maxIntervalInSeconds)));
        }
 /// <summary>
 /// Initializes a new instance of the ConsistencyPolicy class.
 /// </summary>
 /// <param name="defaultConsistencyLevel">The default consistency level
 /// and configuration settings of the DocumentDB account. Possible
 /// values include: 'Eventual', 'Session', 'BoundedStaleness',
 /// 'Strong', 'ConsistentPrefix'</param>
 /// <param name="maxStalenessPrefix">When used with the Bounded
 /// Staleness consistency level, this value represents the number of
 /// stale requests tolerated. Accepted range for this value is 1 –
 /// 2,147,483,647. Required when defaultConsistencyPolicy is set to
 /// 'BoundedStaleness'.</param>
 /// <param name="maxIntervalInSeconds">When used with the Bounded
 /// Staleness consistency level, this value represents the time amount
 /// of staleness (in seconds) tolerated. Accepted range for this value
 /// is 1 - 100. Required when defaultConsistencyPolicy is set to
 /// 'BoundedStaleness'.</param>
 public ConsistencyPolicy(DefaultConsistencyLevel defaultConsistencyLevel, long?maxStalenessPrefix = default(long?), int?maxIntervalInSeconds = default(int?))
 {
     DefaultConsistencyLevel = defaultConsistencyLevel;
     MaxStalenessPrefix      = maxStalenessPrefix;
     MaxIntervalInSeconds    = maxIntervalInSeconds;
     CustomInit();
 }
Esempio n. 3
0
 void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 {
     writer.WriteStartObject();
     writer.WritePropertyName("defaultConsistencyLevel");
     writer.WriteStringValue(DefaultConsistencyLevel.ToSerialString());
     if (Optional.IsDefined(MaxStalenessPrefix))
     {
         writer.WritePropertyName("maxStalenessPrefix");
         writer.WriteNumberValue(MaxStalenessPrefix.Value);
     }
     if (Optional.IsDefined(MaxIntervalInSeconds))
     {
         writer.WritePropertyName("maxIntervalInSeconds");
         writer.WriteNumberValue(MaxIntervalInSeconds.Value);
     }
     writer.WriteEndObject();
 }
Esempio n. 4
0
        internal static string ToSerializedValue(this DefaultConsistencyLevel value)
        {
            switch (value)
            {
            case DefaultConsistencyLevel.Eventual:
                return("Eventual");

            case DefaultConsistencyLevel.Session:
                return("Session");

            case DefaultConsistencyLevel.BoundedStaleness:
                return("BoundedStaleness");

            case DefaultConsistencyLevel.Strong:
                return("Strong");

            case DefaultConsistencyLevel.ConsistentPrefix:
                return("ConsistentPrefix");
            }
            return(null);
        }
 internal ConsistencyPolicy(DefaultConsistencyLevel defaultConsistencyLevel, long?maxStalenessPrefix, int?maxIntervalInSeconds)
 {
     DefaultConsistencyLevel = defaultConsistencyLevel;
     MaxStalenessPrefix      = maxStalenessPrefix;
     MaxIntervalInSeconds    = maxIntervalInSeconds;
 }
 public ConsistencyPolicy(DefaultConsistencyLevel defaultConsistencyLevel)
 {
     DefaultConsistencyLevel = defaultConsistencyLevel;
 }
Esempio n. 7
0
 public static string ToSerialString(this DefaultConsistencyLevel value) => value switch
 {