/// <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);
/// <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));
/// <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); }
/// <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));
/// <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);
/// <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); }
/// <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); }
/// <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); }
/// <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)); }
public override T ToType(LdValue jsonValue) => _toTypeFn(jsonValue);
public void TestNullStringConstructorIsEquivalentToNullInstance() { Assert.Equal(LdValue.Null, LdValue.Of(null)); }
public void ObjectBuilderAddDoesNotAllowDuplicates() { var builder = LdValue.BuildObject().Add("a", 1).Add("b", 2); Assert.ThrowsAny <Exception>(() => builder.Add("a", 3)); }
public static void AssertJsonEquals(string expected, string actual) { Assert.Equal(LdValue.Parse(expected), LdValue.Parse(actual)); }
public IUserBuilderCanMakeAttributePrivate Custom(string name, LdValue value) { return(_builder.Custom(name, value)); }
public IUserBuilderCanMakeAttributePrivate Custom(string name, double value) { return(Custom(name, LdValue.Of(value))); }