LaunchDarkly Dotnet Client SDK
Search Results for

    Show / Hide Table of Contents

    Class TestData.FlagBuilder

    A builder for feature flag configurations to be used with TestData.

    Inheritance
    object
    TestData.FlagBuilder
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: LaunchDarkly.Sdk.Client.Integrations
    Assembly: LaunchDarkly.ClientSdk.dll
    Syntax
    public sealed class TestData.FlagBuilder

    Methods

    | Edit this page View Source

    BooleanFlag()

    A shortcut for setting the flag to use the standard boolean configuration.

    Declaration
    public TestData.FlagBuilder BooleanFlag()
    Returns
    Type Description
    TestData.FlagBuilder

    the builder

    Remarks

    This is the default for all new flags created with Flag(string). The flag will have two variations, true and false (in that order). When using evaluation reasons, the reason will be set to FallthroughReason whenever the value is true, and OffReason whenever the value is false.

    | Edit this page View Source

    Variation(LdValue)

    Sets the flag to return the specified variation value for all contexts by default.

    Declaration
    public TestData.FlagBuilder Variation(LdValue value)
    Parameters
    Type Name Description
    LdValue value

    the desired value to be returned for all users

    Returns
    Type Description
    TestData.FlagBuilder

    the builder

    Remarks

    The value may be of any JSON type, as defined by LdValue. If the value matches one of the values previously specified with Variations(params LdValue[]), then the variation index is set to the index of that value. Otherwise, the value is added to the variation list.

    | Edit this page View Source

    Variation(bool)

    Sets the flag to return the specified boolean variation for all contexts by default.

    Declaration
    public TestData.FlagBuilder Variation(bool variation)
    Parameters
    Type Name Description
    bool variation

    the desired true/false variation to be returned for all users

    Returns
    Type Description
    TestData.FlagBuilder

    the builder

    Remarks

    The flag's variations are set to true and false if they are not already (equivalent to calling BooleanFlag()).

    | Edit this page View Source

    Variation(int)

    Sets the flag to return the specified variation for all contexts by default.

    Declaration
    public TestData.FlagBuilder Variation(int variationIndex)
    Parameters
    Type Name Description
    int variationIndex

    the desired variation: 0 for the first, 1 for the second, etc.

    Returns
    Type Description
    TestData.FlagBuilder

    the builder

    Remarks

    The variation is specified by number, out of whatever variation values have already been defined.

    | Edit this page View Source

    VariationForKey(ContextKind, string, LdValue)

    Sets the flag to return the specified variation value for a specific context by kind and key, overriding any other defaults.

    Declaration
    public TestData.FlagBuilder VariationForKey(ContextKind contextKind, string contextKey, LdValue value)
    Parameters
    Type Name Description
    ContextKind contextKind

    the context kind

    string contextKey

    the context key

    LdValue value

    the desired value to be returned for this context

    Returns
    Type Description
    TestData.FlagBuilder

    the builder

    Remarks

    The value may be of any JSON type, as defined by LdValue. If the value matches one of the values previously specified with Variations(params LdValue[]), then the variation index is set to the index of that value. Otherwise, the value is added to the variation list.

    See Also
    VariationForUser(string, LdValue)
    VariationForKey(ContextKind, string, bool)
    VariationForKey(ContextKind, string, int)
    | Edit this page View Source

    VariationForKey(ContextKind, string, bool)

    Sets the flag to return the specified boolean variation for a specific context by kind and key, overriding any other defaults.

    Declaration
    public TestData.FlagBuilder VariationForKey(ContextKind contextKind, string contextKey, bool variation)
    Parameters
    Type Name Description
    ContextKind contextKind

    the context kind

    string contextKey

    the context key

    bool variation

    the desired true/false variation to be returned for this context

    Returns
    Type Description
    TestData.FlagBuilder

    the builder

    Remarks

    The flag's variations are set to true and false if they are not already (equivalent to calling BooleanFlag()).

    See Also
    VariationForUser(string, bool)
    VariationForKey(ContextKind, string, int)
    VariationForKey(ContextKind, string, LdValue)
    | Edit this page View Source

    VariationForKey(ContextKind, string, int)

    Sets the flag to return the specified variation for a specific context by kind and key, overriding any other defaults.

    Declaration
    public TestData.FlagBuilder VariationForKey(ContextKind contextKind, string contextKey, int variationIndex)
    Parameters
    Type Name Description
    ContextKind contextKind

    the context kind

    string contextKey

    the context key

    int variationIndex

    the desired variation to be returned for this context when targeting is on: 0 for the first, 1 for the second, etc.

    Returns
    Type Description
    TestData.FlagBuilder

    the builder

    Remarks

    The variation is specified by number, out of whatever variation values have already been defined.

    See Also
    VariationForUser(string, int)
    VariationForKey(ContextKind, string, bool)
    VariationForKey(ContextKind, string, LdValue)
    | Edit this page View Source

    VariationForUser(string, LdValue)

    Sets the flag to return the specified variation value for a specific user key, overriding any other defaults.

    Declaration
    public TestData.FlagBuilder VariationForUser(string userKey, LdValue value)
    Parameters
    Type Name Description
    string userKey

    a user key

    LdValue value

    the desired value to be returned for this user

    Returns
    Type Description
    TestData.FlagBuilder

    the builder

    Remarks

    The value may be of any JSON type, as defined by LdValue. If the value matches one of the values previously specified with Variations(params LdValue[]), then the variation index is set to the index of that value. Otherwise, the value is added to the variation list.

    See Also
    VariationForKey(ContextKind, string, LdValue)
    VariationForUser(string, bool)
    VariationForUser(string, int)
    | Edit this page View Source

    VariationForUser(string, bool)

    Sets the flag to return the specified boolean variation for a specific user key, overriding any other defaults.

    Declaration
    public TestData.FlagBuilder VariationForUser(string userKey, bool variation)
    Parameters
    Type Name Description
    string userKey

    the user key

    bool variation

    the desired true/false variation to be returned for this user

    Returns
    Type Description
    TestData.FlagBuilder

    the builder

    Remarks

    The flag's variations are set to true and false if they are not already (equivalent to calling BooleanFlag()).

    See Also
    VariationForKey(ContextKind, string, bool)
    VariationForUser(string, int)
    VariationForUser(string, LdValue)
    | Edit this page View Source

    VariationForUser(string, int)

    Sets the flag to return the specified variation for a specific user key, overriding any other defaults.

    Declaration
    public TestData.FlagBuilder VariationForUser(string userKey, int variationIndex)
    Parameters
    Type Name Description
    string userKey

    the user key

    int variationIndex

    the desired variation to be returned for this user when targeting is on: 0 for the first, 1 for the second, etc.

    Returns
    Type Description
    TestData.FlagBuilder

    the builder

    Remarks

    The variation is specified by number, out of whatever variation values have already been defined.

    See Also
    VariationForKey(ContextKind, string, int)
    VariationForUser(string, bool)
    VariationForUser(string, LdValue)
    | Edit this page View Source

    VariationFunc(Func<Context, LdValue?>)

    Sets the flag to use a function to determine the variation value to return for any given context.

    Declaration
    public TestData.FlagBuilder VariationFunc(Func<Context, LdValue?> variationFunc)
    Parameters
    Type Name Description
    Func<Context, LdValue?> variationFunc

    a function to determine the variation

    Returns
    Type Description
    TestData.FlagBuilder

    the builder

    Remarks

    The function takes an evaluation context and returns an LdValue or null. A null result means that the flag will fall back to its default variation for all contexts.

    The value returned by the function must be one of the values previously specified with Variations(params LdValue[]); otherwise it will be ignored.

    This function is called only if the context was not specifically targeted with VariationForUser(string, LdValue) or VariationForKey(ContextKind, string, LdValue).

    | Edit this page View Source

    VariationFunc(Func<Context, bool?>)

    Sets the flag to use a function to determine whether to return true or false for any given context.

    Declaration
    public TestData.FlagBuilder VariationFunc(Func<Context, bool?> variationFunc)
    Parameters
    Type Name Description
    Func<Context, bool?> variationFunc

    a function to determine the variation

    Returns
    Type Description
    TestData.FlagBuilder

    the builder

    Remarks

    The function takes an evaluation context and returns true, false, or null. A null result means that the flag will fall back to its default variation for all contexts.

    The flag's variations are set to true and false if they are not already (equivalent to calling BooleanFlag()).

    This function is called only if the context was not specifically targeted with VariationForUser(string, bool) or VariationForKey(ContextKind, string, bool).

    | Edit this page View Source

    VariationFunc(Func<Context, int?>)

    Sets the flag to use a function to determine the variation index to return for any given context.

    Declaration
    public TestData.FlagBuilder VariationFunc(Func<Context, int?> variationFunc)
    Parameters
    Type Name Description
    Func<Context, int?> variationFunc

    a function to determine the variation

    Returns
    Type Description
    TestData.FlagBuilder

    the builder

    Remarks

    The function takes an evaluation context and returns an integer variation index or null. A null result means that the flag will fall back to its default variation for all contexts.

    This function is called only if the context was not specifically targeted with VariationForUser(string, int) or VariationForKey(ContextKind, string, int).

    | Edit this page View Source

    Variations(params LdValue[])

    Changes the allowable variation values for the flag.

    Declaration
    public TestData.FlagBuilder Variations(params LdValue[] values)
    Parameters
    Type Name Description
    LdValue[] values

    the desired variations

    Returns
    Type Description
    TestData.FlagBuilder

    the builder

    Remarks

    The value may be of any JSON type, as defined by LdValue. For instance, a boolean flag normally has LdValue.Of(true), LdValue.Of(false); a string-valued flag might have LdValue.Of("red"), LdValue.Of("green"), LdValue.Of("blue"); etc.

    See Also

    Flag(string)
    Update(FlagBuilder)
    • Edit this page
    • View Source
    In this article
    Back to top Generated by DocFX