Exemplo n.º 1
0
        internal bool IsObjectApplicable(Collection <string> typeNames)
        {
            if (dataBaseInfo.view is null)
            {
                return(true);
            }

            if (typeNames.Count == 0)
            {
                return(false);
            }

            TypeMatch match = new TypeMatch(expressionFactory, dataBaseInfo.db, typeNames);

            if (match.PerfectMatch(new TypeMatchItem(this, dataBaseInfo.applicableTypes)))
            {
                return(true);
            }

            bool result = match.BestMatch != null;

            // 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 (false == result)
            {
                Collection <string> typesWithoutPrefix = Deserializer.MaskDeserializationPrefix(typeNames);
                if (typesWithoutPrefix != null)
                {
                    result = IsObjectApplicable(typesWithoutPrefix);
                }
            }

            return(result);
        }
Exemplo n.º 2
0
        private ListControlEntryDefinition GetActiveListControlEntryDefinition(ListControlBody listBody, PSObject so)
        {
            ConsolidatedString internalTypeNames = so.InternalTypeNames;
            TypeMatch          match             = new TypeMatch(base.expressionFactory, base.dataBaseInfo.db, internalTypeNames);

            foreach (ListControlEntryDefinition definition in listBody.optionalEntryList)
            {
                if (match.PerfectMatch(new TypeMatchItem(definition, definition.appliesTo, so)))
                {
                    return(definition);
                }
            }
            if (match.BestMatch != null)
            {
                return(match.BestMatch as ListControlEntryDefinition);
            }
            Collection <string> typeNames = Deserializer.MaskDeserializationPrefix(internalTypeNames);

            if (typeNames != null)
            {
                match = new TypeMatch(base.expressionFactory, base.dataBaseInfo.db, typeNames);
                foreach (ListControlEntryDefinition definition2 in listBody.optionalEntryList)
                {
                    if (match.PerfectMatch(new TypeMatchItem(definition2, definition2.appliesTo)))
                    {
                        return(definition2);
                    }
                }
                if (match.BestMatch != null)
                {
                    return(match.BestMatch as ListControlEntryDefinition);
                }
            }
            return(listBody.defaultEntryDefinition);
        }
Exemplo n.º 3
0
        internal static ViewDefinition GetOutOfBandView(PSPropertyExpressionFactory expressionFactory,
                                                        TypeInfoDataBase db, Collection <string> typeNames)
        {
            TypeMatch match = new TypeMatch(expressionFactory, db, typeNames);

            foreach (ViewDefinition vd in db.viewDefinitionsSection.viewDefinitionList)
            {
                if (!IsOutOfBandView(vd))
                {
                    continue;
                }
                if (match.PerfectMatch(new TypeMatchItem(vd, vd.appliesTo)))
                {
                    return(vd);
                }
            }

            // this is the best match we had
            ViewDefinition result = match.BestMatch as ViewDefinition;

            // 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 = GetOutOfBandView(expressionFactory, db, typesWithoutPrefix);
                }
            }

            return(result);
        }
Exemplo n.º 4
0
        internal static FormatShape GetShapeFromType(PSPropertyExpressionFactory expressionFactory, TypeInfoDataBase db, Collection <string> typeNames)
        {
            ShapeSelectionDirectives shapeDirectives = db.defaultSettingsSection.shapeSelectionDirectives;

            TypeMatch match = new TypeMatch(expressionFactory, db, typeNames);

            foreach (FormatShapeSelectionOnType shapeSelOnType in shapeDirectives.formatShapeSelectionOnTypeList)
            {
                if (match.PerfectMatch(new TypeMatchItem(shapeSelOnType, shapeSelOnType.appliesTo)))
                {
                    return(shapeSelOnType.formatShape);
                }
            }
            if (match.BestMatch != null)
            {
                return(((FormatShapeSelectionOnType)(match.BestMatch)).formatShape);
            }
            else
            {
                Collection <string> typesWithoutPrefix = Deserializer.MaskDeserializationPrefix(typeNames);
                if (typesWithoutPrefix != null)
                {
                    FormatShape result = GetShapeFromType(expressionFactory, db, typesWithoutPrefix);
                    return(result);
                }

                // return a default value if no matches were found
                return(FormatShape.Undefined);
            }
        }
