< Summary

Class:Azure.Messaging.ServiceBus.ProcessSessionEventArgs
Assembly:Azure.Messaging.ServiceBus
File(s):C:\Git\azure-sdk-for-net\sdk\servicebus\Azure.Messaging.ServiceBus\src\Processor\ProcessSessionEventArgs.cs
Covered lines:0
Uncovered lines:11
Coverable lines:11
Total lines:78
Line coverage:0% (0 of 11)
Covered branches:0
Total branches:0

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
get_CancellationToken()-0%100%
get_SessionId()-0%100%
get_SessionLockedUntil()-0%100%
.ctor(...)-0%100%
GetSessionStateAsync()-0%100%
SetSessionStateAsync()-0%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\servicebus\Azure.Messaging.ServiceBus\src\Processor\ProcessSessionEventArgs.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System;
 5using System.Threading;
 6using System.Threading.Tasks;
 7
 8namespace Azure.Messaging.ServiceBus
 9{
 10    /// <summary>
 11    /// The <see cref="ProcessSessionEventArgs"/> contain event args related to the session being processed.
 12    /// </summary>
 13    public class ProcessSessionEventArgs : EventArgs
 14    {
 15        /// <summary>
 16        /// The processor's <see cref="System.Threading.CancellationToken"/> instance which will be
 17        /// cancelled in the event that <see cref="ServiceBusProcessor.StopProcessingAsync"/> is called.
 18        /// </summary>
 019        public CancellationToken CancellationToken { get; }
 20
 21        /// <summary>
 22        /// The <see cref="ServiceBusSessionReceiver"/> that will be used for setting and getting session
 23        /// state.
 24        /// </summary>
 25        private readonly ServiceBusSessionReceiver _sessionReceiver;
 26
 27        /// <summary>
 28        /// The Session Id associated with the session being processed.
 29        /// </summary>
 030        public string SessionId => _sessionReceiver.SessionId;
 31
 32        /// <summary>
 33        /// Gets the <see cref="DateTimeOffset"/> that the current session is locked until.
 34        /// </summary>
 035        public DateTimeOffset SessionLockedUntil => _sessionReceiver.SessionLockedUntil;
 36
 37        /// <summary>
 38        /// Initializes a new instance of the <see cref="ProcessSessionEventArgs"/> class.
 39        /// </summary>
 40        ///
 41        /// <param name="receiver">The <see cref="ServiceBusSessionReceiver"/> that will be used for all settlement meth
 42        /// for the args.</param>
 43        /// <param name="cancellationToken">The processor's <see cref="System.Threading.CancellationToken"/> instance wh
 044        internal ProcessSessionEventArgs(
 045            ServiceBusSessionReceiver receiver,
 046            CancellationToken cancellationToken)
 47        {
 048            _sessionReceiver = receiver;
 049            CancellationToken = cancellationToken;
 050        }
 51
 52        /// <summary>
 53        /// Gets the session state.
 54        /// </summary>
 55        ///
 56        /// <param name="cancellationToken">An optional <see cref="CancellationToken"/> instance to signal the request t
 57        ///
 58        /// <returns>The session state as byte array.</returns>
 59        public virtual async Task<byte[]> GetSessionStateAsync(
 60            CancellationToken cancellationToken = default) =>
 061            await _sessionReceiver.GetSessionStateAsync(cancellationToken).ConfigureAwait(false);
 62
 63        /// <summary>
 64        /// Set a custom state on the session which can be later retrieved using <see cref="GetSessionStateAsync"/>
 65        /// </summary>
 66        ///
 67        /// <param name="sessionState">A byte array of session state</param>
 68        /// <param name="cancellationToken">An optional <see cref="CancellationToken"/> instance to signal the request t
 69        ///
 70        /// <remarks>This state is stored on Service Bus forever unless you set an empty state on it.</remarks>
 71        ///
 72        /// <returns>A task to be resolved on when the operation has completed.</returns>
 73        public virtual async Task SetSessionStateAsync(
 74            byte[] sessionState,
 75            CancellationToken cancellationToken = default) =>
 076            await _sessionReceiver.SetSessionStateAsync(sessionState, cancellationToken).ConfigureAwait(false);
 77    }
 78}