protected void WriteInternalErrorMessage(string message) { FormatEntryData fed = new FormatEntryData(); fed.outOfBand = true; ComplexViewEntry cve = new ComplexViewEntry(); FormatEntry fe = new FormatEntry(); cve.formatValueList.Add(fe); fe.formatValueList.Add(new FormatNewLine()); // get a field for the message FormatTextField ftf = new FormatTextField(); ftf.text = message; fe.formatValueList.Add(ftf); fe.formatValueList.Add(new FormatNewLine()); fed.formatEntryInfo = cve; this.WriteObject(fed); }
private ComplexViewEntry GenerateComplexViewEntryFromDataBaseInfo(PSObject so, int enumerationLimit) { ComplexViewEntry entry = new ComplexViewEntry(); new ComplexControlGenerator(base.dataBaseInfo.db, base.dataBaseInfo.view.loadingInfo, base.expressionFactory, base.dataBaseInfo.view.formatControlDefinitionHolder.controlDefinitionList, base.ErrorManager, enumerationLimit, base.errorContext).GenerateFormatEntries(50, base.dataBaseInfo.view.mainControl, so, entry.formatValueList); return(entry); }
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 void ProcessPayload(FormatEntryData fed) { ComplexViewEntry formatEntryInfo = fed.formatEntryInfo as ComplexViewEntry; if ((formatEntryInfo != null) && (formatEntryInfo.formatValueList != null)) { this.writer.WriteObject(formatEntryInfo.formatValueList); } }
/// <summary> /// write a row into the list /// </summary> /// <param name="fed">FormatEntryData to process</param> internal override void ProcessPayload(FormatEntryData fed) { ComplexViewEntry cve = fed.formatEntryInfo as ComplexViewEntry; if (cve == null || cve.formatValueList == null) { return; } _writer.WriteObject(cve.formatValueList); }
private void ProcessOutOfBandPayload(FormatEntryData fed) { // try if it is raw text RawTextFormatEntry rte = fed.formatEntryInfo as RawTextFormatEntry; if (rte != null) { if (fed.isHelpObject) { ComplexWriter complexWriter = new ComplexWriter(); complexWriter.Initialize(_lo, _lo.ColumnNumber); complexWriter.WriteString(rte.text); } else { _lo.WriteLine(rte.text); } return; } // try if it is a complex entry ComplexViewEntry cve = fed.formatEntryInfo as ComplexViewEntry; if (cve != null && cve.formatValueList != null) { ComplexWriter complexWriter = new ComplexWriter(); complexWriter.Initialize(_lo, int.MaxValue); complexWriter.WriteObject(cve.formatValueList); return; } // try if it is a list view ListViewEntry lve = fed.formatEntryInfo as ListViewEntry; if (lve != null && lve.listViewFieldList != null) { ListWriter listWriter = new ListWriter(); _lo.WriteLine(""); string[] properties = ListOutputContext.GetProperties(lve); listWriter.Initialize(properties, _lo.ColumnNumber, _lo.DisplayCells); string[] values = ListOutputContext.GetValues(lve); listWriter.WriteProperties(values, _lo); _lo.WriteLine(""); return; } }
/// <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; if (inputParameters != 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); }
private void WriteNewLineObject() { FormatEntryData fed = new FormatEntryData(); fed.outOfBand = true; ComplexViewEntry cve = new ComplexViewEntry(); FormatEntry fe = new FormatEntry(); cve.formatValueList.Add(fe); // Formating system writes newline before each object // so no need to add newline here like: // fe.formatValueList.Add(new FormatNewLine()); fed.formatEntryInfo = cve; this.WriteObject(fed); }
protected void WriteInternalErrorMessage(string message) { FormatEntryData o = new FormatEntryData { outOfBand = true }; ComplexViewEntry entry = new ComplexViewEntry(); FormatEntry item = new FormatEntry(); entry.formatValueList.Add(item); item.formatValueList.Add(new FormatNewLine()); FormatTextField field = new FormatTextField { text = message }; item.formatValueList.Add(field); item.formatValueList.Add(new FormatNewLine()); o.formatEntryInfo = entry; this.WriteObject(o); }
private void ProcessOutOfBandPayload(FormatEntryData fed) { RawTextFormatEntry formatEntryInfo = fed.formatEntryInfo as RawTextFormatEntry; if (formatEntryInfo != null) { if (fed.isHelpObject) { ComplexWriter writer = new ComplexWriter(); writer.Initialize(this.lo, this.lo.ColumnNumber); writer.WriteString(formatEntryInfo.text); } else { this.lo.WriteLine(formatEntryInfo.text); } } else { ComplexViewEntry entry2 = fed.formatEntryInfo as ComplexViewEntry; if ((entry2 != null) && (entry2.formatValueList != null)) { ComplexWriter writer2 = new ComplexWriter(); writer2.Initialize(this.lo, this.lo.ColumnNumber); writer2.WriteObject(entry2.formatValueList); } else { ListViewEntry lve = fed.formatEntryInfo as ListViewEntry; if ((lve != null) && (lve.listViewFieldList != null)) { ListWriter writer3 = new ListWriter(); this.lo.WriteLine(""); string[] properties = ListOutputContext.GetProperties(lve); writer3.Initialize(properties, this.lo.ColumnNumber, this.lo.DisplayCells); string[] values = ListOutputContext.GetValues(lve); writer3.WriteProperties(values, this.lo); this.lo.WriteLine(""); } } } }
private ComplexViewEntry GenerateComplexViewEntryFromDataBaseInfo(PSObject so, int enumerationLimit) { // execute on the format directive ComplexViewEntry cve = new ComplexViewEntry(); // NOTE: we set a max depth to protect ourselves from infinite loops const int maxTreeDepth = 50; ComplexControlGenerator controlGenerator = new ComplexControlGenerator(this.dataBaseInfo.db, this.dataBaseInfo.view.loadingInfo, this.expressionFactory, this.dataBaseInfo.view.formatControlDefinitionHolder.controlDefinitionList, this.ErrorManager, enumerationLimit, this.errorContext); controlGenerator.GenerateFormatEntries(maxTreeDepth, this.dataBaseInfo.view.mainControl, so, cve.formatValueList); return(cve); }
private ComplexViewEntry GenerateComplexViewEntryFromDataBaseInfo(PSObject so, int enumerationLimit) { // execute on the format directive ComplexViewEntry cve = new ComplexViewEntry(); // NOTE: we set a max depth to protect ourselves from infinite loops const int maxTreeDepth = 50; ComplexControlGenerator controlGenerator = new ComplexControlGenerator(this.dataBaseInfo.db, this.dataBaseInfo.view.loadingInfo, this.expressionFactory, this.dataBaseInfo.view.formatControlDefinitionHolder.controlDefinitionList, this.ErrorManager, enumerationLimit, this.errorContext); controlGenerator.GenerateFormatEntries(maxTreeDepth, this.dataBaseInfo.view.mainControl, so, 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; }
private ComplexViewEntry GenerateComplexViewEntryFromDataBaseInfo(PSObject so, int enumerationLimit) { ComplexViewEntry entry = new ComplexViewEntry(); new ComplexControlGenerator(base.dataBaseInfo.db, base.dataBaseInfo.view.loadingInfo, base.expressionFactory, base.dataBaseInfo.view.formatControlDefinitionHolder.controlDefinitionList, base.ErrorManager, enumerationLimit, base.errorContext).GenerateFormatEntries(50, base.dataBaseInfo.view.mainControl, so, 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; if (inputParameters != 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; }