Пример #1
0
 /// <summary>
 /// Converts an <see cref="LdValue"/> to a value of the specified type.
 /// </summary>
 /// <remarks>
 /// This method should never throw an exception; if the conversion cannot be done, it
 /// should return <c>default(T)</c>.
 /// </remarks>
 /// <param name="jsonValue">an <see cref="LdValue"/></param>
 /// <returns>a value of this type</returns>
 abstract public T ToType(LdValue jsonValue);
Пример #2
0
 /// <summary>
 /// Adds a key-value pair to the object being built or replaces an existing key.
 /// </summary>
 /// <param name="key">the key</param>
 /// <param name="value">the value to add or replace</param>
 /// <returns>the same builder</returns>
 public ObjectBuilder Set(string key, string value) =>
 Set(key, LdValue.Of(value));
Пример #3
0
 /// <summary>
 /// Adds a key-value pair to the object being built.
 /// </summary>
 /// <param name="key">the key to add</param>
 /// <param name="value">the value to add</param>
 /// <returns>the same builder</returns>
 public ObjectBuilder Add(string key, string value)
 {
     _builder.Add(key, LdValue.Of(value));
     return(this);
 }
Пример #4
0
 /// <summary>
 /// Adds a key-value pair to the object being built.
 /// </summary>
 /// <remarks>
 /// Numeric values in LaunchDarkly have some precision limitations. For more details, see our
 /// documentation on <see href="https://docs.launchdarkly.com/sdk/concepts/flag-types">flag
 /// value types</see>.
 /// </remarks>
 /// <param name="key">the key to add</param>
 /// <param name="value">the value to add</param>
 /// <returns>the same builder</returns>
 public ObjectBuilder Add(string key, double value) =>
 Add(key, LdValue.Of(value));
Пример #5
0
 /// <summary>
 /// Adds a key-value pair to the object being built or replaces an existing key.
 /// </summary>
 /// <param name="key">the key</param>
 /// <param name="value">the value to add or replace</param>
 /// <returns>the same builder</returns>
 public ObjectBuilder Set(string key, LdValue value) =>
 Remove(key).Add(key, value);
Пример #6
0
 /// <summary>
 /// Adds a value to the array being built.
 /// </summary>
 /// <param name="value">the value to add</param>
 /// <returns>the same builder</returns>
 public ArrayBuilder Add(string value)
 {
     _builder.Add(LdValue.Of(value));
     return(this);
 }
Пример #7
0
 /// <summary>
 /// Adds a key-value pair to the object being built.
 /// </summary>
 /// <param name="key">the key to add</param>
 /// <param name="value">the value to add</param>
 /// <returns>the same builder</returns>
 public ObjectBuilder Add(string key, LdValue value)
 {
     _builder.Add(key, value);
     return(this);
 }
Пример #8
0
 /// <summary>
 /// Adds a value to the array being built.
 /// </summary>
 /// <param name="value">the value to add</param>
 /// <returns>the same builder</returns>
 public ArrayBuilder Add(LdValue value)
 {
     _builder.Add(value);
     return(this);
 }
Пример #9
0
 /// <summary>
 /// Adds a value to the array being built.
 /// </summary>
 /// <remarks>
 /// Numeric values in LaunchDarkly have some precision limitations. For more details, see our
 /// documentation on <see href="https://docs.launchdarkly.com/sdk/concepts/flag-types">flag
 /// value types</see>.
 /// </remarks>
 /// <param name="value">the value to add</param>
 /// <returns>the same builder</returns>
 public ArrayBuilder Add(double value)
 {
     _builder.Add(LdValue.Of(value));
     return(this);
 }
 private void AssertJsonEqual(string expectedString, string actualString)
 {
     Assert.Equal(LdValue.Parse(expectedString), LdValue.Parse(actualString));
 }
Пример #11
0
 public override T ToType(LdValue jsonValue) => _toTypeFn(jsonValue);
Пример #12
0
 public void TestNullStringConstructorIsEquivalentToNullInstance()
 {
     Assert.Equal(LdValue.Null, LdValue.Of(null));
 }
Пример #13
0
        public void ObjectBuilderAddDoesNotAllowDuplicates()
        {
            var builder = LdValue.BuildObject().Add("a", 1).Add("b", 2);

            Assert.ThrowsAny <Exception>(() => builder.Add("a", 3));
        }
Пример #14
0
 public static void AssertJsonEquals(string expected, string actual)
 {
     Assert.Equal(LdValue.Parse(expected), LdValue.Parse(actual));
 }
Пример #15
0
 public IUserBuilderCanMakeAttributePrivate Custom(string name, LdValue value)
 {
     return(_builder.Custom(name, value));
 }
Пример #16
0
 public IUserBuilderCanMakeAttributePrivate Custom(string name, double value)
 {
     return(Custom(name, LdValue.Of(value)));
 }