示例#1
0
        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 EnumerableExpansion GetExpansionState(PSObject so)
        {
            if ((this.parameters != null) && this.parameters.expansion.HasValue)
            {
                return(this.parameters.expansion.Value);
            }
            ConsolidatedString internalTypeNames = so.InternalTypeNames;

            return(DisplayDataQuery.GetEnumerableExpansionFromType(this.expressionFactory, this._typeInfoDataBase, internalTypeNames));
        }
示例#3
0
 internal virtual void Initialize(TerminatingErrorContext terminatingErrorContext, MshExpressionFactory mshExpressionFactory, TypeInfoDataBase db, ViewDefinition view, FormattingCommandLineParameters formatParameters)
 {
     this.errorContext                 = terminatingErrorContext;
     this.expressionFactory            = mshExpressionFactory;
     this.parameters                   = formatParameters;
     this.dataBaseInfo.db              = db;
     this.dataBaseInfo.view            = view;
     this.dataBaseInfo.applicableTypes = DisplayDataQuery.GetAllApplicableTypes(db, view.appliesTo);
     this.InitializeHelper();
 }
示例#4
0
        private static ViewDefinition GetDefaultView(
            MshExpressionFactory expressionFactory,
            TypeInfoDataBase db,
            Collection <string> typeNames)
        {
            TypeMatch match = new TypeMatch(expressionFactory, db, typeNames);

            foreach (ViewDefinition viewDefinition in db.viewDefinitionsSection.viewDefinitionList)
            {
                if (viewDefinition != null)
                {
                    if (DisplayDataQuery.IsOutOfBandView(viewDefinition))
                    {
                        DisplayDataQuery.ActiveTracer.WriteLine("NOT MATCH OutOfBand {0}  NAME: {1}", (object)ControlBase.GetControlShapeName(viewDefinition.mainControl), (object)viewDefinition.name);
                    }
                    else if (viewDefinition.appliesTo == null)
                    {
                        DisplayDataQuery.ActiveTracer.WriteLine("NOT MATCH {0}  NAME: {1}  No applicable types", (object)ControlBase.GetControlShapeName(viewDefinition.mainControl), (object)viewDefinition.name);
                    }
                    else
                    {
                        try
                        {
                            TypeMatch.SetTracer(DisplayDataQuery.ActiveTracer);
                            if (match.PerfectMatch(new TypeMatchItem((object)viewDefinition, viewDefinition.appliesTo)))
                            {
                                DisplayDataQuery.TraceHelper(viewDefinition, true);
                                return(viewDefinition);
                            }
                        }
                        finally
                        {
                            TypeMatch.ResetTracer();
                        }
                        DisplayDataQuery.TraceHelper(viewDefinition, false);
                    }
                }
            }
            ViewDefinition viewDefinition1 = DisplayDataQuery.GetBestMatch(match);

            if (viewDefinition1 == null)
            {
                Collection <string> typeNames1 = Deserializer.MaskDeserializationPrefix(typeNames);
                if (typeNames1 != null)
                {
                    viewDefinition1 = DisplayDataQuery.GetDefaultView(expressionFactory, db, typeNames1);
                }
            }
            return(viewDefinition1);
        }
        private EnumerableExpansion GetExpansionState(PSObject so)
        {
            // if the command line swtich has been specified, use this as an override
            if (_parameters != null && _parameters.expansion.HasValue)
            {
                return(_parameters.expansion.Value);
            }

            // check if we have an expansion entry in format.mshxml
            var typeNames = so.InternalTypeNames;

            return(DisplayDataQuery.GetEnumerableExpansionFromType(
                       _expressionFactory, _typeInfoDataBase, typeNames));
        }
示例#6
0
        private int ComputeBestMatch(AppliesTo appliesTo, PSObject currentObject)
        {
            int best = BestMatchIndexUndefined;

            foreach (TypeOrGroupReference r in appliesTo.referenceList)
            {
                PSPropertyExpression ex = null;
                if (r.conditionToken != null)
                {
                    ex = _expressionFactory.CreateFromExpressionToken(r.conditionToken);
                }

                int           currentMatch = BestMatchIndexUndefined;
                TypeReference tr           = r as TypeReference;

                if (tr != null)
                {
                    // we have a type
                    currentMatch = MatchTypeIndex(tr.name, currentObject, ex);
                }
                else
                {
                    // we have a type group reference
                    TypeGroupReference tgr = r as TypeGroupReference;

                    // find the type group definition the reference points to
                    TypeGroupDefinition tgd = DisplayDataQuery.FindGroupDefinition(_db, tgr.name);

                    if (tgd != null)
                    {
                        // we found the group, see if the group has the type
                        currentMatch = ComputeBestMatchInGroup(tgd, currentObject, ex);
                    }
                }

                if (currentMatch == BestMatchIndexPerfect)
                {
                    return(currentMatch);
                }

                if (best == BestMatchIndexUndefined || best < currentMatch)
                {
                    best = currentMatch;
                }
            }

            return(best);
        }
