Esempio n. 1
0
        /// <summary>
        /// Creates a new <see cref="LdClient"/> singleton instance and attempts to initialize feature flags.
        /// </summary>
        /// <remarks>
        /// <para>
        /// In offline mode, this constructor will return immediately. Otherwise, it will wait and block on
        /// the current thread until initialization and the first response from the LaunchDarkly service is
        /// returned, up to the specified timeout. If the timeout elapses, the returned instance will have
        /// an <see cref="Initialized"/> property of <see langword="false"/>.
        /// </para>
        /// <para>
        /// If you would rather this happen asynchronously, use <see cref="InitAsync(string, User)"/>. To
        /// specify additional configuration options rather than just the mobile key, use
        /// <see cref="Init(Configuration, User, TimeSpan)"/> or <see cref="InitAsync(Configuration, User)"/>.
        /// </para>
        /// <para>
        /// You must use one of these static factory methods to instantiate the single instance of LdClient
        /// for the lifetime of your application.
        /// </para>
        /// </remarks>
        /// <returns>the singleton <see cref="LdClient"/> instance</returns>
        /// <param name="mobileKey">the mobile key given to you by LaunchDarkly</param>
        /// <param name="user">the user needed for client operations (must not be <see langword="null"/>);
        /// if the user's <see cref="User.Key"/> is <see langword="null"/> and <see cref="User.Anonymous"/>
        /// is <see langword="true"/>, it will be assigned a key that uniquely identifies this device</param>
        /// <param name="maxWaitTime">the maximum length of time to wait for the client to initialize</param>
        public static LdClient Init(string mobileKey, User user, TimeSpan maxWaitTime)
        {
            var config = Configuration.Default(mobileKey);

            return(Init(config, user, maxWaitTime));
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a new <see cref="LdClient"/> singleton instance and attempts to initialize feature flags asynchronously.
        /// </summary>
        /// <remarks>
        /// <para>
        /// The returned task will yield the <see cref="LdClient"/> instance once the first response from
        /// the LaunchDarkly service is returned (or immediately if it is in offline mode).
        /// </para>
        /// <para>
        /// You must use one of these static factory methods to instantiate the single instance of LdClient
        /// for the lifetime of your application.
        /// </para>
        /// </remarks>
        /// <returns>the singleton <see cref="LdClient"/> instance</returns>
        /// <param name="mobileKey">the mobile key given to you by LaunchDarkly</param>
        /// <param name="user">the user needed for client operations (must not be <see langword="null"/>);
        /// if the user's <see cref="User.Key"/> is <see langword="null"/> and <see cref="User.Anonymous"/>
        /// is <see langword="true"/>, it will be assigned a key that uniquely identifies this device</param>
        public static async Task <LdClient> InitAsync(string mobileKey, User user)
        {
            var config = Configuration.Default(mobileKey);

            return(await InitAsync(config, user));
        }
Esempio n. 3
0
        /// <summary>
        /// Creates and returns new LdClient singleton instance, then starts the workflow for
        /// fetching feature flags.
        ///
        /// This constructor will wait and block on the current thread until initialization and the
        /// first response from the LaunchDarkly service is returned, if you would rather this happen
        /// in an async fashion you can use <see cref="InitAsync(string, User)"/>
        ///
        /// This is the creation point for LdClient, you must use this static method or the more specific
        /// <see cref="Init(Configuration, User)"/> to instantiate the single instance of LdClient
        /// for the lifetime of your application.
        /// </summary>
        /// <returns>The singleton LdClient instance.</returns>
        /// <param name="mobileKey">The mobile key given to you by LaunchDarkly.</param>
        /// <param name="user">The user needed for client operations.</param>
        public static LdClient Init(string mobileKey, User user)
        {
            var config = Configuration.Default(mobileKey);

            return(Init(config, user));
        }