Exemple #1
0
 internal override FormattingCommandLineParameters GetCommandLineParameters()
 {
     FormattingCommandLineParameters parameters = new FormattingCommandLineParameters();
     if (this.prop != null)
     {
         ParameterProcessor processor = new ParameterProcessor(new FormatWideParameterDefinition());
         TerminatingErrorContext invocationContext = new TerminatingErrorContext(this);
         parameters.mshParameterList = processor.ProcessParameters(new object[] { this.prop }, invocationContext);
     }
     if (!string.IsNullOrEmpty(base.View))
     {
         if (parameters.mshParameterList.Count != 0)
         {
             base.ReportCannotSpecifyViewAndProperty();
         }
         parameters.viewName = base.View;
     }
     if ((this.autosize.HasValue && this.column.HasValue) && this.autosize.Value)
     {
         string message = StringUtil.Format(FormatAndOut_format_xxx.CannotSpecifyAutosizeAndColumnsError, new object[0]);
         ErrorRecord errorRecord = new ErrorRecord(new InvalidDataException(), "FormatCannotSpecifyAutosizeAndColumns", ErrorCategory.InvalidArgument, null) {
             ErrorDetails = new ErrorDetails(message)
         };
         base.ThrowTerminatingError(errorRecord);
     }
     parameters.groupByParameter = base.ProcessGroupByParameter();
     parameters.forceFormattingAlsoOnOutOfBand = (bool) base.Force;
     if (this.showErrorsAsMessages.HasValue)
     {
         parameters.showErrorsAsMessages = base.showErrorsAsMessages;
     }
     if (this.showErrorsInFormattedOutput.HasValue)
     {
         parameters.showErrorsInFormattedOutput = base.showErrorsInFormattedOutput;
     }
     parameters.expansion = base.ProcessExpandParameter();
     if (this.autosize.HasValue)
     {
         parameters.autosize = new bool?(this.autosize.Value);
     }
     WideSpecificParameters parameters2 = new WideSpecificParameters();
     parameters.shapeParameters = parameters2;
     if (this.column.HasValue)
     {
         parameters2.columns = new int?(this.column.Value);
     }
     return parameters;
 }
Exemple #2
0
        internal override FormattingCommandLineParameters GetCommandLineParameters()
        {
            FormattingCommandLineParameters parameters = new FormattingCommandLineParameters();

            if (_prop != null)
            {
                ParameterProcessor processor = new ParameterProcessor(new FormatWideParameterDefinition());
                TerminatingErrorContext invocationContext = new TerminatingErrorContext(this);
                parameters.mshParameterList = processor.ProcessParameters(new object[] { _prop }, invocationContext);
            }

            if (!string.IsNullOrEmpty(this.View))
            {
                // we have a view command line switch
                if (parameters.mshParameterList.Count != 0)
                {
                    ReportCannotSpecifyViewAndProperty();
                }
                parameters.viewName = this.View;
            }

            // we cannot specify -column and -autosize, they are mutually exclusive
            if (_autosize.HasValue && _column.HasValue)
            {
                if (_autosize.Value)
                {
                    // the user specified -autosize:true AND a column number
                    string msg = StringUtil.Format(FormatAndOut_format_xxx.CannotSpecifyAutosizeAndColumnsError);


                    ErrorRecord errorRecord = new ErrorRecord(
                        new InvalidDataException(),
                        "FormatCannotSpecifyAutosizeAndColumns",
                        ErrorCategory.InvalidArgument,
                        null);

                    errorRecord.ErrorDetails = new ErrorDetails(msg);
                    this.ThrowTerminatingError(errorRecord);
                }
            }

            parameters.groupByParameter = this.ProcessGroupByParameter();
            parameters.forceFormattingAlsoOnOutOfBand = this.Force;
            if (this.showErrorsAsMessages.HasValue)
                parameters.showErrorsAsMessages = this.showErrorsAsMessages;
            if (this.showErrorsInFormattedOutput.HasValue)
                parameters.showErrorsInFormattedOutput = this.showErrorsInFormattedOutput;

            parameters.expansion = ProcessExpandParameter();

            if (_autosize.HasValue)
                parameters.autosize = _autosize.Value;

            WideSpecificParameters wideSpecific = new WideSpecificParameters();
            parameters.shapeParameters = wideSpecific;
            if (_column.HasValue)
            {
                wideSpecific.columns = _column.Value;
            }
            return parameters;
        }