Ejemplo n.º 1
0
        private ListViewEntry GenerateListViewEntryFromDataBaseInfo(PSObject so, int enumerationLimit)
        {
            ListViewEntry lve = new ListViewEntry();

            ListControlEntryDefinition activeListControlEntryDefinition =
                GetActiveListControlEntryDefinition(_listBody, so);

            foreach (ListControlItemDefinition listItem in activeListControlEntryDefinition.itemDefinitionList)
            {
                if (!EvaluateDisplayCondition(so, listItem.conditionToken))
                {
                    continue;
                }

                ListViewField       lvf = new ListViewField();
                MshExpressionResult result;
                lvf.formatPropertyField = GenerateFormatPropertyField(listItem.formatTokenList, so, enumerationLimit, out result);

                // we need now to provide a label
                if (listItem.label != null)
                {
                    // if the directive provides one, we use it
                    lvf.label = this.dataBaseInfo.db.displayResourceManagerCache.GetTextTokenString(listItem.label);
                }
                else if (result != null)
                {
                    // if we got a valid match from the Mshexpression, use it as a label
                    lvf.label = result.ResolvedExpression.ToString();
                }
                else
                {
                    // we did fail getting a result (i.e. property does not exist on the object)

                    // we try to fall back and see if we have an un-resolved MshExpression
                    FormatToken        token = listItem.formatTokenList[0];
                    FieldPropertyToken fpt   = token as FieldPropertyToken;
                    if (fpt != null)
                    {
                        MshExpression ex = this.expressionFactory.CreateFromExpressionToken(fpt.expression, this.dataBaseInfo.view.loadingInfo);

                        // use the un-resolved MshExpression string as a label
                        lvf.label = ex.ToString();
                    }
                    else
                    {
                        TextToken tt = token as TextToken;
                        if (tt != null)
                        {
                            // we had a text token, use it as a label (last resort...)
                            lvf.label = this.dataBaseInfo.db.displayResourceManagerCache.GetTextTokenString(tt);
                        }
                    }
                }
                lve.listViewFieldList.Add(lvf);
            }
            return(lve);
        }
Ejemplo n.º 2
0
 internal bool IsMatch(MshExpression expression)
 {
     for (int i = 0; i < this._wildcardPatterns.Length; i++)
     {
         if (this._wildcardPatterns[i].IsMatch(expression.ToString()))
         {
             return true;
         }
     }
     return false;
 }