Exemplo n.º 1
0
        /// <summary>
        /// Opens a Wallet.
        /// </summary>
        /// <remarks>
        /// <para>Opens a wallet by name using the name of a wallet created earlier using the
        /// <see cref="CreateWalletAsync(string, string, string, string, string)"/> method.
        /// </para>
        /// <note type="note">Attempting to open the same wallet more than once will result in an error.</note>
        /// <para>
        /// The <paramref name="runtimeConfig"/> parameter allows the default configuration of the wallet
        /// to be overridden while opening the wallet; this does not replace the configuration registered
        /// when the wallet was created but instead overrides it for the duration of this opening only.
        /// See the <see cref="CreateWalletAsync(string, string, string, string, string)"/> method for
        /// details on the configuration string supported by the default wallet type; custom wallet
        /// types will can support their own format.
        /// </para>
        /// <para>The <paramref name="credentials"/> parameter is unused in the default wallet at present,
        /// however the value can be used by custom wallet implementations; it is up to the custom wallet
        /// type implementer to interpret the value.
        /// </para>
        /// </remarks>
        /// <param name="name">The name of the Wallet to open.</param>
        /// <param name="runtimeConfig">The runtime configuration to override the configuration the wallet was created with.</param>
        /// <param name="credentials">The wallet credentials.</param>
        /// <returns>An asynchronous <see cref="Task{T}"/> that resolves to a <see cref="Wallet"/> instance when the operation completes.</returns>
        public static Task <Wallet> OpenWalletAsync(string name, string runtimeConfig, string credentials)
        {
            var taskCompletionSource = new TaskCompletionSource <Wallet>();
            var commandHandle        = PendingCommands.Add(taskCompletionSource);

            var result = IndyNativeMethods.indy_open_wallet(
                commandHandle,
                name,
                runtimeConfig,
                credentials,
                _openWalletCallback
                );

            CallbackHelper.CheckResult(result);

            return(taskCompletionSource.Task);
        }