Пример #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();
                PSPropertyExpressionResult 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 PSPropertyExpression
                    FormatToken        token = listItem.formatTokenList[0];
                    FieldPropertyToken fpt   = token as FieldPropertyToken;
                    if (fpt != null)
                    {
                        PSPropertyExpression ex = this.expressionFactory.CreateFromExpressionToken(fpt.expression, this.dataBaseInfo.view.loadingInfo);

                        // use the un-resolved PSPropertyExpression 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);
        }
Пример #2
0
        private ListViewEntry GenerateListViewEntryFromProperties(PSObject so, int enumerationLimit)
        {
            // compute active properties every time
            if (this.activeAssociationList is null)
            {
                SetUpActiveProperties(so);
            }

            ListViewEntry lve = new ListViewEntry();

            for (int k = 0; k < this.activeAssociationList.Count; k++)
            {
                MshResolvedExpressionParameterAssociation a = this.activeAssociationList[k];
                ListViewField lvf = new ListViewField();

                if (a.OriginatingParameter != null)
                {
                    object key = a.OriginatingParameter.GetEntry(FormatParameterDefinitionKeys.LabelEntryKey);

                    if (key != AutomationNull.Value)
                    {
                        lvf.propertyName = (string)key;
                    }
                    else
                    {
                        lvf.propertyName = a.ResolvedExpression.ToString();
                    }
                }
                else
                {
                    lvf.propertyName = a.ResolvedExpression.ToString();
                }

                FieldFormattingDirective directive = null;
                if (a.OriginatingParameter != null)
                {
                    directive = a.OriginatingParameter.GetEntry(FormatParameterDefinitionKeys.FormatStringEntryKey) as FieldFormattingDirective;
                }

                lvf.formatPropertyField.propertyValue = this.GetExpressionDisplayValue(so, enumerationLimit, a.ResolvedExpression, directive);
                lve.listViewFieldList.Add(lvf);
            }

            this.activeAssociationList = null;
            return(lve);
        }
Пример #3
0
        private ListViewEntry GenerateListViewEntryFromDataBaseInfo(PSObject so, int enumerationLimit)
        {
            ListViewEntry entry = new ListViewEntry();

            foreach (ListControlItemDefinition definition2 in this.GetActiveListControlEntryDefinition(this.listBody, so).itemDefinitionList)
            {
                if (base.EvaluateDisplayCondition(so, definition2.conditionToken))
                {
                    MshExpressionResult result;
                    ListViewField       item = new ListViewField {
                        formatPropertyField = base.GenerateFormatPropertyField(definition2.formatTokenList, so, enumerationLimit, out result)
                    };
                    if (definition2.label != null)
                    {
                        item.label = base.dataBaseInfo.db.displayResourceManagerCache.GetTextTokenString(definition2.label);
                    }
                    else if (result != null)
                    {
                        item.label = result.ResolvedExpression.ToString();
                    }
                    else
                    {
                        FormatToken        token  = definition2.formatTokenList[0];
                        FieldPropertyToken token2 = token as FieldPropertyToken;
                        if (token2 != null)
                        {
                            item.label = base.expressionFactory.CreateFromExpressionToken(token2.expression, base.dataBaseInfo.view.loadingInfo).ToString();
                        }
                        else
                        {
                            TextToken tt = token as TextToken;
                            if (tt != null)
                            {
                                item.label = base.dataBaseInfo.db.displayResourceManagerCache.GetTextTokenString(tt);
                            }
                        }
                    }
                    entry.listViewFieldList.Add(item);
                }
            }
            return(entry);
        }
Пример #4
0
 private ListViewEntry GenerateListViewEntryFromDataBaseInfo(PSObject so, int enumerationLimit)
 {
     ListViewEntry entry = new ListViewEntry();
     foreach (ListControlItemDefinition definition2 in this.GetActiveListControlEntryDefinition(this.listBody, so).itemDefinitionList)
     {
         if (base.EvaluateDisplayCondition(so, definition2.conditionToken))
         {
             MshExpressionResult result;
             ListViewField item = new ListViewField {
                 formatPropertyField = base.GenerateFormatPropertyField(definition2.formatTokenList, so, enumerationLimit, out result)
             };
             if (definition2.label != null)
             {
                 item.label = base.dataBaseInfo.db.displayResourceManagerCache.GetTextTokenString(definition2.label);
             }
             else if (result != null)
             {
                 item.label = result.ResolvedExpression.ToString();
             }
             else
             {
                 FormatToken token = definition2.formatTokenList[0];
                 FieldPropertyToken token2 = token as FieldPropertyToken;
                 if (token2 != null)
                 {
                     item.label = base.expressionFactory.CreateFromExpressionToken(token2.expression, base.dataBaseInfo.view.loadingInfo).ToString();
                 }
                 else
                 {
                     TextToken tt = token as TextToken;
                     if (tt != null)
                     {
                         item.label = base.dataBaseInfo.db.displayResourceManagerCache.GetTextTokenString(tt);
                     }
                 }
             }
             entry.listViewFieldList.Add(item);
         }
     }
     return entry;
 }