Exemplo n.º 5
0
 private WideControlEntryDefinition GetActiveWideControlEntryDefinition(WideControlBody wideBody, PSObject so)
 {
     ConsolidatedString internalTypeNames = so.InternalTypeNames;
     TypeMatch match = new TypeMatch(base.expressionFactory, base.dataBaseInfo.db, internalTypeNames);
     foreach (WideControlEntryDefinition definition in wideBody.optionalEntryList)
     {
         if (match.PerfectMatch(new TypeMatchItem(definition, definition.appliesTo)))
         {
             return definition;
         }
     }
     if (match.BestMatch != null)
     {
         return (match.BestMatch as WideControlEntryDefinition);
     }
     Collection<string> typeNames = Deserializer.MaskDeserializationPrefix(internalTypeNames);
     if (typeNames != null)
     {
         match = new TypeMatch(base.expressionFactory, base.dataBaseInfo.db, typeNames);
         foreach (WideControlEntryDefinition definition2 in wideBody.optionalEntryList)
         {
             if (match.PerfectMatch(new TypeMatchItem(definition2, definition2.appliesTo)))
             {
                 return definition2;
             }
         }
         if (match.BestMatch != null)
         {
             return (match.BestMatch as WideControlEntryDefinition);
         }
     }
     return wideBody.defaultEntryDefinition;
 }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
0
        private ComplexControlEntryDefinition GetActiveComplexControlEntryDefinition(ComplexControlBody complexBody, PSObject so)
        {
            ConsolidatedString internalTypeNames = so.InternalTypeNames;
            TypeMatch          match             = new TypeMatch(this.expressionFactory, this.db, internalTypeNames);

            foreach (ComplexControlEntryDefinition definition in complexBody.optionalEntryList)
            {
                if (match.PerfectMatch(new TypeMatchItem(definition, definition.appliesTo)))
                {
                    return(definition);
                }
            }
            if (match.BestMatch != null)
            {
                return(match.BestMatch as ComplexControlEntryDefinition);
            }
            Collection <string> typeNames = Deserializer.MaskDeserializationPrefix(internalTypeNames);

            if (typeNames != null)
            {
                match = new TypeMatch(this.expressionFactory, this.db, typeNames);
                foreach (ComplexControlEntryDefinition definition2 in complexBody.optionalEntryList)
                {
                    if (match.PerfectMatch(new TypeMatchItem(definition2, definition2.appliesTo)))
                    {
                        return(definition2);
                    }
                }
                if (match.BestMatch != null)
                {
                    return(match.BestMatch as ComplexControlEntryDefinition);
                }
            }
            return(complexBody.defaultEntry);
        }
Exemplo n.º 8
0
        internal bool IsObjectApplicable(Collection <string> typeNames)
        {
            if (this.dataBaseInfo.view == null)
            {
                return(true);
            }
            if (typeNames.Count == 0)
            {
                return(false);
            }
            TypeMatch match = new TypeMatch(this.expressionFactory, this.dataBaseInfo.db, typeNames);

            if (match.PerfectMatch(new TypeMatchItem(this, this.dataBaseInfo.applicableTypes)))
            {
                return(true);
            }
            bool flag = match.BestMatch != null;

            if (!flag)
            {
                Collection <string> collection = Deserializer.MaskDeserializationPrefix(typeNames);
                if (collection != null)
                {
                    flag = this.IsObjectApplicable(collection);
                }
            }
            return(flag);
        }
Exemplo n.º 9
0
        internal static EnumerableExpansion GetEnumerableExpansionFromType(PSPropertyExpressionFactory expressionFactory, TypeInfoDataBase db, Collection <string> typeNames)
        {
            TypeMatch match = new TypeMatch(expressionFactory, db, typeNames);

            foreach (EnumerableExpansionDirective expansionDirective in db.defaultSettingsSection.enumerableExpansionDirectiveList)
            {
                if (match.PerfectMatch(new TypeMatchItem(expansionDirective, expansionDirective.appliesTo)))
                {
                    return(expansionDirective.enumerableExpansion);
                }
            }
            if (match.BestMatch != null)
            {
                return(((EnumerableExpansionDirective)(match.BestMatch)).enumerableExpansion);
            }
            else
            {
                Collection <string> typesWithoutPrefix = Deserializer.MaskDeserializationPrefix(typeNames);
                if (typesWithoutPrefix != null)
                {
                    EnumerableExpansion result = GetEnumerableExpansionFromType(expressionFactory, db, typesWithoutPrefix);
                    return(result);
                }

                // return a default value if no matches were found
                return(EnumerableExpansion.EnumOnly);
            }
        }
