예제 #1
0
        internal static ViewDefinition GetViewByShapeAndType(
            MshExpressionFactory expressionFactory,
            TypeInfoDataBase db,
            FormatShape shape,
            Collection <string> typeNames,
            string viewName)
        {
            if (shape == FormatShape.Undefined)
            {
                return(DisplayDataQuery.GetDefaultView(expressionFactory, db, typeNames));
            }
            Type mainControlType;

            if (shape == FormatShape.Table)
            {
                mainControlType = typeof(TableControlBody);
            }
            else if (shape == FormatShape.List)
            {
                mainControlType = typeof(ListControlBody);
            }
            else if (shape == FormatShape.Wide)
            {
                mainControlType = typeof(WideControlBody);
            }
            else
            {
                if (shape != FormatShape.Complex)
                {
                    return((ViewDefinition)null);
                }
                mainControlType = typeof(ComplexControlBody);
            }
            return(DisplayDataQuery.GetView(expressionFactory, db, mainControlType, typeNames, viewName));
        }
예제 #2
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);
        }