Ejemplo n.º 1
0
        private static ViewDefinition GetDefaultView(PSPropertyExpressionFactory expressionFactory, TypeInfoDataBase db, Collection <string> typeNames)
        {
            TypeMatch match = new TypeMatch(expressionFactory, db, typeNames);

            foreach (ViewDefinition vd in db.viewDefinitionsSection.viewDefinitionList)
            {
                if (vd == null)
                {
                    continue;
                }

                if (IsOutOfBandView(vd))
                {
                    ActiveTracer.WriteLine(
                        "NOT MATCH OutOfBand {0}  NAME: {1}",
                        ControlBase.GetControlShapeName(vd.mainControl), vd.name);
                    continue;
                }

                if (vd.appliesTo == null)
                {
                    ActiveTracer.WriteLine(
                        "NOT MATCH {0}  NAME: {1}  No applicable types",
                        ControlBase.GetControlShapeName(vd.mainControl), vd.name);
                    continue;
                }

                try
                {
                    TypeMatch.SetTracer(ActiveTracer);
                    if (match.PerfectMatch(new TypeMatchItem(vd, vd.appliesTo)))
                    {
                        TraceHelper(vd, true);
                        return(vd);
                    }
                }
                finally
                {
                    TypeMatch.ResetTracer();
                }

                TraceHelper(vd, false);
            }
            // this is the best match we had
            ViewDefinition result = GetBestMatch(match);

            // we were unable to find a best match so far..try
            // to get rid of Deserialization prefix and see if a
            // match can be found.
            if (result == null)
            {
                Collection <string> typesWithoutPrefix = Deserializer.MaskDeserializationPrefix(typeNames);
                if (typesWithoutPrefix != null)
                {
                    result = GetDefaultView(expressionFactory, db, typesWithoutPrefix);
                }
            }

            return(result);
        }
Ejemplo n.º 2
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 definition in db.viewDefinitionsSection.viewDefinitionList)
            {
                if ((definition == null) || (mainControlType != definition.mainControl.GetType()))
                {
                    ActiveTracer.WriteLine("NOT MATCH {0}  NAME: {1}", new object[] { ControlBase.GetControlShapeName(definition.mainControl), (definition != null) ? definition.name : string.Empty });
                }
                else if (IsOutOfBandView(definition))
                {
                    ActiveTracer.WriteLine("NOT MATCH OutOfBand {0}  NAME: {1}", new object[] { ControlBase.GetControlShapeName(definition.mainControl), definition.name });
                }
                else if (definition.appliesTo == null)
                {
                    ActiveTracer.WriteLine("NOT MATCH {0}  NAME: {1}  No applicable types", new object[] { ControlBase.GetControlShapeName(definition.mainControl), definition.name });
                }
                else if ((viewName != null) && !string.Equals(definition.name, viewName, StringComparison.OrdinalIgnoreCase))
                {
                    ActiveTracer.WriteLine("NOT MATCH {0}  NAME: {1}", new object[] { ControlBase.GetControlShapeName(definition.mainControl), definition.name });
                }
                else
                {
                    try
                    {
                        TypeMatch.SetTracer(ActiveTracer);
                        if (match.PerfectMatch(new TypeMatchItem(definition, definition.appliesTo)))
                        {
                            TraceHelper(definition, true);
                            return(definition);
                        }
                    }
                    finally
                    {
                        TypeMatch.ResetTracer();
                    }
                    TraceHelper(definition, false);
                }
            }
            ViewDefinition bestMatch = GetBestMatch(match);

            if (bestMatch == null)
            {
                Collection <string> collection = Deserializer.MaskDeserializationPrefix(typeNames);
                if (collection != null)
                {
                    bestMatch = GetView(expressionFactory, db, mainControlType, collection, viewName);
                }
            }
            return(bestMatch);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
        private static ViewDefinition GetView(PSPropertyExpressionFactory expressionFactory, TypeInfoDataBase db, System.Type mainControlType, Collection <string> typeNames, string viewName)
        {
            TypeMatch match = new TypeMatch(expressionFactory, db, typeNames);

            foreach (ViewDefinition vd in db.viewDefinitionsSection.viewDefinitionList)
            {
                if (vd == null || mainControlType != vd.mainControl.GetType())
                {
                    ActiveTracer.WriteLine(
                        "NOT MATCH {0}  NAME: {1}",
                        ControlBase.GetControlShapeName(vd.mainControl), (vd != null ? vd.name : string.Empty));
                    continue;
                }
                if (IsOutOfBandView(vd))
                {
                    ActiveTracer.WriteLine(
                        "NOT MATCH OutOfBand {0}  NAME: {1}",
                        ControlBase.GetControlShapeName(vd.mainControl), vd.name);
                    continue;
                }
                if (vd.appliesTo == null)
                {
                    ActiveTracer.WriteLine(
                        "NOT MATCH {0}  NAME: {1}  No applicable types",
                        ControlBase.GetControlShapeName(vd.mainControl), vd.name);
                    continue;
                }
                // first make sure we match on name:
                // if not, we do not try a match at all
                if (viewName != null && !string.Equals(vd.name, viewName, StringComparison.OrdinalIgnoreCase))
                {
                    ActiveTracer.WriteLine(
                        "NOT MATCH {0}  NAME: {1}",
                        ControlBase.GetControlShapeName(vd.mainControl), vd.name);
                    continue;
                }

                // check if we have a perfect match
                // if so, we are done
                try
                {
                    TypeMatch.SetTracer(ActiveTracer);
                    if (match.PerfectMatch(new TypeMatchItem(vd, vd.appliesTo)))
                    {
                        TraceHelper(vd, true);
                        return(vd);
                    }
                }
                finally
                {
                    TypeMatch.ResetTracer();
                }
                TraceHelper(vd, false);
            }

            // this is the best match we had
            ViewDefinition result = GetBestMatch(match);

            // we were unable to find a best match so far..try
            // to get rid of Deserialization prefix and see if a
            // match can be found.
            if (result == null)
            {
                Collection <string> typesWithoutPrefix = Deserializer.MaskDeserializationPrefix(typeNames);
                if (typesWithoutPrefix != null)
                {
                    result = GetView(expressionFactory, db, mainControlType, typesWithoutPrefix, viewName);
                }
            }

            return(result);
        }
Ejemplo n.º 5
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);
        }