示例#7
0
        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);
        }
        private bool ExecuteFormatControl(TraversalInfo level, ControlBase control, PSObject so, List <FormatValue> formatValueList)
        {
            ComplexControlBody complexBody      = null;
            ControlReference   controlReference = control as ControlReference;

            if ((controlReference != null) && (controlReference.controlType == typeof(ComplexControlBody)))
            {
                complexBody = DisplayDataQuery.ResolveControlReference(this.db, this.controlDefinitionList, controlReference) as ComplexControlBody;
            }
            else
            {
                complexBody = control as ComplexControlBody;
            }
            if (complexBody != null)
            {
                this.ExecuteFormatControlBody(level, so, complexBody, formatValueList);
                return(true);
            }
            return(false);
        }
        internal virtual void Initialize(TerminatingErrorContext terminatingErrorContext,
                                         PSPropertyExpressionFactory mshExpressionFactory,
                                         TypeInfoDataBase db,
                                         ViewDefinition view,
                                         FormattingCommandLineParameters formatParameters)
        {
            Diagnostics.Assert(mshExpressionFactory != null, "mshExpressionFactory cannot be null");
            Diagnostics.Assert(db != null, "db cannot be null");
            Diagnostics.Assert(view != null, "view cannot be null");

            errorContext      = terminatingErrorContext;
            expressionFactory = mshExpressionFactory;
            parameters        = formatParameters;

            dataBaseInfo.db              = db;
            dataBaseInfo.view            = view;
            dataBaseInfo.applicableTypes = DisplayDataQuery.GetAllApplicableTypes(db, view.appliesTo);

            InitializeHelper();
        }
示例#10
0
        internal static EnumerableExpansion GetEnumerableExpansionFromType(
            MshExpressionFactory expressionFactory,
            TypeInfoDataBase db,
            Collection <string> typeNames)
        {
            TypeMatch typeMatch = new TypeMatch(expressionFactory, db, typeNames);

            foreach (EnumerableExpansionDirective expansionDirective in db.defaultSettingsSection.enumerableExpansionDirectiveList)
            {
                if (typeMatch.PerfectMatch(new TypeMatchItem((object)expansionDirective, expansionDirective.appliesTo)))
                {
                    return(expansionDirective.enumerableExpansion);
                }
            }
            if (typeMatch.BestMatch != null)
            {
                return(((EnumerableExpansionDirective)typeMatch.BestMatch).enumerableExpansion);
            }
            Collection <string> typeNames1 = Deserializer.MaskDeserializationPrefix(typeNames);

            return(typeNames1 != null?DisplayDataQuery.GetEnumerableExpansionFromType(expressionFactory, db, typeNames1) : EnumerableExpansion.EnumOnly);
        }
示例#11
0
 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);
 }
示例#12
0
        internal static AppliesTo GetAllApplicableTypes(
            TypeInfoDataBase db,
            AppliesTo appliesTo)
        {
            Hashtable hashtable = new Hashtable((IEqualityComparer)StringComparer.OrdinalIgnoreCase);

            foreach (TypeOrGroupReference reference in appliesTo.referenceList)
            {
                if (reference is TypeReference typeReference)
                {
                    if (!hashtable.ContainsKey((object)typeReference.name))
                    {
                        hashtable.Add((object)typeReference.name, (object)null);
                    }
                }
                else if (reference is TypeGroupReference typeGroupReference)
                {
                    TypeGroupDefinition groupDefinition = DisplayDataQuery.FindGroupDefinition(db, typeGroupReference.name);
                    if (groupDefinition != null)
                    {
                        foreach (TypeReference typeReference in groupDefinition.typeReferenceList)
                        {
                            if (!hashtable.ContainsKey((object)typeReference.name))
                            {
                                hashtable.Add((object)typeReference.name, (object)null);
                            }
                        }
                    }
                }
            }
            AppliesTo appliesTo1 = new AppliesTo();

            foreach (DictionaryEntry dictionaryEntry in hashtable)
            {
                appliesTo1.AddAppliesToType(dictionaryEntry.Key as string);
            }
            return(appliesTo1);
        }
