// This method was formerly part of User. It has been moved here because it is only needed // for server-side evaluation logic, specifically for comparing values with an Operator. // Note that ImmutableJsonValue.Of(string) is an efficient operation that does not allocate // a new object, but just wraps the string in a struct (or returns ImmutableJsonValue.Null // if the string is null). public static LdValue GetUserAttributeForEvaluation(User user, string attribute) { switch (attribute) { case "key": return(LdValue.Of(user.Key)); case "secondary": return(LdValue.Of(user.Secondary)); case "ip": return(LdValue.Of(user.IPAddress)); case "email": return(LdValue.Of(user.Email)); case "avatar": return(LdValue.Of(user.Avatar)); case "firstName": return(LdValue.Of(user.FirstName)); case "lastName": return(LdValue.Of(user.LastName)); case "name": return(LdValue.Of(user.Name)); case "country": return(LdValue.Of(user.Country)); case "anonymous": if (user.Anonymous.HasValue) { return(LdValue.Of(user.Anonymous.Value)); } return(LdValue.Null); default: return(user.Custom.TryGetValue(attribute, out var customValue) ? LdValue.FromSafeValue(customValue) : LdValue.Null); } }
public void Track(string name, User user, string data) { Track(name, user, LdValue.Of(data)); }
/// <inheritdoc/> public EvaluationDetail <string> StringVariationDetail(string key, User user, string defaultValue) { return(Evaluate(key, user, LdValue.Of(defaultValue), LdValue.Convert.String, true, EventFactory.DefaultWithReasons)); }
/// <inheritdoc/> public EvaluationDetail <float> FloatVariationDetail(string key, User user, float defaultValue) { return(Evaluate(key, user, LdValue.Of(defaultValue), LdValue.Convert.Float, true, EventFactory.DefaultWithReasons)); }
/// <inheritdoc/> public EvaluationDetail <bool> BoolVariationDetail(string key, User user, bool defaultValue) { return(Evaluate(key, user, LdValue.Of(defaultValue), LdValue.Convert.Bool, true, EventFactory.DefaultWithReasons)); }
/// <inheritdoc/> public string StringVariation(string key, User user, string defaultValue) { return(Evaluate(key, user, LdValue.Of(defaultValue), LdValue.Convert.String, true, EventFactory.Default).Value); }
/// <inheritdoc/> public float FloatVariation(string key, User user, float defaultValue) { return(Evaluate(key, user, LdValue.Of(defaultValue), LdValue.Convert.Float, true, EventFactory.Default).Value); }
/// <inheritdoc/> public int IntVariation(string key, User user, int defaultValue) { return(Evaluate(key, user, LdValue.Of(defaultValue), LdValue.Convert.Int, true, EventFactory.Default).Value); }
/// <inheritdoc/> public bool BoolVariation(string key, User user, bool defaultValue = false) { return(Evaluate(key, user, LdValue.Of(defaultValue), LdValue.Convert.Bool, true, EventFactory.Default).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 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 value to the array being built. /// </summary> /// <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); }
public IUserBuilderCanMakeAttributePrivate Custom(string name, float value) { return(Custom(name, LdValue.Of(value))); }