Exemplo n.º 10
0
 private static ViewDefinition GetBestMatch(TypeMatch match)
 {
     if (match.BestMatch is ViewDefinition bestMatch)
     {
         DisplayDataQuery.TraceHelper(bestMatch, true);
     }
     return(bestMatch);
 }
Exemplo n.º 11
0
 private static ViewDefinition GetBestMatch(TypeMatch match)
 {
     ViewDefinition bestMatch = match.BestMatch as ViewDefinition;
     if (bestMatch != null)
     {
         TraceHelper(bestMatch, true);
     }
     return bestMatch;
 }
Exemplo n.º 12
0
        private static ViewDefinition GetBestMatch(TypeMatch match)
        {
            ViewDefinition bestMatchedVD = match.BestMatch as ViewDefinition;

            if (bestMatchedVD != null)
            {
                TraceHelper(bestMatchedVD, true);
            }
            return(bestMatchedVD);
        }
Exemplo n.º 13
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);
        }
Exemplo n.º 14
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);
        }
Exemplo n.º 15
0
 private static ViewDefinition GetDefaultView(MshExpressionFactory expressionFactory, TypeInfoDataBase db, Collection<string> typeNames)
 {
     TypeMatch match = new TypeMatch(expressionFactory, db, typeNames);
     foreach (ViewDefinition definition in db.viewDefinitionsSection.viewDefinitionList)
     {
         if (definition != null)
         {
             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
             {
                 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 = GetDefaultView(expressionFactory, db, collection);
         }
     }
     return bestMatch;
 }
Exemplo n.º 16
0
        private WideControlEntryDefinition GetActiveWideControlEntryDefinition(WideControlBody wideBody, PSObject so)
        {
            // see if we have an override that matches
            var       typeNames = so.InternalTypeNames;
            TypeMatch match     = new TypeMatch(expressionFactory, this.dataBaseInfo.db, typeNames);

            foreach (WideControlEntryDefinition x in wideBody.optionalEntryList)
            {
                if (match.PerfectMatch(new TypeMatchItem(x, x.appliesTo)))
                {
                    return(x);
                }
            }

            if (match.BestMatch != null)
            {
                return(match.BestMatch as WideControlEntryDefinition);
            }
            else
            {
                Collection <string> typesWithoutPrefix = Deserializer.MaskDeserializationPrefix(typeNames);
                if (typesWithoutPrefix != null)
                {
                    match = new TypeMatch(expressionFactory, this.dataBaseInfo.db, typesWithoutPrefix);
                    foreach (WideControlEntryDefinition x in wideBody.optionalEntryList)
                    {
                        if (match.PerfectMatch(new TypeMatchItem(x, x.appliesTo)))
                        {
                            return(x);
                        }
                    }

                    if (match.BestMatch != null)
                    {
                        return(match.BestMatch as WideControlEntryDefinition);
                    }
                }

                // we do not have any override, use default
                return(wideBody.defaultEntryDefinition);
            }
        }
        private ComplexControlEntryDefinition GetActiveComplexControlEntryDefinition(ComplexControlBody complexBody, PSObject so)
        {
            // see if we have an override that matches
            var typeNames = so.InternalTypeNames;
            TypeMatch match = new TypeMatch(_expressionFactory, _db, typeNames);
            foreach (ComplexControlEntryDefinition x in complexBody.optionalEntryList)
            {
                if (match.PerfectMatch(new TypeMatchItem(x, x.appliesTo, so)))
                {
                    return x;
                }
            }

            if (match.BestMatch != null)
            {
                return match.BestMatch as ComplexControlEntryDefinition;
            }
            else
            {
                Collection<string> typesWithoutPrefix = Deserializer.MaskDeserializationPrefix(typeNames);
                if (typesWithoutPrefix != null)
                {
                    match = new TypeMatch(_expressionFactory, _db, typesWithoutPrefix);
                    foreach (ComplexControlEntryDefinition x in complexBody.optionalEntryList)
                    {
                        if (match.PerfectMatch(new TypeMatchItem(x, x.appliesTo)))
                        {
                            return x;
                        }
                    }

                    if (match.BestMatch != null)
                    {
                        return match.BestMatch as ComplexControlEntryDefinition;
                    }
                }

                // we do not have any override, use default
                return complexBody.defaultEntry;
            }
        }
Exemplo n.º 18
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);
        }
Exemplo n.º 19
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);
        }