示例#13
0
        internal static FormatShape GetShapeFromType(
            MshExpressionFactory expressionFactory,
            TypeInfoDataBase db,
            Collection <string> typeNames)
        {
            ShapeSelectionDirectives selectionDirectives = db.defaultSettingsSection.shapeSelectionDirectives;
            TypeMatch typeMatch = new TypeMatch(expressionFactory, db, typeNames);

            foreach (FormatShapeSelectionOnType shapeSelectionOnType in selectionDirectives.formatShapeSelectionOnTypeList)
            {
                if (typeMatch.PerfectMatch(new TypeMatchItem((object)shapeSelectionOnType, shapeSelectionOnType.appliesTo)))
                {
                    return(shapeSelectionOnType.formatShape);
                }
            }
            if (typeMatch.BestMatch != null)
            {
                return(((FormatShapeSelectionBase)typeMatch.BestMatch).formatShape);
            }
            Collection <string> typeNames1 = Deserializer.MaskDeserializationPrefix(typeNames);

            return(typeNames1 != null?DisplayDataQuery.GetShapeFromType(expressionFactory, db, typeNames1) : FormatShape.Undefined);
        }
示例#14
0
        private int ComputeBestMatch(AppliesTo appliesTo, PSObject currentObject)
        {
            int num = -1;

            foreach (TypeOrGroupReference reference in appliesTo.referenceList)
            {
                MshExpression ex = null;
                if (reference.conditionToken != null)
                {
                    ex = this._expressionFactory.CreateFromExpressionToken(reference.conditionToken);
                }
                int           num2       = -1;
                TypeReference reference2 = reference as TypeReference;
                if (reference2 != null)
                {
                    num2 = this.MatchTypeIndex(reference2.name, currentObject, ex);
                }
                else
                {
                    TypeGroupReference  reference3 = reference as TypeGroupReference;
                    TypeGroupDefinition tgd        = DisplayDataQuery.FindGroupDefinition(this._db, reference3.name);
                    if (tgd != null)
                    {
                        num2 = this.ComputeBestMatchInGroup(tgd, currentObject, ex);
                    }
                }
                if (num2 == 0)
                {
                    return(num2);
                }
                if ((num == -1) || (num < num2))
                {
                    num = num2;
                }
            }
            return(num);
        }
示例#15
0
        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);
        }
示例#16
0
 internal static ControlBody ResolveControlReference(
     TypeInfoDataBase db,
     List <ControlDefinition> viewControlDefinitionList,
     ControlReference controlReference)
 {
     return(DisplayDataQuery.ResolveControlReferenceInList(controlReference, viewControlDefinitionList) ?? DisplayDataQuery.ResolveControlReferenceInList(controlReference, db.formatControlDefinitionHolder.controlDefinitionList));
 }
示例#17
0
        private static ViewDefinition GetView(
            MshExpressionFactory expressionFactory,
            TypeInfoDataBase db,
            Type mainControlType,
            Collection <string> typeNames,
            string viewName)
        {
            TypeMatch match = new TypeMatch(expressionFactory, db, typeNames);

            foreach (ViewDefinition viewDefinition in db.viewDefinitionsSection.viewDefinitionList)
            {
                if (viewDefinition == null || mainControlType != viewDefinition.mainControl.GetType())
                {
                    DisplayDataQuery.ActiveTracer.WriteLine("NOT MATCH {0}  NAME: {1}", (object)ControlBase.GetControlShapeName(viewDefinition.mainControl), viewDefinition != null ? (object)viewDefinition.name : (object)string.Empty);
                }
                else if (DisplayDataQuery.IsOutOfBandView(viewDefinition))
                {
                    DisplayDataQuery.ActiveTracer.WriteLine("NOT MATCH OutOfBand {0}  NAME: {1}", (object)ControlBase.GetControlShapeName(viewDefinition.mainControl), (object)viewDefinition.name);
                }
                else if (viewDefinition.appliesTo == null)
                {
                    DisplayDataQuery.ActiveTracer.WriteLine("NOT MATCH {0}  NAME: {1}  No applicable types", (object)ControlBase.GetControlShapeName(viewDefinition.mainControl), (object)viewDefinition.name);
                }
                else
                {
                    if (viewName != null)
                    {
                        if (!string.Equals(viewDefinition.name, viewName, StringComparison.OrdinalIgnoreCase))
                        {
                            DisplayDataQuery.ActiveTracer.WriteLine("NOT MATCH {0}  NAME: {1}", (object)ControlBase.GetControlShapeName(viewDefinition.mainControl), (object)viewDefinition.name);
                            continue;
                        }
                    }
                    try
                    {
                        TypeMatch.SetTracer(DisplayDataQuery.ActiveTracer);
                        if (match.PerfectMatch(new TypeMatchItem((object)viewDefinition, viewDefinition.appliesTo)))
                        {
                            DisplayDataQuery.TraceHelper(viewDefinition, true);
                            return(viewDefinition);
                        }
                    }
                    finally
                    {
                        TypeMatch.ResetTracer();
                    }
                    DisplayDataQuery.TraceHelper(viewDefinition, false);
                }
            }
            ViewDefinition viewDefinition1 = DisplayDataQuery.GetBestMatch(match);

            if (viewDefinition1 == null)
            {
                Collection <string> typeNames1 = Deserializer.MaskDeserializationPrefix(typeNames);
                if (typeNames1 != null)
                {
                    viewDefinition1 = DisplayDataQuery.GetView(expressionFactory, db, mainControlType, typeNames1, viewName);
                }
            }
            return(viewDefinition1);
        }
