コード例 #1
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);
            }
        }
コード例 #2
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);
        }
コード例 #3
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);
        }