Esempio n. 1
0
 private static string getError(OutputMessages pMessages, Description pDescription, eERROR pError)
 {
     using (StringWriter sw = new StringWriter())
     {
         Console.SetError(sw);
         pMessages.Error(pDescription, pError);
         return sw.ToString().Trim();
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Prints an error message that relates to the description.
        /// </summary>
        /// <param name="pDescs">Collection of parameter descriptions.</param>
        /// <param name="pError">Type of error being reported.</param>
        /// <returns>True if any errors reported.</returns>
        private bool Report(IEnumerable <Description> pDescs, eERROR pError)
        {
            bool result = false;

            foreach (Description desc in pDescs)
            {
                _messages.Error(desc, pError);
                result = true;
            }
            return(result);
        }
Esempio n. 3
0
        public void Error_1()
        {
            MockOutput     mock   = new MockOutput();
            OutputMessages output = new OutputMessages(CliOptions.WindowsStyle, mock);

            Description desc = new Description("width", "The rectangle width", eROLE.NAMED, new ParamString(),
                                               eSCOPE.REQUIRED,
                                               eMULTIPLICITY.ONCE);

            const eERROR unsupported = (eERROR)(-1);

            output.Error(desc, unsupported);
        }
Esempio n. 4
0
        /// <summary>
        /// Called when a validation fails on the parameters.
        /// </summary>
        /// <param name="pDesc">The description of the failed parameter.</param>
        /// <param name="pError">The type of error.</param>
        public void Error(Description pDesc, eERROR pError)
        {
            switch (pError)
            {
                case eERROR.REQUIRED:
                    _output.Error(OutputFormatter.WriteRequired(pDesc.Role, _options.Prefix, pDesc.Name));
                    return;
                case eERROR.DUPLICATE:
                    _output.Error(OutputFormatter.WriteDuplicate(pDesc.Role, _options.Prefix, pDesc.Name));
                    return;
                case eERROR.MISSING_VALUE:
                    _output.Error(OutputFormatter.WriteMissingValue(pDesc.Role, _options.Prefix, pDesc.Name));
                    return;
            }

            throw new InvalidArgumentException("Unsupported error type");
        }
Esempio n. 5
0
        /// <summary>
        /// Called when a validation fails on the parameters.
        /// </summary>
        /// <param name="pDesc">The description of the failed parameter.</param>
        /// <param name="pError">The type of error.</param>
        public void Error(Description pDesc, eERROR pError)
        {
            switch (pError)
            {
            case eERROR.REQUIRED:
                _output.Error(OutputFormatter.WriteRequired(pDesc.Role, _options.Prefix, pDesc.Name));
                return;

            case eERROR.DUPLICATE:
                _output.Error(OutputFormatter.WriteDuplicate(pDesc.Role, _options.Prefix, pDesc.Name));
                return;

            case eERROR.MISSING_VALUE:
                _output.Error(OutputFormatter.WriteMissingValue(pDesc.Role, _options.Prefix, pDesc.Name));
                return;
            }

            throw new InvalidArgumentException("Unsupported error type");
        }
Esempio n. 6
0
 /// <summary>
 /// Prints an error message that relates to the description.
 /// </summary>
 /// <param name="pDescs">Collection of parameter descriptions.</param>
 /// <param name="pError">Type of error being reported.</param>
 /// <returns>True if any errors reported.</returns>
 private bool Report(IEnumerable<Description> pDescs, eERROR pError)
 {
     bool result = false;
     foreach (Description desc in pDescs)
     {
         _messages.Error(desc, pError);
         result = true;
     }
     return result;
 }
Esempio n. 7
0
 private static string getError(OutputMessages pMessages, Description pDescription, eERROR pError)
 {
     using (StringWriter sw = new StringWriter())
     {
         Console.SetError(sw);
         pMessages.Error(pDescription, pError);
         return(sw.ToString().Trim());
     }
 }