示例#18
0
        internal void Initialize(TerminatingErrorContext errorContext,
                                 MshExpressionFactory expressionFactory,
                                 TypeInfoDataBase db,
                                 PSObject so,
                                 FormatShape shape,
                                 FormattingCommandLineParameters parameters)
        {
            ViewDefinition view              = null;
            const string   findViewType      = "FINDING VIEW TYPE: {0}";
            const string   findViewShapeType = "FINDING VIEW {0} TYPE: {1}";
            const string   findViewNameType  = "FINDING VIEW NAME: {0} TYPE: {1}";
            const string   viewFound         = "An applicable view has been found";
            const string   viewNotFound      = "No applicable view has been found";

            try
            {
                DisplayDataQuery.SetTracer(s_formatViewBindingTracer);

                // shape not specified: we need to select one
                var typeNames = so.InternalTypeNames;
                if (shape == FormatShape.Undefined)
                {
                    using (s_formatViewBindingTracer.TraceScope(findViewType, PSObjectTypeName(so)))
                    {
                        view = DisplayDataQuery.GetViewByShapeAndType(expressionFactory, db, shape, typeNames, null);
                    }
                    if (view != null)
                    {
                        // we got a matching view from the database
                        // use this and we are done
                        _viewGenerator = SelectViewGeneratorFromViewDefinition(
                            errorContext,
                            expressionFactory,
                            db,
                            view,
                            parameters);
                        s_formatViewBindingTracer.WriteLine(viewFound);
                        PrepareViewForRemoteObjects(ViewGenerator, so);
                        return;
                    }

                    s_formatViewBindingTracer.WriteLine(viewNotFound);
                    // we did not get any default view (and shape), we need to force one
                    // we just select properties out of the object itself, since they were not
                    // specified on the command line
                    _viewGenerator = SelectViewGeneratorFromProperties(shape, so, errorContext, expressionFactory, db, null);
                    PrepareViewForRemoteObjects(ViewGenerator, so);

                    return;
                }

                // we have a predefined shape: did the user specify properties on the command line?
                if (parameters != null && parameters.mshParameterList.Count > 0)
                {
                    _viewGenerator = SelectViewGeneratorFromProperties(shape, so, errorContext, expressionFactory, db, parameters);
                    return;
                }

                // predefined shape: did the user specify the name of a view?
                if (parameters != null && !string.IsNullOrEmpty(parameters.viewName))
                {
                    using (s_formatViewBindingTracer.TraceScope(findViewNameType, parameters.viewName,
                                                                PSObjectTypeName(so)))
                    {
                        view = DisplayDataQuery.GetViewByShapeAndType(expressionFactory, db, shape, typeNames, parameters.viewName);
                    }
                    if (view != null)
                    {
                        _viewGenerator = SelectViewGeneratorFromViewDefinition(
                            errorContext,
                            expressionFactory,
                            db,
                            view,
                            parameters);
                        s_formatViewBindingTracer.WriteLine(viewFound);
                        return;
                    }
                    s_formatViewBindingTracer.WriteLine(viewNotFound);
                    // illegal input, we have to terminate
                    ProcessUnknownViewName(errorContext, parameters.viewName, so, db, shape);
                }

                // predefined shape: do we have a default view in format.ps1xml?
                using (s_formatViewBindingTracer.TraceScope(findViewShapeType, shape, PSObjectTypeName(so)))
                {
                    view = DisplayDataQuery.GetViewByShapeAndType(expressionFactory, db, shape, typeNames, null);
                }
                if (view != null)
                {
                    _viewGenerator = SelectViewGeneratorFromViewDefinition(
                        errorContext,
                        expressionFactory,
                        db,
                        view,
                        parameters);
                    s_formatViewBindingTracer.WriteLine(viewFound);
                    PrepareViewForRemoteObjects(ViewGenerator, so);

                    return;
                }
                s_formatViewBindingTracer.WriteLine(viewNotFound);
                // we just select properties out of the object itself
                _viewGenerator = SelectViewGeneratorFromProperties(shape, so, errorContext, expressionFactory, db, parameters);
                PrepareViewForRemoteObjects(ViewGenerator, so);
            }
            finally
            {
                DisplayDataQuery.ResetTracer();
            }
        }
