LaunchDarkly Dotnet Client SDK
Search Results for

    Show / Hide Table of Contents

    Class ConfigurationBuilder

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

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

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

    All of the builder methods for setting a configuration property return a reference to the same builder, so they can be chained together.

    Examples
    var config = Configuration.Builder("my-mobile-key").AllAttributesPrivate(true).EventCapacity(1000).Build();

    Methods

    | Edit this page View Source

    ApplicationInfo(ApplicationInfoBuilder)

    Sets the SDK's application metadata, which may be used in the LaunchDarkly analytics or other product features. This object is normally a configuration builder obtained from ApplicationInfo(), which has methods for setting individual metadata properties.

    Declaration
    public ConfigurationBuilder ApplicationInfo(ApplicationInfoBuilder applicationInfo)
    Parameters
    Type Name Description
    ApplicationInfoBuilder applicationInfo

    builder for ApplicationInfo(ApplicationInfoBuilder)

    Returns
    Type Description
    ConfigurationBuilder

    the same builder

    | Edit this page View Source

    AutoEnvironmentAttributes(AutoEnvAttributes)

    Specifies whether the SDK will use Auto Environment Attributes functionality. When enabled, the SDK will automatically provide data about the environment where the application is running. This data makes it simpler to target your mobile customers based on application name or version, or on device characteristics including manufacturer, model, operating system, locale, and so on. We recommend enabling this when you configure the SDK. See our documentation for more details.

    Declaration
    public ConfigurationBuilder AutoEnvironmentAttributes(ConfigurationBuilder.AutoEnvAttributes autoEnvAttributes)
    Parameters
    Type Name Description
    ConfigurationBuilder.AutoEnvAttributes autoEnvAttributes

    Enable / disable Auto Environment Attributes functionality.

    Returns
    Type Description
    ConfigurationBuilder

    the same builder

    | Edit this page View Source

    Build()

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

    Declaration
    public Configuration Build()
    Returns
    Type Description
    Configuration

    the configured Configuration object

    | Edit this page View Source

    DataSource(IComponentConfigurer<IDataSource>)

    Sets the implementation of the component that receives feature flag data from LaunchDarkly, using a factory object.

    Declaration
    public ConfigurationBuilder DataSource(IComponentConfigurer<IDataSource> dataSourceConfig)
    Parameters
    Type Name Description
    IComponentConfigurer<IDataSource> dataSourceConfig

    the factory object

    Returns
    Type Description
    ConfigurationBuilder

    the same builder

    Remarks

    Depending on the implementation, the factory may be a builder that allows you to set other configuration options as well.

    The default is StreamingDataSource(). You may instead use PollingDataSource(). See those methods for details on how to configure them.

    This overwrites any previous options set with DataSource(IComponentConfigurer<IDataSource>). If you want to set multiple options, set them on the same StreamingDataSourceBuilder or PollingDataSourceBuilder.

    | Edit this page View Source

    DiagnosticOptOut(bool)

    Specifies whether true to opt out of sending diagnostic events.

    Declaration
    public ConfigurationBuilder DiagnosticOptOut(bool diagnosticOptOut)
    Parameters
    Type Name Description
    bool diagnosticOptOut

    true to disable diagnostic events

    Returns
    Type Description
    ConfigurationBuilder

    the same builder

    Remarks

    Unless this is set to true, the client will send some diagnostics data to the LaunchDarkly servers in order to assist in the development of future SDK improvements. These diagnostics consist of an initial payload containing some details of SDK in use, the SDK's configuration, and the platform the SDK is being run on, as well as payloads sent periodically with information on irregular occurrences such as dropped events.

    | Edit this page View Source

    EnableBackgroundUpdating(bool)

    Sets whether to enable feature flag polling when the application is in the background.

    Declaration
    public ConfigurationBuilder EnableBackgroundUpdating(bool enableBackgroundUpdating)
    Parameters
    Type Name Description
    bool enableBackgroundUpdating

    true if background updating should be allowed

    Returns
    Type Description
    ConfigurationBuilder

    the same builder

    Remarks

    By default, on Android and iOS the SDK can still receive feature flag updates when an application is in the background, but it will use polling rather than maintaining a streaming connection (and will use the background polling interval rather than the regular polling interval). If you set this property to false, it will not check for feature flag updates until the application returns to the foreground.

    See Also
    BackgroundPollInterval(TimeSpan)
    BackgroundPollInterval(TimeSpan)
    | Edit this page View Source

    EvaluationReasons(bool)

    Set to true if LaunchDarkly should provide additional information about how flag values were calculated.

    Declaration
    public ConfigurationBuilder EvaluationReasons(bool evaluationReasons)
    Parameters
    Type Name Description
    bool evaluationReasons

    true if evaluation reasons are desired

    Returns
    Type Description
    ConfigurationBuilder

    the same builder

    Remarks

    The additional information will then be available through the client's "detail" methods such as BoolVariationDetail(string, bool). Since this increases the size of network requests, such information is not sent unless you set this option to true.

    | Edit this page View Source

    Events(IComponentConfigurer<IEventProcessor>)

    Sets the implementation of the component that processes analytics events.

    Declaration
    public ConfigurationBuilder Events(IComponentConfigurer<IEventProcessor> eventsConfig)
    Parameters
    Type Name Description
    IComponentConfigurer<IEventProcessor> eventsConfig

    a builder/factory object for event configuration

    Returns
    Type Description
    ConfigurationBuilder

    the same builder

    Remarks

    The default is SendEvents(), but you may choose to set it to a customized EventProcessorBuilder, a custom implementation (for instance, a test fixture), or disable events with NoEvents.

    This overwrites any previous options set with Events(IComponentConfigurer<IEventProcessor>). If you want to set multiple options, set them on the same EventProcessorBuilder.

    | Edit this page View Source

    GenerateAnonymousKeys(bool)

    Set to true to make the SDK provide unique keys for anonymous contexts.

    Declaration
    public ConfigurationBuilder GenerateAnonymousKeys(bool generateAnonymousKeys)
    Parameters
    Type Name Description
    bool generateAnonymousKeys

    true to enable automatic anonymous key generation

    Returns
    Type Description
    ConfigurationBuilder

    the same builder

    Remarks

    If enabled, this option changes the SDK's behavior whenever the Context (as given to methods like Init(string, AutoEnvAttributes, Context, TimeSpan) or Identify(Context, TimeSpan)) has an Anonymous property of true, as follows:

    • The first time this happens in the application, the SDK will generate a pseudo-random GUID and overwrite the context's Key with this string.
    • The SDK will then cache this key so that the same key will be reused next time.
    • This uses the same mechanism as the caching of flag values, so if persistent storage is available (see Persistence()), the key will persist across restarts; otherwise, it will persist only during the lifetime of the LdClient.

    If you use multiple ContextKinds, this behavior is per-kind: that is, a separate randomized key is generated and cached for each context kind.

    A Context must always have a key, even if the key will later be overwritten by the SDK, so if you use this functionality you must still provide a placeholder key. This ensures that if the SDK configuration is changed so GenerateAnonymousKeys(bool) is no longer enabled, the SDK will still be able to use the context for evaluations.

    | Edit this page View Source

    Http(HttpConfigurationBuilder)

    Sets the SDK's networking configuration, using a configuration builder obtained from HttpConfiguration(). The builder has methods for setting individual HTTP-related properties.

    Declaration
    public ConfigurationBuilder Http(HttpConfigurationBuilder httpConfigurationBuilder)
    Parameters
    Type Name Description
    HttpConfigurationBuilder httpConfigurationBuilder

    a builder for HTTP configuration

    Returns
    Type Description
    ConfigurationBuilder

    the top-level builder

    Remarks

    This overwrites any previous options set with Http(HttpConfigurationBuilder). If you want to set multiple options, set them on the same HttpConfigurationBuilder.

    | Edit this page View Source

    Logging(ILogAdapter)

    Sets the SDK's logging destination.

    Declaration
    public ConfigurationBuilder Logging(ILogAdapter logAdapter)
    Parameters
    Type Name Description
    ILogAdapter logAdapter

    an ILogAdapter for the desired logging implementation

    Returns
    Type Description
    ConfigurationBuilder

    the same builder

    Remarks

    This is a shortcut for Logging(Components.Logging(logAdapter)). You can use it when you only want to specify the basic logging destination, and do not need to set other log properties.

    For more about how logging works in the SDK, see the LaunchDarkly feature guide.

    Examples

    var config = Configuration.Builder("my-sdk-key") .Logging(Logs.ToWriter(Console.Out)) .Build();

    | Edit this page View Source

    Logging(LoggingConfigurationBuilder)

    Sets the SDK's logging configuration, using a configuration builder obtained from Logging().

    Declaration
    public ConfigurationBuilder Logging(LoggingConfigurationBuilder loggingConfigurationBuilder)
    Parameters
    Type Name Description
    LoggingConfigurationBuilder loggingConfigurationBuilder

    a builder for logging configuration

    Returns
    Type Description
    ConfigurationBuilder

    the top-level builder

    Remarks

    As a shortcut for disabling logging, you may use NoLogging instead. If all you want to do is to set the basic logging destination, and you do not need to set other logging properties, you can use Logging(ILogAdapter) instead.

    For more about how logging works in the SDK, see the LaunchDarkly feature guide.

    This overwrites any previous options set with Logging(LoggingConfigurationBuilder). If you want to set multiple options, set them on the same LoggingConfigurationBuilder.

    Examples

    var config = Configuration.Builder("my-sdk-key") .Logging(Components.Logging().Level(LogLevel.Warn))) .Build();

    See Also
    Logging()
    Logging(ILogAdapter)
    NoLogging
    Logging(ILogAdapter)
    | Edit this page View Source

    MobileKey(string)

    Sets the key for your LaunchDarkly environment.

    Declaration
    public ConfigurationBuilder MobileKey(string mobileKey)
    Parameters
    Type Name Description
    string mobileKey

    the mobile key

    Returns
    Type Description
    ConfigurationBuilder

    the same builder

    Remarks

    This should be the "mobile key" field for the environment on your LaunchDarkly dashboard.

    | Edit this page View Source

    Offline(bool)

    Sets whether or not this client is offline. If true, no calls to LaunchDarkly will be made.

    Declaration
    public ConfigurationBuilder Offline(bool offline)
    Parameters
    Type Name Description
    bool offline

    true if the client should remain offline

    Returns
    Type Description
    ConfigurationBuilder

    the same builder

    | Edit this page View Source

    Persistence(PersistenceConfigurationBuilder)

    Sets the SDK's persistent storage configuration, using a configuration builder obtained from Persistence().

    Declaration
    public ConfigurationBuilder Persistence(PersistenceConfigurationBuilder persistenceConfigurationBuilder)
    Parameters
    Type Name Description
    PersistenceConfigurationBuilder persistenceConfigurationBuilder

    a builder for persistence configuration

    Returns
    Type Description
    ConfigurationBuilder

    the top-level builder

    Remarks

    The persistent storage mechanism allows the SDK to immediately access the last known flag data for the user, if any, if it is offline or has not yet received data from LaunchDarkly.

    By default, the SDK uses a persistence mechanism that is specific to each platform: on Android and iOS it is the native preferences store, and in the .NET Standard implementation for desktop apps it is the System.IO.IsolatedStorage API. You may use the builder methods to substitute a custom implementation or change related parameters.

    This overwrites any previous options set with this method. If you want to set multiple options, set them on the same PersistenceConfigurationBuilder.

    Examples

    var config = Configuration.Builder("my-sdk-key") .Persistence(Components.Persistence().MaxCachedUsers(10)) .Build();

    See Also
    Persistence()
    NoPersistence
    PersistenceConfigurationBuilder
    | Edit this page View Source

    ServiceEndpoints(ServiceEndpointsBuilder)

    Sets the SDK's service URIs, using a configuration builder obtained from ServiceEndpoints().

    Declaration
    public ConfigurationBuilder ServiceEndpoints(ServiceEndpointsBuilder serviceEndpointsBuilder)
    Parameters
    Type Name Description
    ServiceEndpointsBuilder serviceEndpointsBuilder

    the subconfiguration builder object

    Returns
    Type Description
    ConfigurationBuilder

    the main configuration builder

    Remarks

    This overwrites any previous options set with ServiceEndpoints(ServiceEndpointsBuilder). If you want to set multiple options, set them on the same ServiceEndpointsBuilder.

    See Also
    ServiceEndpoints()
    ServiceEndpointsBuilder
    • Edit this page
    • View Source
    In this article
    Back to top Generated by DocFX