LaunchDarkly Dotnet Client SDK
Search Results for

    Show / Hide Table of Contents

    Interface IUserBuilder

    A mutable object that uses the Builder pattern to specify properties for a User object.

    Namespace: LaunchDarkly.Sdk
    Assembly: LaunchDarkly.CommonSdk.dll
    Syntax
    public interface IUserBuilder
    Remarks

    Obtain an instance of this class by calling Builder(string).

    All of the builder methods for setting a user attribute return a reference to the same builder, so they can be chained together (see example). Some of them have the return type IUserBuilderCanMakeAttributePrivate rather than IUserBuilder; those are the user attributes that can be designated as private.

    Examples
    var user = User.Builder("my-key")
        .Name("Bob")
        .Email("test@example.com")
        .Build();

    Methods

    Anonymous(bool)

    Sets whether this user is anonymous, meaning that the user key will not appear on your LaunchDarkly dashboard.

    Declaration
    IUserBuilder Anonymous(bool anonymous)
    Parameters
    Type Name Description
    bool anonymous

    true if the user is anonymous

    Returns
    Type Description
    IUserBuilder

    the same builder

    Avatar(string)

    Sets the avatar URL for a user.

    Declaration
    IUserBuilderCanMakeAttributePrivate Avatar(string avatar)
    Parameters
    Type Name Description
    string avatar

    the avatar URL for the user

    Returns
    Type Description
    IUserBuilderCanMakeAttributePrivate

    the same builder

    Build()

    Creates a User based on the properties that have been set on the builder. Modifying the builder after this point does not affect the returned User.

    Declaration
    User Build()
    Returns
    Type Description
    User

    the configured User object

    Country(string)

    Sets the country identifier for a user.

    Declaration
    IUserBuilderCanMakeAttributePrivate Country(string country)
    Parameters
    Type Name Description
    string country

    the country for the user

    Returns
    Type Description
    IUserBuilderCanMakeAttributePrivate

    the same builder

    Remarks

    This is commonly either a 2- or 3-character standard country code, but LaunchDarkly does not validate this property or restrict its possible values.

    Custom(string, LdValue)

    Adds a custom attribute whose value is a JSON value of any kind.

    Declaration
    IUserBuilderCanMakeAttributePrivate Custom(string name, LdValue value)
    Parameters
    Type Name Description
    string name

    the key for the custom attribute

    LdValue value

    the value for the custom attribute

    Returns
    Type Description
    IUserBuilderCanMakeAttributePrivate

    the same builder

    Remarks

    The rules for allowable data types in custom attributes are the same as for flag variation values. For more details, see our documentation on flag value types.

    When set to one of the built-in user attribute keys, this custom attribute will be ignored.

    Examples
    var arrayOfIntsValue = LdValue.FromValues(new int[] { 1, 2, 3 });
    var user = User.Builder("key").Custom("numbers", arrayOfIntsValue).Build();

    Custom(string, bool)

    Adds a custom attribute with a boolean value.

    Declaration
    IUserBuilderCanMakeAttributePrivate Custom(string name, bool value)
    Parameters
    Type Name Description
    string name

    the key for the custom attribute

    bool value

    the value for the custom attribute

    Returns
    Type Description
    IUserBuilderCanMakeAttributePrivate

    the same builder

    Remarks

    When set to one of the built-in user attribute keys, this custom attribute will be ignored.

    Custom(string, double)

    Adds a custom attribute with a double value.

    Declaration
    IUserBuilderCanMakeAttributePrivate Custom(string name, double value)
    Parameters
    Type Name Description
    string name

    the key for the custom attribute

    double value

    the value for the custom attribute

    Returns
    Type Description
    IUserBuilderCanMakeAttributePrivate

    the same builder

    Remarks

    Numeric values in custom attributes have some precision limitations, the same as for numeric values in flag variations. For more details, see our documentation on flag value types.

    When set to one of the built-in user attribute keys, this custom attribute will be ignored.

    Custom(string, int)

    Adds a custom attribute with an integer value.

    Declaration
    IUserBuilderCanMakeAttributePrivate Custom(string name, int value)
    Parameters
    Type Name Description
    string name

    the key for the custom attribute

    int value

    the value for the custom attribute

    Returns
    Type Description
    IUserBuilderCanMakeAttributePrivate

    the same builder

    Remarks

    When set to one of the built-in user attribute keys, this custom attribute will be ignored.

    Custom(string, long)

    Adds a custom attribute with a long value.

    Declaration
    IUserBuilderCanMakeAttributePrivate Custom(string name, long value)
    Parameters
    Type Name Description
    string name

    the key for the custom attribute

    long value

    the value for the custom attribute

    Returns
    Type Description
    IUserBuilderCanMakeAttributePrivate

    the same builder

    Remarks

    Numeric values in custom attributes have some precision limitations, the same as for numeric values in flag variations. For more details, see our documentation on flag value types.

    When set to one of the built-in user attribute keys, this custom attribute will be ignored.

    Custom(string, float)

    Adds a custom attribute with a floating-point value.

    Declaration
    IUserBuilderCanMakeAttributePrivate Custom(string name, float value)
    Parameters
    Type Name Description
    string name

    the key for the custom attribute

    float value

    the value for the custom attribute

    Returns
    Type Description
    IUserBuilderCanMakeAttributePrivate

    the same builder

    Remarks

    Numeric values in custom attributes have some precision limitations, the same as for numeric values in flag variations. For more details, see our documentation on flag value types.

    When set to one of the built-in user attribute keys, this custom attribute will be ignored.

    Custom(string, string)

    Adds a custom attribute with a string value.

    Declaration
    IUserBuilderCanMakeAttributePrivate Custom(string name, string value)
    Parameters
    Type Name Description
    string name

    the key for the custom attribute

    string value

    the value for the custom attribute

    Returns
    Type Description
    IUserBuilderCanMakeAttributePrivate

    the same builder

    Remarks

    When set to one of the built-in user attribute keys, this custom attribute will be ignored.

    Email(string)

    Sets the email address for a user.

    Declaration
    IUserBuilderCanMakeAttributePrivate Email(string email)
    Parameters
    Type Name Description
    string email

    the email address for the user

    Returns
    Type Description
    IUserBuilderCanMakeAttributePrivate

    the same builder

    FirstName(string)

    Sets the first name for a user.

    Declaration
    IUserBuilderCanMakeAttributePrivate FirstName(string firstName)
    Parameters
    Type Name Description
    string firstName

    the first name for the user

    Returns
    Type Description
    IUserBuilderCanMakeAttributePrivate

    the same builder

    IPAddress(string)

    Sets the IP address for a user.

    Declaration
    IUserBuilderCanMakeAttributePrivate IPAddress(string ipAddress)
    Parameters
    Type Name Description
    string ipAddress

    the IP address for the user

    Returns
    Type Description
    IUserBuilderCanMakeAttributePrivate

    the same builder

    Key(string)

    Sets the unique key for a user.

    Declaration
    IUserBuilder Key(string key)
    Parameters
    Type Name Description
    string key

    the key

    Returns
    Type Description
    IUserBuilder

    the same builder

    LastName(string)

    Sets the last name for a user.

    Declaration
    IUserBuilderCanMakeAttributePrivate LastName(string lastName)
    Parameters
    Type Name Description
    string lastName

    the last name for the user

    Returns
    Type Description
    IUserBuilderCanMakeAttributePrivate

    the same builder

    Name(string)

    Sets the full name for a user.

    Declaration
    IUserBuilderCanMakeAttributePrivate Name(string name)
    Parameters
    Type Name Description
    string name

    the name for the user

    Returns
    Type Description
    IUserBuilderCanMakeAttributePrivate

    the same builder

    In this article
    Back to top Generated by DocFX