Пример #5
0
        private ListViewEntry GenerateListViewEntryFromProperties(PSObject so, int enumerationLimit)
        {
            if (base.activeAssociationList == null)
            {
                this.SetUpActiveProperties(so);
            }
            ListViewEntry entry = new ListViewEntry();

            for (int i = 0; i < base.activeAssociationList.Count; i++)
            {
                MshResolvedExpressionParameterAssociation association = base.activeAssociationList[i];
                ListViewField item = new ListViewField();
                if (association.OriginatingParameter != null)
                {
                    object obj2 = association.OriginatingParameter.GetEntry("label");
                    if (obj2 != AutomationNull.Value)
                    {
                        item.propertyName = (string)obj2;
                    }
                    else
                    {
                        item.propertyName = association.ResolvedExpression.ToString();
                    }
                }
                else
                {
                    item.propertyName = association.ResolvedExpression.ToString();
                }
                FieldFormattingDirective directive = null;
                if (association.OriginatingParameter != null)
                {
                    directive = association.OriginatingParameter.GetEntry("formatString") as FieldFormattingDirective;
                }
                item.formatPropertyField.propertyValue = base.GetExpressionDisplayValue(so, enumerationLimit, association.ResolvedExpression, directive);
                entry.listViewFieldList.Add(item);
            }
            base.activeAssociationList = null;
            return(entry);
        }
Пример #6
0
 private ListViewEntry GenerateListViewEntryFromProperties(PSObject so, int enumerationLimit)
 {
     if (base.activeAssociationList == null)
     {
         this.SetUpActiveProperties(so);
     }
     ListViewEntry entry = new ListViewEntry();
     for (int i = 0; i < base.activeAssociationList.Count; i++)
     {
         MshResolvedExpressionParameterAssociation association = base.activeAssociationList[i];
         ListViewField item = new ListViewField();
         if (association.OriginatingParameter != null)
         {
             object obj2 = association.OriginatingParameter.GetEntry("label");
             if (obj2 != AutomationNull.Value)
             {
                 item.propertyName = (string) obj2;
             }
             else
             {
                 item.propertyName = association.ResolvedExpression.ToString();
             }
         }
         else
         {
             item.propertyName = association.ResolvedExpression.ToString();
         }
         FieldFormattingDirective directive = null;
         if (association.OriginatingParameter != null)
         {
             directive = association.OriginatingParameter.GetEntry("formatString") as FieldFormattingDirective;
         }
         item.formatPropertyField.propertyValue = base.GetExpressionDisplayValue(so, enumerationLimit, association.ResolvedExpression, directive);
         entry.listViewFieldList.Add(item);
     }
     base.activeAssociationList = null;
     return entry;
 }
Пример #7
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;
        }
Пример #8
0
        private ListViewEntry GenerateListViewEntryFromProperties(PSObject so, int enumerationLimit)
        {
            // compute active properties every time
            if (this.activeAssociationList == null)
            {
                SetUpActiveProperties(so);
            }

            ListViewEntry lve = new ListViewEntry();

            for (int k = 0; k < this.activeAssociationList.Count; k++)
            {
                MshResolvedExpressionParameterAssociation a = this.activeAssociationList[k];
                ListViewField lvf = new ListViewField();

                if (a.OriginatingParameter != null)
                {
                    object key = a.OriginatingParameter.GetEntry(FormatParameterDefinitionKeys.LabelEntryKey);

                    if (key != AutomationNull.Value)
                    {
                        lvf.propertyName = (string)key;
                    }
                    else
                    {
                        lvf.propertyName = a.ResolvedExpression.ToString();
                    }
                }
                else
                {
                    lvf.propertyName = a.ResolvedExpression.ToString();
                }

                FieldFormattingDirective directive = null;
                if (a.OriginatingParameter != null)
                {
                    directive = a.OriginatingParameter.GetEntry(FormatParameterDefinitionKeys.FormatStringEntryKey) as FieldFormattingDirective;
                }
                lvf.formatPropertyField.propertyValue = this.GetExpressionDisplayValue(so, enumerationLimit, a.ResolvedExpression, directive);
                lve.listViewFieldList.Add(lvf);
            }

            this.activeAssociationList = null;
            return lve;
        }