/// <summary>
        ///   Gets the serialized value of the specified state.
        /// </summary>
        /// <param name="state">The state.</param>
        /// <returns>The serialized value.</returns>
        public string Serialize(IssueAnnotationState state)
        {
            switch (state)
            {
            case IssueAnnotationState.FalsePositive:
                return(Resources.FalsePositiveMarker);

            case IssueAnnotationState.Fixed:
                return(Resources.FixedMarker);

            case IssueAnnotationState.Reopen:
                return(Resources.ReopenMarker);

            case IssueAnnotationState.Todo:
                return(Resources.TodoMarker);

            case IssueAnnotationState.Verify:
                return(Resources.VerifyMarker);

            default:
                throw new InvalidEnumArgumentException(nameof(state));
            }
        }
Beispiel #2
0
        /// <summary>
        ///   Changes the state of the annotation.
        /// </summary>
        /// <param name="annotation">The annotation.</param>
        /// <param name="toState">State of the annotation to change to.</param>
        public void ChangeState(IssueAnnotation annotation, IssueAnnotationState toState)
        {
            if (annotation.State == toState)
            {
                return;
            }

            switch (annotation.State)
            {
            case IssueAnnotationState.FalsePositive:
                throw new InvalidOperationException(
                          Resources.AnnotationStateCantBeChanged.FormatWith(
                              _serializer.Serialize(annotation.State),
                              _serializer.Serialize(toState)));

            case IssueAnnotationState.Fixed:
                if (toState != IssueAnnotationState.Reopen)
                {
                    throw new InvalidOperationException(
                              Resources.AnnotationStateCantBeChanged.FormatWith(
                                  _serializer.Serialize(annotation.State),
                                  _serializer.Serialize(toState)));
                }

                break;

            case IssueAnnotationState.Reopen:
                if (toState != IssueAnnotationState.Fixed)
                {
                    throw new InvalidOperationException(
                              Resources.AnnotationStateCantBeChanged.FormatWith(
                                  _serializer.Serialize(annotation.State),
                                  _serializer.Serialize(toState)));
                }

                break;

            case IssueAnnotationState.Todo:
                if (toState != IssueAnnotationState.Fixed)
                {
                    throw new InvalidOperationException(
                              Resources.AnnotationStateCantBeChanged.FormatWith(
                                  _serializer.Serialize(annotation.State),
                                  _serializer.Serialize(toState)));
                }

                break;

            case IssueAnnotationState.Verify:
                if ((toState != IssueAnnotationState.Fixed) && (toState != IssueAnnotationState.Reopen))
                {
                    throw new InvalidOperationException(
                              Resources.AnnotationStateCantBeChanged.FormatWith(
                                  _serializer.Serialize(annotation.State),
                                  _serializer.Serialize(toState)));
                }

                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            annotation.State = toState;
        }