LaunchDarkly Dotnet Server SDK
Search Results for

    Show / Hide Table of Contents

    Class ILdClientExtensions

    Convenience methods that extend the ILdClient interface.

    Inheritance
    object
    ILdClientExtensions
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: LaunchDarkly.Sdk.Server
    Assembly: LaunchDarkly.ServerSdk.dll
    Syntax
    public static class ILdClientExtensions
    Remarks

    These allow you to do the following:

    • Treat a string-valued flag as if it referenced values of an enum type.

    These are implemented outside of ILdClient and LdClient because they do not rely on any implementation details of LdClient; they are decorators that would work equally well with a stub or test implementation of the interface.

    Methods

    | Edit this page View Source

    EnumVariationDetail<T>(ILdClient, string, Context, T)

    Equivalent to StringVariationDetail(string, Context, string), but converts the flag's string value to an enum value.

    Declaration
    public static EvaluationDetail<T> EnumVariationDetail<T>(this ILdClient client, string key, Context context, T defaultValue)
    Parameters
    Type Name Description
    ILdClient client

    the client instance

    string key

    the unique feature key for the feature flag

    Context context

    the evaluation context

    T defaultValue

    the default value of the flag (as an enum value)

    Returns
    Type Description
    EvaluationDetail<T>

    an EvaluationDetail<T> object

    Type Parameters
    Name Description
    T

    the enum type

    Remarks

    If the flag has a value that is not one of the allowed enum value names, or is not a string, defaultValue is returned.

    Note that there is no type constraint to guarantee that T really is an enum type, because that is a C# 7.3 feature that is unavailable in older versions of .NET Standard. If you try to use a non-enum type, you will simply receive the default value back.

    | Edit this page View Source

    EnumVariation<T>(ILdClient, string, Context, T)

    Equivalent to StringVariation(string, Context, string), but converts the flag's string value to an enum value.

    Declaration
    public static T EnumVariation<T>(this ILdClient client, string key, Context context, T defaultValue)
    Parameters
    Type Name Description
    ILdClient client

    the client instance

    string key

    the unique feature key for the feature flag

    Context context

    the evaluation context

    T defaultValue

    the default value of the flag (as an enum value)

    Returns
    Type Description
    T

    the variation for the given user, or defaultValue if the flag cannot be evaluated or does not have a valid enum value

    Type Parameters
    Name Description
    T

    the enum type

    Remarks

    If the flag has a value that is not one of the allowed enum value names, or is not a string, defaultValue is returned.

    Note that there is no type constraint to guarantee that T really is an enum type, because that is a C# 7.3 feature that is unavailable in older versions of .NET Standard. If you try to use a non-enum type, you will simply receive the default value back.

    • Edit this page
    • View Source
    In this article
    Back to top Generated by DocFX