Exemple #1
0
        // public static methods
        /// <summary>
        /// Creates and initializes a retryable write operation context.
        /// </summary>
        /// <param name="binding">The binding.</param>
        /// <param name="retryRequested">if set to <c>true</c> [retry requested].</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>A retryable write context.</returns>
        public static RetryableWriteContext Create(IWriteBinding binding, bool retryRequested, CancellationToken cancellationToken)
        {
            var context = new RetryableWriteContext(binding, retryRequested);

            try
            {
                context.Initialize(cancellationToken);

                if (context.Binding.Session.IsInTransaction &&
                    ChannelPinningHelper.PinChannelSourceAndChannelIfRequired(
                        context.ChannelSource,
                        context.Channel,
                        context.Binding.Session,
                        out var pinnedChannelSource,
                        out var pinnedChannel))
                {
                    context.ReplaceChannelSource(pinnedChannelSource);
                    context.ReplaceChannel(pinnedChannel);
                }

                return(context);
            }
            catch
            {
                context.Dispose();
                throw;
            }
        }
        // public static methods
        /// <summary>
        /// Creates and initializes a retryable write operation context.
        /// </summary>
        /// <param name="binding">The binding.</param>
        /// <param name="retryRequested">if set to <c>true</c> [retry requested].</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>A retryable write context.</returns>
        public static RetryableWriteContext Create(IWriteBinding binding, bool retryRequested, CancellationToken cancellationToken)
        {
            var context = new RetryableWriteContext(binding, retryRequested);

            try
            {
                context.Initialize(cancellationToken);
                return(context);
            }
            catch
            {
                context.Dispose();
                throw;
            }
        }
Exemple #3
0
        // public static methods
        /// <summary>
        /// Creates and initializes a retryable write operation context.
        /// </summary>
        /// <param name="binding">The binding.</param>
        /// <param name="retryRequested">if set to <c>true</c> [retry requested].</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>A retryable write context.</returns>
        public static RetryableWriteContext Create(IWriteBinding binding, bool retryRequested, CancellationToken cancellationToken)
        {
            var context = new RetryableWriteContext(binding, retryRequested);

            try
            {
                context.Initialize(cancellationToken);

                ChannelPinningHelper.PinChannellIfRequired(
                    context.ChannelSource,
                    context.Channel,
                    context.Binding.Session);

                return(context);
            }
            catch
            {
                context.Dispose();
                throw;
            }
        }