Exemplo n.º 20
0
        internal static EnumerableExpansion GetEnumerableExpansionFromType(MshExpressionFactory expressionFactory, TypeInfoDataBase db, Collection <string> typeNames)
        {
            TypeMatch match = new TypeMatch(expressionFactory, db, typeNames);

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

            if (collection != null)
            {
                return(GetEnumerableExpansionFromType(expressionFactory, db, collection));
            }
            return(EnumerableExpansion.EnumOnly);
        }
Exemplo n.º 21
0
        internal static ViewDefinition GetOutOfBandView(MshExpressionFactory expressionFactory, TypeInfoDataBase db, Collection <string> typeNames)
        {
            TypeMatch match = new TypeMatch(expressionFactory, db, typeNames);

            foreach (ViewDefinition definition in db.viewDefinitionsSection.viewDefinitionList)
            {
                if (IsOutOfBandView(definition) && match.PerfectMatch(new TypeMatchItem(definition, definition.appliesTo)))
                {
                    return(definition);
                }
            }
            ViewDefinition bestMatch = match.BestMatch as ViewDefinition;

            if (bestMatch == null)
            {
                Collection <string> collection = Deserializer.MaskDeserializationPrefix(typeNames);
                if (collection != null)
                {
                    bestMatch = GetOutOfBandView(expressionFactory, db, collection);
                }
            }
            return(bestMatch);
        }
Exemplo n.º 22
0
        internal static FormatShape GetShapeFromType(MshExpressionFactory expressionFactory, TypeInfoDataBase db, Collection <string> typeNames)
        {
            ShapeSelectionDirectives shapeSelectionDirectives = db.defaultSettingsSection.shapeSelectionDirectives;
            TypeMatch match = new TypeMatch(expressionFactory, db, typeNames);

            foreach (FormatShapeSelectionOnType type in shapeSelectionDirectives.formatShapeSelectionOnTypeList)
            {
                if (match.PerfectMatch(new TypeMatchItem(type, type.appliesTo)))
                {
                    return(type.formatShape);
                }
            }
            if (match.BestMatch != null)
            {
                return(((FormatShapeSelectionOnType)match.BestMatch).formatShape);
            }
            Collection <string> collection = Deserializer.MaskDeserializationPrefix(typeNames);

            if (collection != null)
            {
                return(GetShapeFromType(expressionFactory, db, collection));
            }
            return(FormatShape.Undefined);
        }
Exemplo n.º 23
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);
        }
Exemplo n.º 24
0
 internal static ViewDefinition GetOutOfBandView(MshExpressionFactory expressionFactory, TypeInfoDataBase db, Collection<string> typeNames)
 {
     TypeMatch match = new TypeMatch(expressionFactory, db, typeNames);
     foreach (ViewDefinition definition in db.viewDefinitionsSection.viewDefinitionList)
     {
         if (IsOutOfBandView(definition) && match.PerfectMatch(new TypeMatchItem(definition, definition.appliesTo)))
         {
             return definition;
         }
     }
     ViewDefinition bestMatch = match.BestMatch as ViewDefinition;
     if (bestMatch == null)
     {
         Collection<string> collection = Deserializer.MaskDeserializationPrefix(typeNames);
         if (collection != null)
         {
             bestMatch = GetOutOfBandView(expressionFactory, db, collection);
         }
     }
     return bestMatch;
 }
Exemplo n.º 25
0
 internal static FormatShape GetShapeFromType(MshExpressionFactory expressionFactory, TypeInfoDataBase db, Collection<string> typeNames)
 {
     ShapeSelectionDirectives shapeSelectionDirectives = db.defaultSettingsSection.shapeSelectionDirectives;
     TypeMatch match = new TypeMatch(expressionFactory, db, typeNames);
     foreach (FormatShapeSelectionOnType type in shapeSelectionDirectives.formatShapeSelectionOnTypeList)
     {
         if (match.PerfectMatch(new TypeMatchItem(type, type.appliesTo)))
         {
             return type.formatShape;
         }
     }
     if (match.BestMatch != null)
     {
         return ((FormatShapeSelectionOnType) match.BestMatch).formatShape;
     }
     Collection<string> collection = Deserializer.MaskDeserializationPrefix(typeNames);
     if (collection != null)
     {
         return GetShapeFromType(expressionFactory, db, collection);
     }
     return FormatShape.Undefined;
 }
