internal override FormattingCommandLineParameters GetCommandLineParameters() { FormattingCommandLineParameters parameters = new FormattingCommandLineParameters(); if (this.props != null) { ParameterProcessor processor = new ParameterProcessor(new FormatObjectParameterDefinition()); TerminatingErrorContext invocationContext = new TerminatingErrorContext(this); parameters.mshParameterList = processor.ProcessParameters(this.props, invocationContext); } if (!string.IsNullOrEmpty(base.View)) { if (parameters.mshParameterList.Count != 0) { base.ReportCannotSpecifyViewAndProperty(); } parameters.viewName = base.View; } 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(); ComplexSpecificParameters parameters2 = new ComplexSpecificParameters { maxDepth = this.depth }; parameters.shapeParameters = parameters2; return parameters; }
internal ComplexViewEntry GenerateView(PSObject so, FormattingCommandLineParameters inputParameters) { this.complexSpecificParameters = (ComplexSpecificParameters)inputParameters.shapeParameters; int maxDepth = this.complexSpecificParameters.maxDepth; TraversalInfo level = new TraversalInfo(0, maxDepth); List <MshParameter> parameterList = null; if (inputParameters != null) { parameterList = inputParameters.mshParameterList; } ComplexViewEntry entry = new ComplexViewEntry(); if (TreatAsScalarType(so.InternalTypeNames)) { FormatEntry item = new FormatEntry(); entry.formatValueList.Add(item); this.DisplayRawObject(so, item.formatValueList); return(entry); } IEnumerable e = PSObjectHelper.GetEnumerable(so); if (e != null) { FormatEntry entry3 = new FormatEntry(); entry.formatValueList.Add(entry3); this.DisplayEnumeration(e, level, entry3.formatValueList); return(entry); } this.DisplayObject(so, level, parameterList, entry.formatValueList); return(entry); }
/// <summary> /// Given an object, generate a tree-like view /// of the object. /// </summary> /// <param name="so">Object to process.</param> /// <param name="inputParameters">Parameters from the command line.</param> /// <returns>Complex view entry to send to the output command.</returns> internal ComplexViewEntry GenerateView(PSObject so, FormattingCommandLineParameters inputParameters) { _complexSpecificParameters = (ComplexSpecificParameters)inputParameters.shapeParameters; int maxDepth = _complexSpecificParameters.maxDepth; TraversalInfo level = new TraversalInfo(0, maxDepth); List<MshParameter> mshParameterList = null; mshParameterList = inputParameters.mshParameterList; // create a top level entry as root of the tree ComplexViewEntry cve = new ComplexViewEntry(); var typeNames = so.InternalTypeNames; if (TreatAsScalarType(typeNames)) { FormatEntry fe = new FormatEntry(); cve.formatValueList.Add(fe); DisplayRawObject(so, fe.formatValueList); } else { // check if the top level object is an enumeration IEnumerable e = PSObjectHelper.GetEnumerable(so); if (e != null) { // let's start the traversal with an enumeration FormatEntry fe = new FormatEntry(); cve.formatValueList.Add(fe); DisplayEnumeration(e, level, fe.formatValueList); } else { // let's start the traversal with a traversal on properties DisplayObject(so, level, mshParameterList, cve.formatValueList); } } return cve; }
internal ComplexViewEntry GenerateView(PSObject so, FormattingCommandLineParameters inputParameters) { this.complexSpecificParameters = (ComplexSpecificParameters) inputParameters.shapeParameters; int maxDepth = this.complexSpecificParameters.maxDepth; TraversalInfo level = new TraversalInfo(0, maxDepth); List<MshParameter> parameterList = null; if (inputParameters != null) { parameterList = inputParameters.mshParameterList; } ComplexViewEntry entry = new ComplexViewEntry(); if (TreatAsScalarType(so.InternalTypeNames)) { FormatEntry item = new FormatEntry(); entry.formatValueList.Add(item); this.DisplayRawObject(so, item.formatValueList); return entry; } IEnumerable e = PSObjectHelper.GetEnumerable(so); if (e != null) { FormatEntry entry3 = new FormatEntry(); entry.formatValueList.Add(entry3); this.DisplayEnumeration(e, level, entry3.formatValueList); return entry; } this.DisplayObject(so, level, parameterList, entry.formatValueList); return entry; }
internal override FormattingCommandLineParameters GetCommandLineParameters() { FormattingCommandLineParameters parameters = new FormattingCommandLineParameters(); if (_props != null) { ParameterProcessor processor = new ParameterProcessor(new FormatObjectParameterDefinition()); TerminatingErrorContext invocationContext = new TerminatingErrorContext(this); parameters.mshParameterList = processor.ProcessParameters(_props, invocationContext); } if (!string.IsNullOrEmpty(this.View)) { // we have a view command line switch if (parameters.mshParameterList.Count != 0) { ReportCannotSpecifyViewAndProperty(); } parameters.viewName = this.View; } 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(); ComplexSpecificParameters csp = new ComplexSpecificParameters(); csp.maxDepth = _depth; parameters.shapeParameters = csp; return parameters; }