示例#19
0
        internal void Initialize(TerminatingErrorContext errorContext, MshExpressionFactory expressionFactory, TypeInfoDataBase db, PSObject so, FormatShape shape, FormattingCommandLineParameters parameters)
        {
            ViewDefinition view = null;

            try
            {
                DisplayDataQuery.SetTracer(formatViewBindingTracer);
                ConsolidatedString internalTypeNames = so.InternalTypeNames;
                if (shape == FormatShape.Undefined)
                {
                    using (formatViewBindingTracer.TraceScope("FINDING VIEW  TYPE: {0}", new object[] { PSObjectTypeName(so) }))
                    {
                        view = DisplayDataQuery.GetViewByShapeAndType(expressionFactory, db, shape, internalTypeNames, null);
                    }
                    if (view != null)
                    {
                        this.viewGenerator = SelectViewGeneratorFromViewDefinition(errorContext, expressionFactory, db, view, parameters);
                        formatViewBindingTracer.WriteLine("An applicable view has been found", new object[0]);
                        PrepareViewForRemoteObjects(this.ViewGenerator, so);
                    }
                    else
                    {
                        formatViewBindingTracer.WriteLine("No applicable view has been found", new object[0]);
                        this.viewGenerator = SelectViewGeneratorFromProperties(shape, so, errorContext, expressionFactory, db, null);
                        PrepareViewForRemoteObjects(this.ViewGenerator, so);
                    }
                }
                else if ((parameters != null) && (parameters.mshParameterList.Count > 0))
                {
                    this.viewGenerator = SelectViewGeneratorFromProperties(shape, so, errorContext, expressionFactory, db, parameters);
                }
                else
                {
                    if ((parameters != null) && !string.IsNullOrEmpty(parameters.viewName))
                    {
                        using (formatViewBindingTracer.TraceScope("FINDING VIEW NAME: {0}  TYPE: {1}", new object[] { parameters.viewName, PSObjectTypeName(so) }))
                        {
                            view = DisplayDataQuery.GetViewByShapeAndType(expressionFactory, db, shape, internalTypeNames, parameters.viewName);
                        }
                        if (view != null)
                        {
                            this.viewGenerator = SelectViewGeneratorFromViewDefinition(errorContext, expressionFactory, db, view, parameters);
                            formatViewBindingTracer.WriteLine("An applicable view has been found", new object[0]);
                            return;
                        }
                        formatViewBindingTracer.WriteLine("No applicable view has been found", new object[0]);
                        ProcessUnknownViewName(errorContext, parameters.viewName, so, db, shape);
                    }
                    using (formatViewBindingTracer.TraceScope("FINDING VIEW {0} TYPE: {1}", new object[] { shape, PSObjectTypeName(so) }))
                    {
                        view = DisplayDataQuery.GetViewByShapeAndType(expressionFactory, db, shape, internalTypeNames, null);
                    }
                    if (view != null)
                    {
                        this.viewGenerator = SelectViewGeneratorFromViewDefinition(errorContext, expressionFactory, db, view, parameters);
                        formatViewBindingTracer.WriteLine("An applicable view has been found", new object[0]);
                        PrepareViewForRemoteObjects(this.ViewGenerator, so);
                    }
                    else
                    {
                        formatViewBindingTracer.WriteLine("No applicable view has been found", new object[0]);
                        this.viewGenerator = SelectViewGeneratorFromProperties(shape, so, errorContext, expressionFactory, db, parameters);
                        PrepareViewForRemoteObjects(this.ViewGenerator, so);
                    }
                }
            }
            finally
            {
                DisplayDataQuery.ResetTracer();
            }
        }