Exemplo n.º 26
0
 private List<TableRowItemDefinition> GetActiveTableRowDefinition(TableControlBody tableBody, PSObject so)
 {
     if (tableBody.optionalDefinitionList.Count == 0)
     {
         return tableBody.defaultDefinition.rowItemDefinitionList;
     }
     TableRowDefinition bestMatch = null;
     ConsolidatedString internalTypeNames = so.InternalTypeNames;
     TypeMatch match = new TypeMatch(this.expressionFactory, this.typeInfoDatabase, internalTypeNames);
     foreach (TableRowDefinition definition2 in tableBody.optionalDefinitionList)
     {
         if (match.PerfectMatch(new TypeMatchItem(definition2, definition2.appliesTo)))
         {
             bestMatch = definition2;
             break;
         }
     }
     if (bestMatch == null)
     {
         bestMatch = match.BestMatch as TableRowDefinition;
     }
     if (bestMatch == null)
     {
         Collection<string> typeNames = Deserializer.MaskDeserializationPrefix(internalTypeNames);
         if (typeNames != null)
         {
             match = new TypeMatch(this.expressionFactory, this.typeInfoDatabase, typeNames);
             foreach (TableRowDefinition definition3 in tableBody.optionalDefinitionList)
             {
                 if (match.PerfectMatch(new TypeMatchItem(definition3, definition3.appliesTo)))
                 {
                     bestMatch = definition3;
                     break;
                 }
             }
             if (bestMatch == null)
             {
                 bestMatch = match.BestMatch as TableRowDefinition;
             }
         }
     }
     if (bestMatch == null)
     {
         return tableBody.defaultDefinition.rowItemDefinitionList;
     }
     List<TableRowItemDefinition> list = new List<TableRowItemDefinition>();
     int num = 0;
     foreach (TableRowItemDefinition definition4 in bestMatch.rowItemDefinitionList)
     {
         if (definition4.formatTokenList.Count == 0)
         {
             list.Add(tableBody.defaultDefinition.rowItemDefinitionList[num]);
         }
         else
         {
             list.Add(definition4);
         }
         num++;
     }
     return list;
 }
Exemplo n.º 27
0
        private List <TableRowItemDefinition> GetActiveTableRowDefinition(TableControlBody tableBody, PSObject so, out bool multiLine)
        {
            multiLine = tableBody.defaultDefinition.multiLine;
            if (tableBody.optionalDefinitionList.Count == 0)
            {
                return(tableBody.defaultDefinition.rowItemDefinitionList);
            }
            TableRowDefinition bestMatch         = null;
            ConsolidatedString internalTypeNames = so.InternalTypeNames;
            TypeMatch          match             = new TypeMatch(base.expressionFactory, base.dataBaseInfo.db, internalTypeNames);

            foreach (TableRowDefinition definition2 in tableBody.optionalDefinitionList)
            {
                if (match.PerfectMatch(new TypeMatchItem(definition2, definition2.appliesTo)))
                {
                    bestMatch = definition2;
                    break;
                }
            }
            if (bestMatch == null)
            {
                bestMatch = match.BestMatch as TableRowDefinition;
            }
            if (bestMatch == null)
            {
                Collection <string> typeNames = Deserializer.MaskDeserializationPrefix(internalTypeNames);
                if (typeNames != null)
                {
                    match = new TypeMatch(base.expressionFactory, base.dataBaseInfo.db, typeNames);
                    foreach (TableRowDefinition definition3 in tableBody.optionalDefinitionList)
                    {
                        if (match.PerfectMatch(new TypeMatchItem(definition3, definition3.appliesTo)))
                        {
                            bestMatch = definition3;
                            break;
                        }
                    }
                    if (bestMatch == null)
                    {
                        bestMatch = match.BestMatch as TableRowDefinition;
                    }
                }
            }
            if (bestMatch == null)
            {
                return(tableBody.defaultDefinition.rowItemDefinitionList);
            }
            if (bestMatch.multiLine)
            {
                multiLine = bestMatch.multiLine;
            }
            List <TableRowItemDefinition> list = new List <TableRowItemDefinition>();
            int num = 0;

            foreach (TableRowItemDefinition definition4 in bestMatch.rowItemDefinitionList)
            {
                if (definition4.formatTokenList.Count == 0)
                {
                    list.Add(tableBody.defaultDefinition.rowItemDefinitionList[num]);
                }
                else
                {
                    list.Add(definition4);
                }
                num++;
            }
            return(list);
        }
