private static ViewGenerator SelectViewGeneratorFromViewDefinition( TerminatingErrorContext errorContext, MshExpressionFactory expressionFactory, TypeInfoDataBase db, ViewDefinition view, FormattingCommandLineParameters parameters) { ViewGenerator viewGenerator = null; if (view.mainControl is TableControlBody) { viewGenerator = new TableViewGenerator(); } else if (view.mainControl is ListControlBody) { viewGenerator = new ListViewGenerator(); } else if (view.mainControl is WideControlBody) { viewGenerator = new WideViewGenerator(); } else if (view.mainControl is ComplexControlBody) { viewGenerator = new ComplexViewGenerator(); } Diagnostics.Assert(viewGenerator != null, "viewGenerator != null"); viewGenerator.Initialize(errorContext, expressionFactory, db, view, parameters); return(viewGenerator); }
private static ViewGenerator SelectViewGeneratorFromProperties(FormatShape shape, PSObject so, TerminatingErrorContext errorContext, PSPropertyExpressionFactory expressionFactory, TypeInfoDataBase db, FormattingCommandLineParameters parameters) { // use some heuristics to determine the shape if none is specified if (shape == FormatShape.Undefined && parameters == null) { // check first if we have a known shape for a type var typeNames = so.InternalTypeNames; shape = DisplayDataQuery.GetShapeFromType(expressionFactory, db, typeNames); if (shape == FormatShape.Undefined) { // check if we can have a table: // we want to get the # of properties we are going to display List <PSPropertyExpression> expressionList = PSObjectHelper.GetDefaultPropertySet(so); if (expressionList.Count == 0) { // we failed to get anything from a property set // we just get the first properties out of the first object foreach (MshResolvedExpressionParameterAssociation mrepa in AssociationManager.ExpandAll(so)) { expressionList.Add(mrepa.ResolvedExpression); } } // decide what shape we want for the given number of properties shape = DisplayDataQuery.GetShapeFromPropertyCount(db, expressionList.Count); } } ViewGenerator viewGenerator = null; if (shape == FormatShape.Table) { viewGenerator = new TableViewGenerator(); } else if (shape == FormatShape.List) { viewGenerator = new ListViewGenerator(); } else if (shape == FormatShape.Wide) { viewGenerator = new WideViewGenerator(); } else if (shape == FormatShape.Complex) { viewGenerator = new ComplexViewGenerator(); } Diagnostics.Assert(viewGenerator != null, "viewGenerator != null"); viewGenerator.Initialize(errorContext, expressionFactory, so, db, parameters); return(viewGenerator); }
private static Microsoft.PowerShell.Commands.Internal.Format.ViewGenerator SelectViewGeneratorFromViewDefinition(TerminatingErrorContext errorContext, MshExpressionFactory expressionFactory, TypeInfoDataBase db, ViewDefinition view, FormattingCommandLineParameters parameters) { Microsoft.PowerShell.Commands.Internal.Format.ViewGenerator generator = null; if (view.mainControl is TableControlBody) { generator = new TableViewGenerator(); } else if (view.mainControl is ListControlBody) { generator = new ListViewGenerator(); } else if (view.mainControl is WideControlBody) { generator = new WideViewGenerator(); } else if (view.mainControl is ComplexControlBody) { generator = new ComplexViewGenerator(); } generator.Initialize(errorContext, expressionFactory, db, view, parameters); return(generator); }
private static Microsoft.PowerShell.Commands.Internal.Format.ViewGenerator SelectViewGeneratorFromProperties(FormatShape shape, PSObject so, TerminatingErrorContext errorContext, MshExpressionFactory expressionFactory, TypeInfoDataBase db, FormattingCommandLineParameters parameters) { if ((shape == FormatShape.Undefined) && (parameters == null)) { ConsolidatedString internalTypeNames = so.InternalTypeNames; shape = DisplayDataQuery.GetShapeFromType(expressionFactory, db, internalTypeNames); if (shape == FormatShape.Undefined) { List <MshExpression> defaultPropertySet = PSObjectHelper.GetDefaultPropertySet(so); if (defaultPropertySet.Count == 0) { foreach (MshResolvedExpressionParameterAssociation association in AssociationManager.ExpandAll(so)) { defaultPropertySet.Add(association.ResolvedExpression); } } shape = DisplayDataQuery.GetShapeFromPropertyCount(db, defaultPropertySet.Count); } } Microsoft.PowerShell.Commands.Internal.Format.ViewGenerator generator = null; if (shape == FormatShape.Table) { generator = new TableViewGenerator(); } else if (shape == FormatShape.List) { generator = new ListViewGenerator(); } else if (shape == FormatShape.Wide) { generator = new WideViewGenerator(); } else if (shape == FormatShape.Complex) { generator = new ComplexViewGenerator(); } generator.Initialize(errorContext, expressionFactory, so, db, parameters); return(generator); }
private static ViewGenerator SelectViewGeneratorFromProperties(FormatShape shape, PSObject so, TerminatingErrorContext errorContext, MshExpressionFactory expressionFactory, TypeInfoDataBase db, FormattingCommandLineParameters parameters) { // use some heuristics to determine the shape if none is specified if (shape == FormatShape.Undefined && parameters == null) { // check first if we have a known shape for a type var typeNames = so.InternalTypeNames; shape = DisplayDataQuery.GetShapeFromType(expressionFactory, db, typeNames); if (shape == FormatShape.Undefined) { // check if we can have a table: // we want to get the # of properties we are going to display List<MshExpression> expressionList = PSObjectHelper.GetDefaultPropertySet(so); if (expressionList.Count == 0) { // we failed to get anything from a property set // we just get the first properties out of the first object foreach (MshResolvedExpressionParameterAssociation mrepa in AssociationManager.ExpandAll(so)) { expressionList.Add(mrepa.ResolvedExpression); } } // decide what shape we want for the given number of properties shape = DisplayDataQuery.GetShapeFromPropertyCount(db, expressionList.Count); } } ViewGenerator viewGenerator = null; if (shape == FormatShape.Table) { viewGenerator = new TableViewGenerator(); } else if (shape == FormatShape.List) { viewGenerator = new ListViewGenerator(); } else if (shape == FormatShape.Wide) { viewGenerator = new WideViewGenerator(); } else if (shape == FormatShape.Complex) { viewGenerator = new ComplexViewGenerator(); } Diagnostics.Assert(viewGenerator != null, "viewGenerator != null"); viewGenerator.Initialize(errorContext, expressionFactory, so, db, parameters); return viewGenerator; }
private static ViewGenerator SelectViewGeneratorFromViewDefinition( TerminatingErrorContext errorContext, MshExpressionFactory expressionFactory, TypeInfoDataBase db, ViewDefinition view, FormattingCommandLineParameters parameters) { ViewGenerator viewGenerator = null; if (view.mainControl is TableControlBody) { viewGenerator = new TableViewGenerator(); } else if (view.mainControl is ListControlBody) { viewGenerator = new ListViewGenerator(); } else if (view.mainControl is WideControlBody) { viewGenerator = new WideViewGenerator(); } else if (view.mainControl is ComplexControlBody) { viewGenerator = new ComplexViewGenerator(); } Diagnostics.Assert(viewGenerator != null, "viewGenerator != null"); viewGenerator.Initialize(errorContext, expressionFactory, db, view, parameters); return viewGenerator; }
private static Microsoft.PowerShell.Commands.Internal.Format.ViewGenerator SelectViewGeneratorFromViewDefinition(TerminatingErrorContext errorContext, MshExpressionFactory expressionFactory, TypeInfoDataBase db, ViewDefinition view, FormattingCommandLineParameters parameters) { Microsoft.PowerShell.Commands.Internal.Format.ViewGenerator generator = null; if (view.mainControl is TableControlBody) { generator = new TableViewGenerator(); } else if (view.mainControl is ListControlBody) { generator = new ListViewGenerator(); } else if (view.mainControl is WideControlBody) { generator = new WideViewGenerator(); } else if (view.mainControl is ComplexControlBody) { generator = new ComplexViewGenerator(); } generator.Initialize(errorContext, expressionFactory, db, view, parameters); return generator; }
private static Microsoft.PowerShell.Commands.Internal.Format.ViewGenerator SelectViewGeneratorFromProperties(FormatShape shape, PSObject so, TerminatingErrorContext errorContext, MshExpressionFactory expressionFactory, TypeInfoDataBase db, FormattingCommandLineParameters parameters) { if ((shape == FormatShape.Undefined) && (parameters == null)) { ConsolidatedString internalTypeNames = so.InternalTypeNames; shape = DisplayDataQuery.GetShapeFromType(expressionFactory, db, internalTypeNames); if (shape == FormatShape.Undefined) { List<MshExpression> defaultPropertySet = PSObjectHelper.GetDefaultPropertySet(so); if (defaultPropertySet.Count == 0) { foreach (MshResolvedExpressionParameterAssociation association in AssociationManager.ExpandAll(so)) { defaultPropertySet.Add(association.ResolvedExpression); } } shape = DisplayDataQuery.GetShapeFromPropertyCount(db, defaultPropertySet.Count); } } Microsoft.PowerShell.Commands.Internal.Format.ViewGenerator generator = null; if (shape == FormatShape.Table) { generator = new TableViewGenerator(); } else if (shape == FormatShape.List) { generator = new ListViewGenerator(); } else if (shape == FormatShape.Wide) { generator = new WideViewGenerator(); } else if (shape == FormatShape.Complex) { generator = new ComplexViewGenerator(); } generator.Initialize(errorContext, expressionFactory, so, db, parameters); return generator; }