Example #1
0
 public static As2Disposition failed(String message)
 {
     return(new As2Disposition(
                ActionMode.AUTOMATIC,
                SendingMode.Automatic,
                DispositionType.Failed,
                DispositionModifier.Failed(message)));
 }
Example #2
0
 public static As2Disposition processedWithError(String errorMessage)
 {
     return(new As2Disposition(
                ActionMode.AUTOMATIC,
                SendingMode.Automatic,
                DispositionType.Processed,
                DispositionModifier.Error(errorMessage)));
 }
Example #3
0
 public static As2Disposition processedWithWarning(String warningMessage)
 {
     return(new As2Disposition(
                ActionMode.AUTOMATIC,
                SendingMode.Automatic,
                DispositionType.Processed,
                DispositionModifier.Warning(warningMessage)));
 }
Example #4
0
        public As2Disposition(
            ActionMode actionMode,
            SendingMode sendingMode,
            DispositionType dispositionType,
            DispositionModifier dispositionModifier)
        {
            this.actionMode      = actionMode;
            this.sendingMode     = sendingMode;
            this.DispositionType = dispositionType;

            // Only processed/error or processed/warning is allowed
            if (dispositionType == DispositionType.Processed &&
                (dispositionModifier.Prefix == DispositionModifierPrefix.Failure))
            {
                throw new ArgumentException(
                          "DispositionType 'processed' does not allow a prefix of 'failed'. Only 'error' and 'warning' are allowed");
            }

            this.dispositionModifier = dispositionModifier;
        }
Example #5
0
        public static As2Disposition valueOf(String s)
        {
            s = (s ?? string.Empty).Trim();
            Match matcher = pattern.Match(s);

            if (!matcher.Success)
            {
                throw new ArgumentException("'" + s + "'" + " does not match pattern for As2Disposition");
            }

            String     actionModeString = matcher.Groups[1].Value;
            ActionMode actionMode       = ActionMode.CreateFromTextValue(actionModeString);

            String      sendingModeString = matcher.Groups[2].Value;
            SendingMode sendingMode       = SendingMode.CreateFromTextValue(sendingModeString);

            String          dispositionTypeString = matcher.Groups[3].Value;
            DispositionType dispositionType       = DispositionType.ValueOf(dispositionTypeString.ToLowerInvariant());

            As2Disposition result;

            if (matcher.Groups[4].Success)
            {
                DispositionModifier dispositionModifier;
                String dispositionModifierPrefixString = matcher.Groups[5].Value;
                String dispositionModifierString       = matcher.Groups[6].Value;
                dispositionModifier = new DispositionModifier(
                    DispositionModifierPrefix.ValueOf(dispositionModifierPrefixString.ToUpperInvariant()),
                    dispositionModifierString);
                result = new As2Disposition(actionMode, sendingMode, dispositionType, dispositionModifier);
            }
            else
            {
                result = new As2Disposition(actionMode, sendingMode, dispositionType);
            }

            return(result);
        }