Пример #1
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;
 }
Пример #2
0
 private static ViewDefinition GetBestMatch(TypeMatch match)
 {
     ViewDefinition bestMatch = match.BestMatch as ViewDefinition;
     if (bestMatch != null)
     {
         TraceHelper(bestMatch, true);
     }
     return bestMatch;
 }
Пример #3
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;
 }
Пример #4
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;
            }
        }
Пример #5
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;
        }
Пример #6
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;
        }
Пример #7
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;
        }
Пример #8
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;
            }
        }
Пример #9
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;
            }
        }
Пример #10
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;
        }
Пример #11
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;
 }
Пример #12
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;
        }
Пример #13
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;
 }
Пример #14
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;
 }
Пример #15
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;
 }
Пример #16
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;
 }