예제 #1
0
        public static Task <IDicomClientState> TransitionToCompletedState(this DicomClient dicomClient, IDicomClientConnection connection,
                                                                          DicomClientCancellation cancellation)
        {
            var completedParameters = new DicomClientCompletedState.DicomClientCompletedWithoutErrorInitialisationParameters(connection);
            var completedState      = new DicomClientCompletedState(dicomClient, completedParameters);

            return(dicomClient.Transition(completedState, cancellation));
        }
예제 #2
0
        public static Task <IDicomClientState> TransitionToAbortState(this DicomClient dicomClient, IInitialisationWithConnectionParameters parameters,
                                                                      DicomClientCancellation cancellation)
        {
            var abortParameters = new DicomClientAbortState.InitialisationParameters(parameters.Connection);
            var abortState      = new DicomClientAbortState(dicomClient, abortParameters);

            return(dicomClient.Transition(abortState, cancellation));
        }
예제 #3
0
        public static Task <IDicomClientState> TransitionToRequestAssociationState(this DicomClient dicomClient, IDicomClientConnection connection,
                                                                                   DicomClientCancellation cancellation)
        {
            var requestAssociationParameters = new DicomClientRequestAssociationState.InitialisationParameters(connection);
            var requestAssociationState      = new DicomClientRequestAssociationState(dicomClient, requestAssociationParameters);

            return(dicomClient.Transition(requestAssociationState, cancellation));
        }
예제 #4
0
 public static Task <IDicomClientState> TransitionToCompletedState(this DicomClient dicomClient, IInitialisationWithConnectionParameters parameters,
                                                                   DicomClientCancellation cancellation)
 {
     return(TransitionToCompletedState(dicomClient, parameters.Connection, cancellation));
 }
예제 #5
0
        public static Task <IDicomClientState> TransitionToReleaseAssociationState(this DicomClient dicomClient,
                                                                                   IInitialisationWithAssociationParameters parameters, DicomClientCancellation cancellation)
        {
            var releaseAssociationParameters = new DicomClientReleaseAssociationState.InitialisationParameters(parameters.Association, parameters.Connection);
            var releaseAssociationState      = new DicomClientReleaseAssociationState(dicomClient, releaseAssociationParameters);

            return(dicomClient.Transition(releaseAssociationState, cancellation));
        }
예제 #6
0
        public static Task <IDicomClientState> TransitionToLingerState(this DicomClient dicomClient,
                                                                       IInitialisationWithAssociationParameters parameters, DicomClientCancellation cancellation)
        {
            var lingerParameters = new DicomClientLingeringState.InitialisationParameters(parameters.Association, parameters.Connection);
            var lingerState      = new DicomClientLingeringState(dicomClient, lingerParameters);

            return(dicomClient.Transition(lingerState, cancellation));
        }
예제 #7
0
        public static Task <IDicomClientState> TransitionToSendingRequestsState(this DicomClient dicomClient, IInitialisationWithConnectionParameters parameters,
                                                                                DicomAssociation association, DicomClientCancellation cancellation)
        {
            var sendingRequestsParameters = new DicomClientSendingRequestsState.InitialisationParameters(association, parameters.Connection);
            var sendingRequestsState      = new DicomClientSendingRequestsState(dicomClient, sendingRequestsParameters);

            return(dicomClient.Transition(sendingRequestsState, cancellation));
        }
예제 #8
0
 public static Task <IDicomClientState> TransitionToSendingRequestsState(this DicomClient dicomClient,
                                                                         IInitialisationWithAssociationParameters parameters, DicomClientCancellation cancellation)
 {
     return(TransitionToSendingRequestsState(dicomClient, parameters, parameters.Association, cancellation));
 }
예제 #9
0
        public static Task <IDicomClientState> TransitionToConnectState(this DicomClient dicomClient, DicomClientCancellation cancellation)
        {
            var connectState = new DicomClientConnectState(dicomClient);

            return(dicomClient.Transition(connectState, cancellation));
        }
예제 #10
0
        public static Task <IDicomClientState> TransitionToIdleState(this DicomClient dicomClient, DicomClientCancellation cancellation)
        {
            var idleState = new DicomClientIdleState(dicomClient);

            return(dicomClient.Transition(idleState, cancellation));
        }
예제 #11
0
        public static Task <IDicomClientState> TransitionToCompletedWithErrorState(this DicomClient dicomClient,
                                                                                   IDicomClientConnection connection,
                                                                                   Exception exception, DicomClientCancellation cancellation)
        {
            var completedWithErrorParameters = connection == null
                ? new DicomClientCompletedState.DicomClientCompletedWithErrorInitialisationParameters(exception)
                : new DicomClientCompletedState.DicomClientCompletedWithErrorInitialisationParameters(exception, connection);
            var completedWithErrorState = new DicomClientCompletedState(dicomClient, completedWithErrorParameters);

            return(dicomClient.Transition(completedWithErrorState, cancellation));
        }
예제 #12
0
 public async Task SendAsync(CancellationToken cancellationToken          = default(CancellationToken),
                             DicomClientCancellationMode cancellationMode = DicomClientCancellationMode.ImmediatelyReleaseAssociation)
 {
     var cancellation = new DicomClientCancellation(cancellationToken, cancellationMode);
     await State.SendAsync(cancellation).ConfigureAwait(false);
 }
예제 #13
0
        internal async Task <IDicomClientState> Transition(IDicomClientState newState, DicomClientCancellation cancellation)
        {
            Task InternalTransition()
            {
                var oldState = State;

                Logger.Debug($"[{oldState}] --> [{newState}]");

                oldState.Dispose();

                State = newState ?? throw new ArgumentNullException(nameof(newState));

                StateChanged?.Invoke(this, new StateChangedEventArgs(oldState, newState));

                return(CompletedTaskProvider.CompletedTask);
            }

            await ExecuteWithinTransitionLock(InternalTransition).ConfigureAwait(false);

            return(await newState.GetNextStateAsync(cancellation).ConfigureAwait(false));
        }