Esempio 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();
                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);
        }
Esempio n. 2
0
            /// <summary>
            /// write a row into the list
            /// </summary>
            /// <param name="fed">FormatEntryData to process</param>
            internal override void ProcessPayload(FormatEntryData fed)
            {
                ListViewEntry lve = fed.formatEntryInfo as ListViewEntry;

                InternalInitialize(lve);
                string[] values = GetValues(lve);
                _listWriter.WriteProperties(values, this.InnerCommand._lo);
                this.InnerCommand._lo.WriteLine("");
            }
Esempio n. 3
0
        private void ProcessOutOfBandPayload(FormatEntryData fed)
        {
            // try if it is raw text
            RawTextFormatEntry rte = fed.formatEntryInfo as RawTextFormatEntry;

            if (rte != null)
            {
                if (fed.isHelpObject)
                {
                    ComplexWriter complexWriter = new ComplexWriter();

                    complexWriter.Initialize(_lo, _lo.ColumnNumber);
                    complexWriter.WriteString(rte.text);
                }
                else
                {
                    _lo.WriteLine(rte.text);
                }

                return;
            }

            // try if it is a complex entry
            ComplexViewEntry cve = fed.formatEntryInfo as ComplexViewEntry;

            if (cve != null && cve.formatValueList != null)
            {
                ComplexWriter complexWriter = new ComplexWriter();

                complexWriter.Initialize(_lo, int.MaxValue);
                complexWriter.WriteObject(cve.formatValueList);

                return;
            }
            // try if it is a list view
            ListViewEntry lve = fed.formatEntryInfo as ListViewEntry;

            if (lve != null && lve.listViewFieldList != null)
            {
                ListWriter listWriter = new ListWriter();

                _lo.WriteLine("");

                string[] properties = ListOutputContext.GetProperties(lve);
                listWriter.Initialize(properties, _lo.ColumnNumber, _lo.DisplayCells);
                string[] values = ListOutputContext.GetValues(lve);
                listWriter.WriteProperties(values, _lo);

                _lo.WriteLine("");

                return;
            }
        }
Esempio n. 4
0
            internal static string[] GetValues(ListViewEntry lve)
            {
                StringCollection strings = new StringCollection();

                foreach (ListViewField field in lve.listViewFieldList)
                {
                    strings.Add(field.formatPropertyField.propertyValue);
                }
                if (strings.Count == 0)
                {
                    return(null);
                }
                string[] array = new string[strings.Count];
                strings.CopyTo(array, 0);
                return(array);
            }
Esempio n. 5
0
            internal static string[] GetProperties(ListViewEntry lve)
            {
                StringCollection props = new StringCollection();

                foreach (ListViewField lvf in lve.listViewFieldList)
                {
                    props.Add(lvf.label ?? lvf.propertyName);
                }
                if (props.Count == 0)
                {
                    return(null);
                }
                string[] retVal = new string[props.Count];
                props.CopyTo(retVal, 0);
                return(retVal);
            }
Esempio n. 6
0
            internal static string[] GetValues(ListViewEntry lve)
            {
                StringCollection vals = new StringCollection();

                foreach (ListViewField lvf in lve.listViewFieldList)
                {
                    vals.Add(lvf.formatPropertyField.propertyValue);
                }
                if (vals.Count == 0)
                {
                    return(null);
                }
                string[] retVal = new string[vals.Count];
                vals.CopyTo(retVal, 0);
                return(retVal);
            }
Esempio n. 7
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);
        }
Esempio n. 8
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);
        }