Exemplo n.º 28
0
        private List<TableRowItemDefinition> GetActiveTableRowDefinition(TableControlBody tableBody, PSObject so,
                                                out bool multiLine)
        {
            multiLine = tableBody.defaultDefinition.multiLine;
            if (tableBody.optionalDefinitionList.Count == 0)
            {
                // we do not have any override, use default
                return tableBody.defaultDefinition.rowItemDefinitionList;
            }

            // see if we have an override that matches
            TableRowDefinition matchingRowDefinition = null;

            var typeNames = so.InternalTypeNames;
            TypeMatch match = new TypeMatch(expressionFactory, this.dataBaseInfo.db, typeNames);

            foreach (TableRowDefinition x in tableBody.optionalDefinitionList)
            {
                if (match.PerfectMatch(new TypeMatchItem(x, x.appliesTo)))
                {
                    matchingRowDefinition = x;
                    break;
                }
            }
            if (matchingRowDefinition == null)
            {
                matchingRowDefinition = match.BestMatch as TableRowDefinition;
            }

            if (matchingRowDefinition == null)
            {
                Collection<string> typesWithoutPrefix = Deserializer.MaskDeserializationPrefix(typeNames);
                if (null != typesWithoutPrefix)
                {
                    match = new TypeMatch(expressionFactory, this.dataBaseInfo.db, typesWithoutPrefix);

                    foreach (TableRowDefinition x in tableBody.optionalDefinitionList)
                    {
                        if (match.PerfectMatch(new TypeMatchItem(x, x.appliesTo)))
                        {
                            matchingRowDefinition = x;
                            break;
                        }
                    }
                    if (matchingRowDefinition == null)
                    {
                        matchingRowDefinition = match.BestMatch as TableRowDefinition;
                    }
                }
            }

            if (matchingRowDefinition == null)
            {
                // no matching override, use default
                return tableBody.defaultDefinition.rowItemDefinitionList;
            }

            // the overriding row definition takes the precedence
            if (matchingRowDefinition.multiLine)
                multiLine = matchingRowDefinition.multiLine;

            // we have an override, we need to compute the merge of the active cells
            List<TableRowItemDefinition> activeRowItemDefinitionList = new List<TableRowItemDefinition>();
            int col = 0;
            foreach (TableRowItemDefinition rowItem in matchingRowDefinition.rowItemDefinitionList)
            {
                // check if the row is an override or not
                if (rowItem.formatTokenList.Count == 0)
                {
                    // it's a place holder, use the default
                    activeRowItemDefinitionList.Add(tableBody.defaultDefinition.rowItemDefinitionList[col]);
                }
                else
                {
                    // use the override
                    activeRowItemDefinitionList.Add(rowItem);
                }
                col++;
            }

            return activeRowItemDefinitionList;
        }
Exemplo n.º 29
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);
        }
Exemplo n.º 30
0
        internal static ViewDefinition GetOutOfBandView(MshExpressionFactory expressionFactory,
                                                        TypeInfoDataBase db, Collection<string> typeNames)
        {
            TypeMatch match = new TypeMatch(expressionFactory, db, typeNames);
            foreach (ViewDefinition vd in db.viewDefinitionsSection.viewDefinitionList)
            {
                if (!IsOutOfBandView(vd))
                    continue;
                if (match.PerfectMatch(new TypeMatchItem(vd, vd.appliesTo)))
                {
                    return vd;
                }
            }

            // this is the best match we had
            ViewDefinition result = match.BestMatch as ViewDefinition;
            // 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 (null == result)
            {
                Collection<string> typesWithoutPrefix = Deserializer.MaskDeserializationPrefix(typeNames);
                if (null != typesWithoutPrefix)
                {
                    result = GetOutOfBandView(expressionFactory, db, typesWithoutPrefix);
                }
            }

            return result;
        }
Exemplo n.º 31
0
        internal static FormatShape GetShapeFromType(MshExpressionFactory expressionFactory, TypeInfoDataBase db, Collection<string> typeNames)
        {
            ShapeSelectionDirectives shapeDirectives = db.defaultSettingsSection.shapeSelectionDirectives;

            TypeMatch match = new TypeMatch(expressionFactory, db, typeNames);
            foreach (FormatShapeSelectionOnType shapeSelOnType in shapeDirectives.formatShapeSelectionOnTypeList)
            {
                if (match.PerfectMatch(new TypeMatchItem(shapeSelOnType, shapeSelOnType.appliesTo)))
                {
                    return shapeSelOnType.formatShape;
                }
            }
            if (match.BestMatch != null)
            {
                return ((FormatShapeSelectionOnType)(match.BestMatch)).formatShape;
            }
            else
            {
                Collection<string> typesWithoutPrefix = Deserializer.MaskDeserializationPrefix(typeNames);
                if (null != typesWithoutPrefix)
                {
                    FormatShape result = GetShapeFromType(expressionFactory, db, typesWithoutPrefix);
                    return result;
                }

                // return a default value if no matches were found
                return FormatShape.Undefined;
            }
        }
