internal static FormatEntryData GenerateOutOfBandData(TerminatingErrorContext errorContext, PSPropertyExpressionFactory expressionFactory, TypeInfoDataBase db, PSObject so, int enumerationLimit, bool useToStringFallback, out List <ErrorRecord> errors) { errors = null; var typeNames = so.InternalTypeNames; ViewDefinition view = DisplayDataQuery.GetOutOfBandView(expressionFactory, db, typeNames); ViewGenerator outOfBandViewGenerator; if (view != null) { // process an out of band view retrieved from the display database if (view.mainControl is ComplexControlBody) { outOfBandViewGenerator = new ComplexViewGenerator(); } else { outOfBandViewGenerator = new ListViewGenerator(); } outOfBandViewGenerator.Initialize(errorContext, expressionFactory, db, view, null); } else { if (DefaultScalarTypes.IsTypeInList(typeNames) || IsPropertyLessObject(so)) { // we force a ToString() on well known types return(GenerateOutOfBandObjectAsToString(so)); } if (!useToStringFallback) { return(null); } // we must check we have enough properties for a list view if (new PSPropertyExpression("*").ResolveNames(so).Count <= 0) { return(null); } // we do not have a view, we default to list view // process an out of band view as a default outOfBandViewGenerator = new ListViewGenerator(); outOfBandViewGenerator.Initialize(errorContext, expressionFactory, so, db, null); } FormatEntryData fed = outOfBandViewGenerator.GeneratePayload(so, enumerationLimit); fed.outOfBand = true; fed.SetStreamTypeFromPSObject(so); errors = outOfBandViewGenerator.ErrorManager.DrainFailedResultList(); return(fed); }
internal static FormatEntryData GenerateOutOfBandData(TerminatingErrorContext errorContext, MshExpressionFactory expressionFactory, TypeInfoDataBase db, PSObject so, int enumerationLimit, bool useToStringFallback, out List <ErrorRecord> errors) { ViewGenerator generator; errors = null; ConsolidatedString internalTypeNames = so.InternalTypeNames; ViewDefinition view = DisplayDataQuery.GetOutOfBandView(expressionFactory, db, internalTypeNames); if (view != null) { if (view.mainControl is ComplexControlBody) { generator = new ComplexViewGenerator(); } else { generator = new ListViewGenerator(); } generator.Initialize(errorContext, expressionFactory, db, view, null); } else { if (DefaultScalarTypes.IsTypeInList(internalTypeNames) || IsPropertyLessObject(so)) { return(GenerateOutOfBandObjectAsToString(so)); } if (!useToStringFallback) { return(null); } if (new MshExpression("*").ResolveNames(so).Count <= 0) { return(null); } generator = new ListViewGenerator(); generator.Initialize(errorContext, expressionFactory, so, db, null); } FormatEntryData data = generator.GeneratePayload(so, enumerationLimit); data.outOfBand = true; data.SetStreamTypeFromPSObject(so); errors = generator.ErrorManager.DrainFailedResultList(); return(data); }
internal static ViewDefinition GetOutOfBandView( MshExpressionFactory expressionFactory, TypeInfoDataBase db, Collection <string> typeNames) { TypeMatch typeMatch = new TypeMatch(expressionFactory, db, typeNames); foreach (ViewDefinition viewDefinition in db.viewDefinitionsSection.viewDefinitionList) { if (DisplayDataQuery.IsOutOfBandView(viewDefinition) && typeMatch.PerfectMatch(new TypeMatchItem((object)viewDefinition, viewDefinition.appliesTo))) { return(viewDefinition); } } if (!(typeMatch.BestMatch is ViewDefinition viewDefinition)) { Collection <string> typeNames1 = Deserializer.MaskDeserializationPrefix(typeNames); if (typeNames1 != null) { viewDefinition = DisplayDataQuery.GetOutOfBandView(expressionFactory, db, typeNames1); } } return(viewDefinition); }