Esempio n. 9
0
        private void ProcessOutOfBandPayload(FormatEntryData fed)
        {
            RawTextFormatEntry formatEntryInfo = fed.formatEntryInfo as RawTextFormatEntry;

            if (formatEntryInfo != null)
            {
                if (fed.isHelpObject)
                {
                    ComplexWriter writer = new ComplexWriter();
                    writer.Initialize(this.lo, this.lo.ColumnNumber);
                    writer.WriteString(formatEntryInfo.text);
                }
                else
                {
                    this.lo.WriteLine(formatEntryInfo.text);
                }
            }
            else
            {
                ComplexViewEntry entry2 = fed.formatEntryInfo as ComplexViewEntry;
                if ((entry2 != null) && (entry2.formatValueList != null))
                {
                    ComplexWriter writer2 = new ComplexWriter();
                    writer2.Initialize(this.lo, this.lo.ColumnNumber);
                    writer2.WriteObject(entry2.formatValueList);
                }
                else
                {
                    ListViewEntry lve = fed.formatEntryInfo as ListViewEntry;
                    if ((lve != null) && (lve.listViewFieldList != null))
                    {
                        ListWriter writer3 = new ListWriter();
                        this.lo.WriteLine("");
                        string[] properties = ListOutputContext.GetProperties(lve);
                        writer3.Initialize(properties, this.lo.ColumnNumber, this.lo.DisplayCells);
                        string[] values = ListOutputContext.GetValues(lve);
                        writer3.WriteProperties(values, this.lo);
                        this.lo.WriteLine("");
                    }
                }
            }
        }
Esempio n. 10
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;
 }
Esempio n. 11
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);
        }
Esempio n. 12
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;
 }
Esempio n. 13
0
            internal static string[] GetValues(ListViewEntry lve)
            {
                StringCollection vals = new StringCollection();

                foreach (ListViewField lvf in lve.listViewFieldList)
                {
                    vals.Add(lvf.formatPropertyField.propertyValue);
                }
                if (vals.Count == 0)
                    return null;
                string[] retVal = new string[vals.Count];
                vals.CopyTo(retVal, 0);
                return retVal;
            }
Esempio n. 14
0
 internal static string[] GetProperties(ListViewEntry lve)
 {
     StringCollection props = new StringCollection();
     foreach (ListViewField lvf in lve.listViewFieldList)
     {
         props.Add(lvf.label ?? lvf.propertyName);
     }
     if (props.Count == 0)
         return null;
     string[] retVal = new string[props.Count];
     props.CopyTo(retVal, 0);
     return retVal;
 }
Esempio n. 15
0
 private void InternalInitialize(ListViewEntry lve)
 {
     _properties = GetProperties(lve);
     _listWriter.Initialize(_properties, this.InnerCommand._lo.ColumnNumber, InnerCommand._lo.DisplayCells);
 }
Esempio n. 16
0
 private void InternalInitialize(ListViewEntry lve)
 {
     this.properties = GetProperties(lve);
     this.listWriter.Initialize(this.properties, base.InnerCommand.lo.ColumnNumber, base.InnerCommand.lo.DisplayCells);
 }
Esempio n. 17
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;
        }
Esempio n. 18
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;
        }
Esempio n. 19
0
 internal static string[] GetProperties(ListViewEntry lve)
 {
     StringCollection strings = new StringCollection();
     foreach (ListViewField field in lve.listViewFieldList)
     {
         strings.Add((field.label != null) ? field.label : field.propertyName);
     }
     if (strings.Count == 0)
     {
         return null;
     }
     string[] array = new string[strings.Count];
     strings.CopyTo(array, 0);
     return array;
 }
Esempio n. 20
0
 private void InternalInitialize(ListViewEntry lve)
 {
     _properties = GetProperties(lve);
     _listWriter.Initialize(_properties, this.InnerCommand._lo.ColumnNumber, InnerCommand._lo.DisplayCells);
 }
Esempio n. 21
0
 internal static string[] GetValues(ListViewEntry lve)
 {
     StringCollection strings = new StringCollection();
     foreach (ListViewField field in lve.listViewFieldList)
     {
         strings.Add(field.formatPropertyField.propertyValue);
     }
     if (strings.Count == 0)
     {
         return null;
     }
     string[] array = new string[strings.Count];
     strings.CopyTo(array, 0);
     return array;
 }
Esempio n. 22
0
 private void InternalInitialize(ListViewEntry lve)
 {
     this.properties = GetProperties(lve);
     this.listWriter.Initialize(this.properties, base.InnerCommand.lo.ColumnNumber, base.InnerCommand.lo.DisplayCells);
 }