Exemplo n.º 32
0
        internal static EnumerableExpansion GetEnumerableExpansionFromType(MshExpressionFactory expressionFactory, TypeInfoDataBase db, Collection<string> typeNames)
        {
            TypeMatch match = new TypeMatch(expressionFactory, db, typeNames);
            foreach (EnumerableExpansionDirective expansionDirective in db.defaultSettingsSection.enumerableExpansionDirectiveList)
            {
                if (match.PerfectMatch(new TypeMatchItem(expansionDirective, expansionDirective.appliesTo)))
                {
                    return expansionDirective.enumerableExpansion;
                }
            }
            if (match.BestMatch != null)
            {
                return ((EnumerableExpansionDirective)(match.BestMatch)).enumerableExpansion;
            }
            else
            {
                Collection<string> typesWithoutPrefix = Deserializer.MaskDeserializationPrefix(typeNames);
                if (null != typesWithoutPrefix)
                {
                    EnumerableExpansion result = GetEnumerableExpansionFromType(expressionFactory, db, typesWithoutPrefix);
                    return result;
                }

                // return a default value if no matches were found
                return EnumerableExpansion.EnumOnly;
            }
        }
        private List <TableRowItemDefinition> GetActiveTableRowDefinition(TableControlBody tableBody, PSObject so,
                                                                          out bool multiLine)
        {
            multiLine = tableBody.defaultDefinition.multiLine;
            if (tableBody.optionalDefinitionList.Count == 0)
            {
                // we do not have any override, use default
                return(tableBody.defaultDefinition.rowItemDefinitionList);
            }

            // see if we have an override that matches
            TableRowDefinition matchingRowDefinition = null;

            var       typeNames = so.InternalTypeNames;
            TypeMatch match     = new TypeMatch(expressionFactory, this.dataBaseInfo.db, typeNames);

            foreach (TableRowDefinition x in tableBody.optionalDefinitionList)
            {
                if (match.PerfectMatch(new TypeMatchItem(x, x.appliesTo)))
                {
                    matchingRowDefinition = x;
                    break;
                }
            }

            if (matchingRowDefinition == null)
            {
                matchingRowDefinition = match.BestMatch as TableRowDefinition;
            }

            if (matchingRowDefinition == null)
            {
                Collection <string> typesWithoutPrefix = Deserializer.MaskDeserializationPrefix(typeNames);
                if (typesWithoutPrefix != null)
                {
                    match = new TypeMatch(expressionFactory, this.dataBaseInfo.db, typesWithoutPrefix);

                    foreach (TableRowDefinition x in tableBody.optionalDefinitionList)
                    {
                        if (match.PerfectMatch(new TypeMatchItem(x, x.appliesTo)))
                        {
                            matchingRowDefinition = x;
                            break;
                        }
                    }

                    if (matchingRowDefinition == null)
                    {
                        matchingRowDefinition = match.BestMatch as TableRowDefinition;
                    }
                }
            }

            if (matchingRowDefinition == null)
            {
                // no matching override, use default
                return(tableBody.defaultDefinition.rowItemDefinitionList);
            }

            // the overriding row definition takes the precedence
            if (matchingRowDefinition.multiLine)
            {
                multiLine = matchingRowDefinition.multiLine;
            }

            // we have an override, we need to compute the merge of the active cells
            List <TableRowItemDefinition> activeRowItemDefinitionList = new List <TableRowItemDefinition>();
            int col = 0;

            foreach (TableRowItemDefinition rowItem in matchingRowDefinition.rowItemDefinitionList)
            {
                // check if the row is an override or not
                if (rowItem.formatTokenList.Count == 0)
                {
                    // it's a place holder, use the default
                    activeRowItemDefinitionList.Add(tableBody.defaultDefinition.rowItemDefinitionList[col]);
                }
                else
                {
                    // use the override
                    activeRowItemDefinitionList.Add(rowItem);
                }

                col++;
            }

            return(activeRowItemDefinitionList);
        }
Exemplo n.º 34
0
        internal bool IsObjectApplicable(Collection<string> typeNames)
        {
            if (dataBaseInfo.view == null)
                return true;

            if (typeNames.Count == 0)
                return false;

            TypeMatch match = new TypeMatch(expressionFactory, dataBaseInfo.db, typeNames);
            if (match.PerfectMatch(new TypeMatchItem(this, dataBaseInfo.applicableTypes)))
            {
                return true;
            }

            bool result = match.BestMatch != null;

            // 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 (false == result)
            {
                Collection<string> typesWithoutPrefix = Deserializer.MaskDeserializationPrefix(typeNames);
                if (null != typesWithoutPrefix)
                {
                    result = IsObjectApplicable(typesWithoutPrefix);
                }
            }
            return result;
        }
Exemplo n.º 35
0
 internal bool IsObjectApplicable(Collection<string> typeNames)
 {
     if (this.dataBaseInfo.view == null)
     {
         return true;
     }
     if (typeNames.Count == 0)
     {
         return false;
     }
     TypeMatch match = new TypeMatch(this.expressionFactory, this.dataBaseInfo.db, typeNames);
     if (match.PerfectMatch(new TypeMatchItem(this, this.dataBaseInfo.applicableTypes)))
     {
         return true;
     }
     bool flag = match.BestMatch != null;
     if (!flag)
     {
         Collection<string> collection = Deserializer.MaskDeserializationPrefix(typeNames);
         if (collection != null)
         {
             flag = this.IsObjectApplicable(collection);
         }
     }
     return flag;
 }
Exemplo n.º 36
0
 internal static EnumerableExpansion GetEnumerableExpansionFromType(MshExpressionFactory expressionFactory, TypeInfoDataBase db, Collection<string> typeNames)
 {
     TypeMatch match = new TypeMatch(expressionFactory, db, typeNames);
     foreach (EnumerableExpansionDirective directive in db.defaultSettingsSection.enumerableExpansionDirectiveList)
     {
         if (match.PerfectMatch(new TypeMatchItem(directive, directive.appliesTo)))
         {
             return directive.enumerableExpansion;
         }
     }
     if (match.BestMatch != null)
     {
         return ((EnumerableExpansionDirective) match.BestMatch).enumerableExpansion;
     }
     Collection<string> collection = Deserializer.MaskDeserializationPrefix(typeNames);
     if (collection != null)
     {
         return GetEnumerableExpansionFromType(expressionFactory, db, collection);
     }
     return EnumerableExpansion.EnumOnly;
 }
Exemplo n.º 37
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);
        }
Exemplo n.º 38
0
        private static ViewDefinition GetView(MshExpressionFactory 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), (null != vd ? 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 (null == result)
            {
                Collection<string> typesWithoutPrefix = Deserializer.MaskDeserializationPrefix(typeNames);
                if (null != typesWithoutPrefix)
                {
                    result = GetView(expressionFactory, db, mainControlType, typesWithoutPrefix, viewName);
                }
            }

            return result;
        }
Exemplo n.º 39
0
        private WideControlEntryDefinition GetActiveWideControlEntryDefinition(WideControlBody wideBody, PSObject so)
        {
            // see if we have an override that matches
            var typeNames = so.InternalTypeNames;
            TypeMatch match = new TypeMatch(expressionFactory, this.dataBaseInfo.db, typeNames);
            foreach (WideControlEntryDefinition x in wideBody.optionalEntryList)
            {
                if (match.PerfectMatch(new TypeMatchItem(x, x.appliesTo)))
                {
                    return x;
                }
            }
            if (match.BestMatch != null)
            {
                return match.BestMatch as WideControlEntryDefinition;
            }
            else
            {
                Collection<string> typesWithoutPrefix = Deserializer.MaskDeserializationPrefix(typeNames);
                if (null != typesWithoutPrefix)
                {
                    match = new TypeMatch(expressionFactory, this.dataBaseInfo.db, typesWithoutPrefix);
                    foreach (WideControlEntryDefinition x in wideBody.optionalEntryList)
                    {
                        if (match.PerfectMatch(new TypeMatchItem(x, x.appliesTo)))
                        {
                            return x;
                        }
                    }
                    if (match.BestMatch != null)
                    {
                        return match.BestMatch as WideControlEntryDefinition;
                    }
                }

                // we do not have any override, use default
                return wideBody.defaultEntryDefinition;
            }
        }
Exemplo n.º 40
0
        private static ViewDefinition GetDefaultView(MshExpressionFactory 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 (null == result)
            {
                Collection<string> typesWithoutPrefix = Deserializer.MaskDeserializationPrefix(typeNames);
                if (null != typesWithoutPrefix)
                {
                    result = GetDefaultView(expressionFactory, db, typesWithoutPrefix);
                }
            }

            return result;
        }