예제 #1
0
 private void ProcessCachedGroupOnWide(WideViewHeaderInfo wvhi, List <PacketInfoData> objects)
 {
     if (wvhi.columns == 0)
     {
         int num = 0;
         foreach (PacketInfoData data in objects)
         {
             FormatEntryData data2 = data as FormatEntryData;
             if (data2 != null)
             {
                 WideViewEntry       formatEntryInfo     = data2.formatEntryInfo as WideViewEntry;
                 FormatPropertyField formatPropertyField = formatEntryInfo.formatPropertyField;
                 if (!string.IsNullOrEmpty(formatPropertyField.propertyValue))
                 {
                     int num2 = this.lo.DisplayCells.Length(formatPropertyField.propertyValue);
                     if (num2 > num)
                     {
                         num = num2;
                     }
                 }
             }
         }
         WideFormattingHint hint = new WideFormattingHint {
             maxWidth = num
         };
         this.formattingHint = hint;
     }
 }
        private WideViewEntry GenerateWideViewEntryFromProperties(PSObject so, int enumerationLimit)
        {
            // compute active properties every time
            if (this.activeAssociationList == null)
            {
                SetUpActiveProperty(so);
            }

            WideViewEntry       wve = new WideViewEntry();
            FormatPropertyField fpf = new FormatPropertyField();

            wve.formatPropertyField = fpf;
            if (this.activeAssociationList.Count > 0)
            {
                // get the first one
                MshResolvedExpressionParameterAssociation a = this.activeAssociationList[0];
                FieldFormattingDirective directive          = null;
                if (a.OriginatingParameter != null)
                {
                    directive = a.OriginatingParameter.GetEntry(FormatParameterDefinitionKeys.FormatStringEntryKey) as FieldFormattingDirective;
                }

                fpf.propertyValue = this.GetExpressionDisplayValue(so, enumerationLimit, a.ResolvedExpression, directive);
            }

            this.activeAssociationList = null;
            return(wve);
        }
예제 #3
0
        private void DisplayRawObject(PSObject so, List <FormatValue> formatValueList)
        {
            FormatPropertyField fpf = new FormatPropertyField();

            StringFormatError formatErrorObject = null;

            if (_errorManager.DisplayFormatErrorString)
            {
                // we send a format error object down to the formatting calls
                // only if we want to show the formatting error strings
                formatErrorObject = new StringFormatError();
            }

            fpf.propertyValue = PSObjectHelper.SmartToString(so, _expressionFactory, _enumerationLimit, formatErrorObject);

            if (formatErrorObject != null && formatErrorObject.exception != null)
            {
                // if we did no thave any errors in the expression evaluation
                // we might have errors in the formatting, if present
                _errorManager.LogStringFormatError(formatErrorObject);
                if (_errorManager.DisplayFormatErrorString)
                {
                    fpf.propertyValue = _errorManager.FormatErrorString;
                }
            }

            formatValueList.Add(fpf);
            formatValueList.Add(new FormatNewLine());
        }
예제 #4
0
        internal GroupStartData GenerateGroupStartData(PSObject firstObjectInGroup, int enumerationLimit)
        {
            GroupStartData data = new GroupStartData();

            if (this.groupingManager != null)
            {
                object currentGroupingKeyPropertyValue = this.groupingManager.CurrentGroupingKeyPropertyValue;
                if (currentGroupingKeyPropertyValue == AutomationNull.Value)
                {
                    return(data);
                }
                PSObject    so      = PSObjectHelper.AsPSObject(currentGroupingKeyPropertyValue);
                ControlBase control = null;
                TextToken   tt      = null;
                if (((this.dataBaseInfo.view != null) && (this.dataBaseInfo.view.groupBy != null)) && (this.dataBaseInfo.view.groupBy.startGroup != null))
                {
                    control = this.dataBaseInfo.view.groupBy.startGroup.control;
                    tt      = this.dataBaseInfo.view.groupBy.startGroup.labelTextToken;
                }
                data.groupingEntry = new GroupingEntry();
                if (control == null)
                {
                    string            textTokenString;
                    StringFormatError formatErrorObject = null;
                    if (this.errorManager.DisplayFormatErrorString)
                    {
                        formatErrorObject = new StringFormatError();
                    }
                    string formatErrorString = PSObjectHelper.SmartToString(so, this.expressionFactory, enumerationLimit, formatErrorObject);
                    if ((formatErrorObject != null) && (formatErrorObject.exception != null))
                    {
                        this.errorManager.LogStringFormatError(formatErrorObject);
                        if (this.errorManager.DisplayFormatErrorString)
                        {
                            formatErrorString = this.errorManager.FormatErrorString;
                        }
                    }
                    FormatEntry item = new FormatEntry();
                    data.groupingEntry.formatValueList.Add(item);
                    FormatTextField field = new FormatTextField();
                    if (tt != null)
                    {
                        textTokenString = this.dataBaseInfo.db.displayResourceManagerCache.GetTextTokenString(tt);
                    }
                    else
                    {
                        textTokenString = this.groupingManager.GroupingKeyDisplayName;
                    }
                    field.text = StringUtil.Format(FormatAndOut_format_xxx.GroupStartDataIndentedAutoGeneratedLabel, textTokenString);
                    item.formatValueList.Add(field);
                    FormatPropertyField field2 = new FormatPropertyField {
                        propertyValue = formatErrorString
                    };
                    item.formatValueList.Add(field2);
                    return(data);
                }
                new ComplexControlGenerator(this.dataBaseInfo.db, this.dataBaseInfo.view.loadingInfo, this.expressionFactory, this.dataBaseInfo.view.formatControlDefinitionHolder.controlDefinitionList, this.ErrorManager, enumerationLimit, this.errorContext).GenerateFormatEntries(50, control, firstObjectInGroup, data.groupingEntry.formatValueList);
            }
            return(data);
        }
        private TableRowEntry GenerateTableRowEntryFromFromProperties(PSObject so, int enumerationLimit)
        {
            TableRowEntry tre = new TableRowEntry();

            for (int k = 0; k < this.activeAssociationList.Count; k++)
            {
                FormatPropertyField      fpf       = new FormatPropertyField();
                FieldFormattingDirective directive = null;
                if (activeAssociationList[k].OriginatingParameter != null)
                {
                    directive = activeAssociationList[k].OriginatingParameter.GetEntry(FormatParameterDefinitionKeys.FormatStringEntryKey) as FieldFormattingDirective;
                }

                if (directive is null)
                {
                    directive         = new FieldFormattingDirective();
                    directive.isTable = true;
                }

                fpf.propertyValue = this.GetExpressionDisplayValue(so, enumerationLimit, this.activeAssociationList[k].ResolvedExpression, directive);
                tre.formatPropertyFieldList.Add(fpf);
            }

            return(tre);
        }
예제 #6
0
        protected FormatPropertyField GenerateFormatPropertyField(List <FormatToken> formatTokenList, PSObject so, int enumerationLimit, out MshExpressionResult result)
        {
            result = null;
            FormatPropertyField field = new FormatPropertyField();

            if (formatTokenList.Count != 0)
            {
                FormatToken        token  = formatTokenList[0];
                FieldPropertyToken token2 = token as FieldPropertyToken;
                if (token2 != null)
                {
                    MshExpression ex = this.expressionFactory.CreateFromExpressionToken(token2.expression, this.dataBaseInfo.view.loadingInfo);
                    field.propertyValue = this.GetExpressionDisplayValue(so, enumerationLimit, ex, token2.fieldFormattingDirective, out result);
                    return(field);
                }
                TextToken tt = token as TextToken;
                if (tt != null)
                {
                    field.propertyValue = this.dataBaseInfo.db.displayResourceManagerCache.GetTextTokenString(tt);
                }
                return(field);
            }
            field.propertyValue = "";
            return(field);
        }
예제 #7
0
 internal override void Deserialize(PSObject so, FormatObjectDeserializer deserializer)
 {
     base.Deserialize(so, deserializer);
     this.label               = deserializer.DeserializeStringMemberVariable(so, "label");
     this.propertyName        = deserializer.DeserializeStringMemberVariable(so, "propertyName");
     this.formatPropertyField = (FormatPropertyField)deserializer.DeserializeMandatoryMemberObject(so, "formatPropertyField");
 }
예제 #8
0
 internal override void Deserialize(PSObject so, FormatObjectDeserializer deserializer)
 {
     base.Deserialize(so, deserializer);
     this.label = deserializer.DeserializeStringMemberVariable(so, "label");
     this.propertyName = deserializer.DeserializeStringMemberVariable(so, "propertyName");
     this.formatPropertyField = (FormatPropertyField) deserializer.DeserializeMandatoryMemberObject(so, "formatPropertyField");
 }
예제 #9
0
        protected FormatPropertyField GenerateFormatPropertyField(List <FormatToken> formatTokenList, PSObject so, int enumerationLimit, out PSPropertyExpressionResult result)
        {
            result = null;
            FormatPropertyField fpf = new FormatPropertyField();

            if (formatTokenList.Count != 0)
            {
                FormatToken        token = formatTokenList[0];
                FieldPropertyToken fpt   = token as FieldPropertyToken;
                if (fpt != null)
                {
                    PSPropertyExpression ex = this.expressionFactory.CreateFromExpressionToken(fpt.expression, this.dataBaseInfo.view.loadingInfo);
                    fpf.propertyValue = this.GetExpressionDisplayValue(so, enumerationLimit, ex, fpt.fieldFormattingDirective, out result);
                }
                else
                {
                    TextToken tt = token as TextToken;
                    if (tt != null)
                    {
                        fpf.propertyValue = this.dataBaseInfo.db.displayResourceManagerCache.GetTextTokenString(tt);
                    }
                }
            }
            else
            {
                fpf.propertyValue = string.Empty;
            }

            return(fpf);
        }
예제 #10
0
        /// <summary>
        /// display a leaf value
        /// </summary>
        /// <param name="val">object to display</param>
        /// <param name="formatValueList">list of format tokens to add to</param>
        private void DisplayLeaf(object val, List <FormatValue> formatValueList)
        {
            FormatPropertyField fpf = new FormatPropertyField();

            fpf.propertyValue = PSObjectHelper.FormatField(null, PSObjectHelper.AsPSObject(val), _enumerationLimit, null, _expressionFactory);
            formatValueList.Add(fpf);
            formatValueList.Add(new FormatNewLine());
        }
예제 #11
0
        private void DisplayLeaf(object val, List <FormatValue> formatValueList)
        {
            FormatPropertyField item = new FormatPropertyField {
                propertyValue = PSObjectHelper.FormatField(null, PSObjectHelper.AsPSObject(val), this.enumerationLimit, null, this.expressionFactory)
            };

            formatValueList.Add(item);
            formatValueList.Add(new FormatNewLine());
        }
예제 #12
0
            /// <summary>
            /// write a row into the table
            /// </summary>
            /// <param name="fed">FormatEntryData to process</param>
            internal override void ProcessPayload(FormatEntryData fed)
            {
                WideViewEntry       wve = fed.formatEntryInfo as WideViewEntry;
                FormatPropertyField fpf = wve.formatPropertyField as FormatPropertyField;

                _buffer.Add(fpf.propertyValue);
                if (_buffer.IsFull)
                {
                    WriteStringBuffer();
                }
            }
예제 #13
0
            internal override void ProcessPayload(FormatEntryData fed)
            {
                WideViewEntry       formatEntryInfo     = fed.formatEntryInfo as WideViewEntry;
                FormatPropertyField formatPropertyField = formatEntryInfo.formatPropertyField;

                this.buffer.Add(formatPropertyField.propertyValue);
                if (this.buffer.IsFull)
                {
                    this.WriteStringBuffer();
                }
            }
예제 #14
0
        private TableRowEntry GenerateTableRowEntryFromDataBaseInfo(PSObject so, int enumerationLimit)
        {
            TableRowEntry entry = new TableRowEntry();

            foreach (TableRowItemDefinition definition in this.GetActiveTableRowDefinition(this.tableBody, so, out entry.multiLine))
            {
                FormatPropertyField item = base.GenerateFormatPropertyField(definition.formatTokenList, so, enumerationLimit);
                item.alignment = definition.alignment;
                entry.formatPropertyFieldList.Add(item);
            }
            return(entry);
        }
예제 #15
0
        /// <summary>
        /// Operate on a single entry.
        /// </summary>
        /// <param name="fe">Entry to process.</param>
        /// <param name="currentDepth">Current depth of recursion.</param>
        private void GenerateFormatEntryDisplay(FormatEntry fe, int currentDepth)
        {
            foreach (object obj in fe.formatValueList)
            {
                FormatEntry feChild = obj as FormatEntry;
                if (feChild != null)
                {
                    if (currentDepth < maxRecursionDepth)
                    {
                        if (feChild.frameInfo != null)
                        {
                            // if we have frame information, we need to push it on the
                            // indentation stack
                            using (_indentationManager.StackFrame(feChild.frameInfo))
                            {
                                GenerateFormatEntryDisplay(feChild, currentDepth + 1);
                            }
                        }
                        else
                        {
                            // no need here of activating an indentation stack frame
                            GenerateFormatEntryDisplay(feChild, currentDepth + 1);
                        }
                    }

                    continue;
                }

                if (obj is FormatNewLine)
                {
                    this.WriteToScreen();
                    continue;
                }

                FormatTextField ftf = obj as FormatTextField;
                if (ftf != null)
                {
                    this.AddToBuffer(ftf.text);
                    continue;
                }

                FormatPropertyField fpf = obj as FormatPropertyField;
                if (fpf != null)
                {
                    this.AddToBuffer(fpf.propertyValue);
                }
            }
        }
예제 #16
0
        private TableRowEntry GenerateTableRowEntryFromFromProperties(PSObject so, int enumerationLimit)
        {
            TableRowEntry entry = new TableRowEntry();

            for (int i = 0; i < base.activeAssociationList.Count; i++)
            {
                FormatPropertyField      item      = new FormatPropertyField();
                FieldFormattingDirective directive = null;
                if (base.activeAssociationList[i].OriginatingParameter != null)
                {
                    directive = base.activeAssociationList[i].OriginatingParameter.GetEntry("formatString") as FieldFormattingDirective;
                }
                item.propertyValue = base.GetExpressionDisplayValue(so, enumerationLimit, base.activeAssociationList[i].ResolvedExpression, directive);
                entry.formatPropertyFieldList.Add(item);
            }
            return(entry);
        }
        private TableRowEntry GenerateTableRowEntryFromDataBaseInfo(PSObject so, int enumerationLimit)
        {
            TableRowEntry tre = new TableRowEntry();

            List <TableRowItemDefinition> activeRowItemDefinitionList = GetActiveTableRowDefinition(_tableBody, so, out tre.multiLine);

            foreach (TableRowItemDefinition rowItem in activeRowItemDefinitionList)
            {
                FormatPropertyField fpf = GenerateFormatPropertyField(rowItem.formatTokenList, so, enumerationLimit);

                // get the alignment from the row entry
                // NOTE: if it's not set, the alignment sent with the header will prevail
                fpf.alignment = rowItem.alignment;

                tre.formatPropertyFieldList.Add(fpf);
            }

            return(tre);
        }
예제 #18
0
 private void GenerateFormatEntryDisplay(FormatEntry fe, int currentDepth)
 {
     foreach (object obj2 in fe.formatValueList)
     {
         FormatEntry entry = obj2 as FormatEntry;
         if (entry != null)
         {
             if (currentDepth < 50)
             {
                 if (entry.frameInfo != null)
                 {
                     using (this.indentationManager.StackFrame(entry.frameInfo))
                     {
                         this.GenerateFormatEntryDisplay(entry, currentDepth + 1);
                         continue;
                     }
                 }
                 this.GenerateFormatEntryDisplay(entry, currentDepth + 1);
             }
         }
         else if (obj2 is FormatNewLine)
         {
             this.WriteToScreen();
         }
         else
         {
             FormatTextField field = obj2 as FormatTextField;
             if (field != null)
             {
                 this.AddToBuffer(field.text);
             }
             else
             {
                 FormatPropertyField field2 = obj2 as FormatPropertyField;
                 if (field2 != null)
                 {
                     this.AddToBuffer(field2.propertyValue);
                 }
             }
         }
     }
 }
예제 #19
0
        private void DisplayRawObject(PSObject so, List <FormatValue> formatValueList)
        {
            FormatPropertyField item = new FormatPropertyField();
            StringFormatError   formatErrorObject = null;

            if (this.errorManager.DisplayFormatErrorString)
            {
                formatErrorObject = new StringFormatError();
            }
            item.propertyValue = PSObjectHelper.SmartToString(so, this.expressionFactory, this.enumerationLimit, formatErrorObject);
            if ((formatErrorObject != null) && (formatErrorObject.exception != null))
            {
                this.errorManager.LogStringFormatError(formatErrorObject);
                if (this.errorManager.DisplayFormatErrorString)
                {
                    item.propertyValue = this.errorManager.FormatErrorString;
                }
            }
            formatValueList.Add(item);
            formatValueList.Add(new FormatNewLine());
        }
예제 #20
0
 private WideViewEntry GenerateWideViewEntryFromProperties(PSObject so, int enumerationLimit)
 {
     if (base.activeAssociationList == null)
     {
         this.SetUpActiveProperty(so);
     }
     WideViewEntry entry = new WideViewEntry();
     FormatPropertyField field = new FormatPropertyField();
     entry.formatPropertyField = field;
     if (base.activeAssociationList.Count > 0)
     {
         MshResolvedExpressionParameterAssociation association = base.activeAssociationList[0];
         FieldFormattingDirective directive = null;
         if (association.OriginatingParameter != null)
         {
             directive = association.OriginatingParameter.GetEntry("formatString") as FieldFormattingDirective;
         }
         field.propertyValue = base.GetExpressionDisplayValue(so, enumerationLimit, association.ResolvedExpression, directive);
     }
     base.activeAssociationList = null;
     return entry;
 }
예제 #21
0
        private void ProcessCachedGroupOnWide(WideViewHeaderInfo wvhi, List <PacketInfoData> objects)
        {
            if (wvhi.columns != 0)
            {
                // columns forced on the client
                return;
            }

            int maxLen = 0;
            int cellCount; // scratch variable

            foreach (PacketInfoData o in objects)
            {
                FormatEntryData fed = o as FormatEntryData;

                if (fed == null)
                {
                    continue;
                }

                WideViewEntry       wve = fed.formatEntryInfo as WideViewEntry;
                FormatPropertyField fpf = wve.formatPropertyField as FormatPropertyField;

                if (!string.IsNullOrEmpty(fpf.propertyValue))
                {
                    cellCount = _lo.DisplayCells.Length(fpf.propertyValue);
                    if (cellCount > maxLen)
                    {
                        maxLen = cellCount;
                    }
                }
            }

            WideFormattingHint hint = new WideFormattingHint();

            hint.maxWidth   = maxLen;
            _formattingHint = hint;
        }
예제 #22
0
        private WideViewEntry GenerateWideViewEntryFromProperties(PSObject so, int enumerationLimit)
        {
            if (base.activeAssociationList == null)
            {
                this.SetUpActiveProperty(so);
            }
            WideViewEntry       entry = new WideViewEntry();
            FormatPropertyField field = new FormatPropertyField();

            entry.formatPropertyField = field;
            if (base.activeAssociationList.Count > 0)
            {
                MshResolvedExpressionParameterAssociation association = base.activeAssociationList[0];
                FieldFormattingDirective directive = null;
                if (association.OriginatingParameter != null)
                {
                    directive = association.OriginatingParameter.GetEntry("formatString") as FieldFormattingDirective;
                }
                field.propertyValue = base.GetExpressionDisplayValue(so, enumerationLimit, association.ResolvedExpression, directive);
            }
            base.activeAssociationList = null;
            return(entry);
        }
예제 #23
0
 protected FormatPropertyField GenerateFormatPropertyField(List<FormatToken> formatTokenList, PSObject so, int enumerationLimit, out MshExpressionResult result)
 {
     result = null;
     FormatPropertyField field = new FormatPropertyField();
     if (formatTokenList.Count != 0)
     {
         FormatToken token = formatTokenList[0];
         FieldPropertyToken token2 = token as FieldPropertyToken;
         if (token2 != null)
         {
             MshExpression ex = this.expressionFactory.CreateFromExpressionToken(token2.expression, this.dataBaseInfo.view.loadingInfo);
             field.propertyValue = this.GetExpressionDisplayValue(so, enumerationLimit, ex, token2.fieldFormattingDirective, out result);
             return field;
         }
         TextToken tt = token as TextToken;
         if (tt != null)
         {
             field.propertyValue = this.dataBaseInfo.db.displayResourceManagerCache.GetTextTokenString(tt);
         }
         return field;
     }
     field.propertyValue = "";
     return field;
 }
예제 #24
0
        private WideViewEntry GenerateWideViewEntryFromProperties(PSObject so, int enumerationLimit)
        {
            // compute active properties every time
            if (this.activeAssociationList == null)
            {
                SetUpActiveProperty(so);
            }

            WideViewEntry wve = new WideViewEntry();
            FormatPropertyField fpf = new FormatPropertyField();

            wve.formatPropertyField = fpf;
            if (this.activeAssociationList.Count > 0)
            {
                // get the first one
                MshResolvedExpressionParameterAssociation a = this.activeAssociationList[0];
                FieldFormattingDirective directive = null;
                if (a.OriginatingParameter != null)
                {
                    directive = a.OriginatingParameter.GetEntry(FormatParameterDefinitionKeys.FormatStringEntryKey) as FieldFormattingDirective;
                }

                fpf.propertyValue = this.GetExpressionDisplayValue(so, enumerationLimit, a.ResolvedExpression, directive);
            }

            this.activeAssociationList = null;
            return wve;
        }
예제 #25
0
        internal GroupStartData GenerateGroupStartData(PSObject firstObjectInGroup, int enumerationLimit)
        {
            GroupStartData startGroup = new GroupStartData();

            if (_groupingManager is null)
            {
                return(startGroup);
            }

            object currentGroupingValue = _groupingManager.CurrentGroupingKeyPropertyValue;

            if (currentGroupingValue == AutomationNull.Value)
            {
                return(startGroup);
            }

            PSObject so = PSObjectHelper.AsPSObject(currentGroupingValue);

            // we need to determine how to display the group header
            ControlBase control        = null;
            TextToken   labelTextToken = null;

            if (this.dataBaseInfo.view != null && this.dataBaseInfo.view.groupBy != null)
            {
                if (this.dataBaseInfo.view.groupBy.startGroup != null)
                {
                    // NOTE: from the database constraints, only one of the
                    // two will be non null
                    control        = this.dataBaseInfo.view.groupBy.startGroup.control;
                    labelTextToken = this.dataBaseInfo.view.groupBy.startGroup.labelTextToken;
                }
            }

            startGroup.groupingEntry = new GroupingEntry();

            if (control is null)
            {
                // we do not have a control, we auto generate a
                // snippet of complex display using a label

                StringFormatError formatErrorObject = null;
                if (_errorManager.DisplayFormatErrorString)
                {
                    // we send a format error object down to the formatting calls
                    // only if we want to show the formatting error strings
                    formatErrorObject = new StringFormatError();
                }

                string currentGroupingValueDisplay = PSObjectHelper.SmartToString(so, this.expressionFactory, enumerationLimit, formatErrorObject);

                if (formatErrorObject != null && formatErrorObject.exception != null)
                {
                    // if we did no thave any errors in the expression evaluation
                    // we might have errors in the formatting, if present
                    _errorManager.LogStringFormatError(formatErrorObject);
                    if (_errorManager.DisplayFormatErrorString)
                    {
                        currentGroupingValueDisplay = _errorManager.FormatErrorString;
                    }
                }

                FormatEntry fe = new FormatEntry();
                startGroup.groupingEntry.formatValueList.Add(fe);

                FormatTextField ftf = new FormatTextField();

                // determine what the label should be. If we have a label from the
                // database, let's use it, else fall back to the string provided
                // by the grouping manager
                string label;
                if (labelTextToken != null)
                {
                    label = this.dataBaseInfo.db.displayResourceManagerCache.GetTextTokenString(labelTextToken);
                }
                else
                {
                    label = _groupingManager.GroupingKeyDisplayName;
                }

                ftf.text = StringUtil.Format(FormatAndOut_format_xxx.GroupStartDataIndentedAutoGeneratedLabel, label);

                fe.formatValueList.Add(ftf);

                FormatPropertyField fpf = new FormatPropertyField();

                fpf.propertyValue = currentGroupingValueDisplay;
                fe.formatValueList.Add(fpf);
            }
            else
            {
                // NOTE: we set a max depth to protect ourselves from infinite loops
                const int maxTreeDepth = 50;
                ComplexControlGenerator controlGenerator =
                    new ComplexControlGenerator(this.dataBaseInfo.db,
                                                this.dataBaseInfo.view.loadingInfo,
                                                this.expressionFactory,
                                                this.dataBaseInfo.view.formatControlDefinitionHolder.controlDefinitionList,
                                                this.ErrorManager,
                                                enumerationLimit,
                                                this.errorContext);

                controlGenerator.GenerateFormatEntries(maxTreeDepth,
                                                       control, firstObjectInGroup, startGroup.groupingEntry.formatValueList);
            }

            return(startGroup);
        }
예제 #26
0
 internal override void Deserialize(PSObject so, FormatObjectDeserializer deserializer)
 {
     base.Deserialize(so, deserializer);
     this.formatPropertyField = (FormatPropertyField) deserializer.DeserializeMandatoryMemberObject(so, "formatPropertyField");
 }
예제 #27
0
        internal GroupStartData GenerateGroupStartData(PSObject firstObjectInGroup, int enumerationLimit)
        {
            GroupStartData startGroup = new GroupStartData();
            if (_groupingManager == null)
                return startGroup;

            object currentGroupingValue = _groupingManager.CurrentGroupingKeyPropertyValue;

            if (currentGroupingValue == AutomationNull.Value)
                return startGroup;

            PSObject so = PSObjectHelper.AsPSObject(currentGroupingValue);

            // we need to determine how to display the group header
            ControlBase control = null;
            TextToken labelTextToken = null;
            if (this.dataBaseInfo.view != null && this.dataBaseInfo.view.groupBy != null)
            {
                if (this.dataBaseInfo.view.groupBy.startGroup != null)
                {
                    // NOTE: from the database constraints, only one of the
                    // two will be non null
                    control = this.dataBaseInfo.view.groupBy.startGroup.control;
                    labelTextToken = this.dataBaseInfo.view.groupBy.startGroup.labelTextToken;
                }
            }

            startGroup.groupingEntry = new GroupingEntry();

            if (control == null)
            {
                // we do not have a control, we auto generate a
                // snippet of complex display using a label

                StringFormatError formatErrorObject = null;
                if (_errorManager.DisplayFormatErrorString)
                {
                    // we send a format error object down to the formatting calls
                    // only if we want to show the formatting error strings
                    formatErrorObject = new StringFormatError();
                }

                string currentGroupingValueDisplay = PSObjectHelper.SmartToString(so, this.expressionFactory, enumerationLimit, formatErrorObject);

                if (formatErrorObject != null && formatErrorObject.exception != null)
                {
                    // if we did no thave any errors in the expression evaluation
                    // we might have errors in the formatting, if present
                    _errorManager.LogStringFormatError(formatErrorObject);
                    if (_errorManager.DisplayFormatErrorString)
                    {
                        currentGroupingValueDisplay = _errorManager.FormatErrorString;
                    }
                }


                FormatEntry fe = new FormatEntry();
                startGroup.groupingEntry.formatValueList.Add(fe);

                FormatTextField ftf = new FormatTextField();

                // determine what the label should be. If we have a label from the
                // database, let's use it, else fall back to the string provided
                // by the grouping manager
                string label;
                if (labelTextToken != null)
                    label = this.dataBaseInfo.db.displayResourceManagerCache.GetTextTokenString(labelTextToken);
                else
                    label = _groupingManager.GroupingKeyDisplayName;

                ftf.text = StringUtil.Format(FormatAndOut_format_xxx.GroupStartDataIndentedAutoGeneratedLabel, label);

                fe.formatValueList.Add(ftf);

                FormatPropertyField fpf = new FormatPropertyField();

                fpf.propertyValue = currentGroupingValueDisplay;
                fe.formatValueList.Add(fpf);
            }
            else
            {
                // NOTE: we set a max depth to protect ourselves from infinite loops
                const int maxTreeDepth = 50;
                ComplexControlGenerator controlGenerator =
                                new ComplexControlGenerator(this.dataBaseInfo.db,
                                        this.dataBaseInfo.view.loadingInfo,
                                        this.expressionFactory,
                                        this.dataBaseInfo.view.formatControlDefinitionHolder.controlDefinitionList,
                                        this.ErrorManager,
                                        enumerationLimit,
                                        this.errorContext);

                controlGenerator.GenerateFormatEntries(maxTreeDepth,
                    control, firstObjectInGroup, startGroup.groupingEntry.formatValueList);
            }
            return startGroup;
        }
예제 #28
0
 public WideViewEntry() : base("59bf79de63354a7b9e4d1697940ff188")
 {
     this.formatPropertyField = new FormatPropertyField();
 }
예제 #29
0
        private void ExecuteFormatTokenList(TraversalInfo level,
                                            PSObject so, List <FormatToken> formatTokenList, List <FormatValue> formatValueList)
        {
            if (so == null)
            {
                throw PSTraceSource.NewArgumentNullException("so");
            }

            // guard against infinite loop
            if (level.Level == level.MaxDepth)
            {
                return;
            }

            FormatEntry fe = new FormatEntry();

            formatValueList.Add(fe);
            #region foreach loop
            foreach (FormatToken t in formatTokenList)
            {
                TextToken tt = t as TextToken;
                if (tt != null)
                {
                    FormatTextField ftf = new FormatTextField();
                    ftf.text = _db.displayResourceManagerCache.GetTextTokenString(tt);
                    fe.formatValueList.Add(ftf);
                    continue;
                }
                var newline = t as NewLineToken;
                if (newline != null)
                {
                    for (int i = 0; i < newline.count; i++)
                    {
                        fe.formatValueList.Add(new FormatNewLine());
                    }
                    continue;
                }
                FrameToken ft = t as FrameToken;
                if (ft != null)
                {
                    // instantiate a new entry and attach a frame info object
                    FormatEntry feFrame = new FormatEntry();
                    feFrame.frameInfo = new FrameInfo();

                    // add the frame info
                    feFrame.frameInfo.firstLine        = ft.frameInfoDefinition.firstLine;
                    feFrame.frameInfo.leftIndentation  = ft.frameInfoDefinition.leftIndentation;
                    feFrame.frameInfo.rightIndentation = ft.frameInfoDefinition.rightIndentation;

                    // execute the list inside the frame
                    ExecuteFormatTokenList(level, so, ft.itemDefinition.formatTokenList, feFrame.formatValueList);

                    // add the frame computation results to the current format entry
                    fe.formatValueList.Add(feFrame);
                    continue;
                }
                #region CompoundPropertyToken
                CompoundPropertyToken cpt = t as CompoundPropertyToken;
                if (cpt != null)
                {
                    if (!EvaluateDisplayCondition(so, cpt.conditionToken))
                    {
                        // token not active, skip it
                        continue;
                    }

                    // get the property from the object
                    object val = null;

                    // if no expression was specified, just use the
                    // object itself
                    if (cpt.expression == null || string.IsNullOrEmpty(cpt.expression.expressionValue))
                    {
                        val = so;
                    }
                    else
                    {
                        PSPropertyExpression ex = _expressionFactory.CreateFromExpressionToken(cpt.expression, _loadingInfo);
                        List <PSPropertyExpressionResult> resultList = ex.GetValues(so);
                        if (resultList.Count > 0)
                        {
                            val = resultList[0].Result;
                            if (resultList[0].Exception != null)
                            {
                                _errorManager.LogPSPropertyExpressionFailedResult(resultList[0], so);
                            }
                        }
                    }

                    // if the token is has a formatting string, it's a leaf node,
                    // do the formatting and we will be done
                    if (cpt.control == null || cpt.control is FieldControlBody)
                    {
                        // Since it is a leaf node we just consider it an empty string and go
                        // on with formatting
                        if (val == null)
                        {
                            val = string.Empty;
                        }
                        FieldFormattingDirective fieldFormattingDirective = null;
                        StringFormatError        formatErrorObject        = null;
                        if (cpt.control != null)
                        {
                            fieldFormattingDirective = ((FieldControlBody)cpt.control).fieldFormattingDirective;
                            if (fieldFormattingDirective != null && _errorManager.DisplayFormatErrorString)
                            {
                                formatErrorObject = new StringFormatError();
                            }
                        }

                        IEnumerable         e   = PSObjectHelper.GetEnumerable(val);
                        FormatPropertyField fpf = new FormatPropertyField();
                        if (cpt.enumerateCollection && e != null)
                        {
                            foreach (object x in e)
                            {
                                if (x == null)
                                {
                                    // nothing to process
                                    continue;
                                }
                                fpf = new FormatPropertyField();

                                fpf.propertyValue = PSObjectHelper.FormatField(fieldFormattingDirective, x, _enumerationLimit, formatErrorObject, _expressionFactory);
                                fe.formatValueList.Add(fpf);
                            }
                        }
                        else
                        {
                            fpf = new FormatPropertyField();

                            fpf.propertyValue = PSObjectHelper.FormatField(fieldFormattingDirective, val, _enumerationLimit, formatErrorObject, _expressionFactory);
                            fe.formatValueList.Add(fpf);
                        }
                        if (formatErrorObject != null && formatErrorObject.exception != null)
                        {
                            _errorManager.LogStringFormatError(formatErrorObject);
                            fpf.propertyValue = _errorManager.FormatErrorString;
                        }
                    }
                    else
                    {
                        // An empty result that is not a leaf node should not be expanded
                        if (val == null)
                        {
                            continue;
                        }
                        IEnumerable e = PSObjectHelper.GetEnumerable(val);
                        if (cpt.enumerateCollection && e != null)
                        {
                            foreach (object x in e)
                            {
                                if (x == null)
                                {
                                    // nothing to process
                                    continue;
                                }

                                // proceed with the recursion
                                ExecuteFormatControl(level.NextLevel, cpt.control, PSObject.AsPSObject(x), fe.formatValueList);
                            }
                        }
                        else
                        {
                            // proceed with the recursion
                            ExecuteFormatControl(level.NextLevel, cpt.control, PSObjectHelper.AsPSObject(val), fe.formatValueList);
                        }
                    }
                }
                #endregion CompoundPropertyToken
            }
            #endregion foreach loop
        }
예제 #30
0
 private void DisplayLeaf(object val, List<FormatValue> formatValueList)
 {
     FormatPropertyField item = new FormatPropertyField {
         propertyValue = PSObjectHelper.FormatField(null, PSObjectHelper.AsPSObject(val), this.enumerationLimit, null, this.expressionFactory)
     };
     formatValueList.Add(item);
     formatValueList.Add(new FormatNewLine());
 }
예제 #31
0
 private TableRowEntry GenerateTableRowEntryFromFromProperties(PSObject so, int enumerationLimit)
 {
     TableRowEntry tre = new TableRowEntry();
     for (int k = 0; k < this.activeAssociationList.Count; k++)
     {
         FormatPropertyField fpf = new FormatPropertyField();
         FieldFormattingDirective directive = null;
         if (activeAssociationList[k].OriginatingParameter != null)
         {
             directive = activeAssociationList[k].OriginatingParameter.GetEntry(FormatParameterDefinitionKeys.FormatStringEntryKey) as FieldFormattingDirective;
         }
         fpf.propertyValue = this.GetExpressionDisplayValue(so, enumerationLimit, this.activeAssociationList[k].ResolvedExpression, directive);
         tre.formatPropertyFieldList.Add(fpf);
     }
     return tre;
 }
예제 #32
0
 public WideViewEntry() : base("59bf79de63354a7b9e4d1697940ff188")
 {
     this.formatPropertyField = new FormatPropertyField();
 }
예제 #33
0
        /// <summary>
        /// display a leaf value
        /// </summary>
        /// <param name="val">object to display</param>
        /// <param name="formatValueList">list of format tokens to add to</param>
        private void DisplayLeaf(object val, List<FormatValue> formatValueList)
        {
            FormatPropertyField fpf = new FormatPropertyField();

            fpf.propertyValue = PSObjectHelper.FormatField(null, PSObjectHelper.AsPSObject(val), _enumerationLimit, null, _expressionFactory);
            formatValueList.Add(fpf);
            formatValueList.Add(new FormatNewLine());
        }
예제 #34
0
        private void DisplayRawObject(PSObject so, List<FormatValue> formatValueList)
        {
            FormatPropertyField fpf = new FormatPropertyField();

            StringFormatError formatErrorObject = null;
            if (_errorManager.DisplayFormatErrorString)
            {
                // we send a format error object down to the formatting calls
                // only if we want to show the formatting error strings
                formatErrorObject = new StringFormatError();
            }

            fpf.propertyValue = PSObjectHelper.SmartToString(so, _expressionFactory, _enumerationLimit, formatErrorObject);

            if (formatErrorObject != null && formatErrorObject.exception != null)
            {
                // if we did no thave any errors in the expression evaluation
                // we might have errors in the formatting, if present
                _errorManager.LogStringFormatError(formatErrorObject);
                if (_errorManager.DisplayFormatErrorString)
                {
                    fpf.propertyValue = _errorManager.FormatErrorString;
                }
            }


            formatValueList.Add(fpf);
            formatValueList.Add(new FormatNewLine());
        }
예제 #35
0
        private void ExecuteFormatTokenList(TraversalInfo level,
                PSObject so, List<FormatToken> formatTokenList, List<FormatValue> formatValueList)
        {
            if (so == null)
            {
                throw PSTraceSource.NewArgumentNullException("so");
            }

            // guard against infinite loop
            if (level.Level == level.MaxDepth)
            {
                return;
            }

            FormatEntry fe = new FormatEntry();

            formatValueList.Add(fe);
            #region foreach loop
            foreach (FormatToken t in formatTokenList)
            {
                TextToken tt = t as TextToken;
                if (tt != null)
                {
                    FormatTextField ftf = new FormatTextField();
                    ftf.text = _db.displayResourceManagerCache.GetTextTokenString(tt);
                    fe.formatValueList.Add(ftf);
                    continue;
                }
                var newline = t as NewLineToken;
                if (newline != null)
                {
                    for (int i = 0; i < newline.count; i++)
                    {
                        fe.formatValueList.Add(new FormatNewLine());
                    }
                    continue;
                }
                FrameToken ft = t as FrameToken;
                if (ft != null)
                {
                    // instantiate a new entry and attach a frame info object
                    FormatEntry feFrame = new FormatEntry();
                    feFrame.frameInfo = new FrameInfo();

                    // add the frame info 
                    feFrame.frameInfo.firstLine = ft.frameInfoDefinition.firstLine;
                    feFrame.frameInfo.leftIndentation = ft.frameInfoDefinition.leftIndentation;
                    feFrame.frameInfo.rightIndentation = ft.frameInfoDefinition.rightIndentation;

                    // execute the list inside the frame
                    ExecuteFormatTokenList(level, so, ft.itemDefinition.formatTokenList, feFrame.formatValueList);

                    // add the frame computation results to the current format entry
                    fe.formatValueList.Add(feFrame);
                    continue;
                }
                #region CompoundPropertyToken
                CompoundPropertyToken cpt = t as CompoundPropertyToken;
                if (cpt != null)
                {
                    if (!EvaluateDisplayCondition(so, cpt.conditionToken))
                    {
                        // token not active, skip it
                        continue;
                    }

                    // get the property from the object
                    object val = null;

                    // if no expression was specified, just use the 
                    // object itself
                    if (cpt.expression == null || string.IsNullOrEmpty(cpt.expression.expressionValue))
                    {
                        val = so;
                    }
                    else
                    {
                        MshExpression ex = _expressionFactory.CreateFromExpressionToken(cpt.expression, _loadingInfo);
                        List<MshExpressionResult> resultList = ex.GetValues(so);
                        if (resultList.Count > 0)
                        {
                            val = resultList[0].Result;
                            if (resultList[0].Exception != null)
                            {
                                _errorManager.LogMshExpressionFailedResult(resultList[0], so);
                            }
                        }
                    }


                    // if the token is has a formatting string, it's a leaf node,
                    // do the formatting and we will be done
                    if (cpt.control == null || cpt.control is FieldControlBody)
                    {
                        // Since it is a leaf node we just consider it an empty string and go
                        // on with formatting
                        if (val == null)
                        {
                            val = "";
                        }
                        FieldFormattingDirective fieldFormattingDirective = null;
                        StringFormatError formatErrorObject = null;
                        if (cpt.control != null)
                        {
                            fieldFormattingDirective = ((FieldControlBody)cpt.control).fieldFormattingDirective;
                            if (fieldFormattingDirective != null && _errorManager.DisplayFormatErrorString)
                            {
                                formatErrorObject = new StringFormatError();
                            }
                        }

                        IEnumerable e = PSObjectHelper.GetEnumerable(val);
                        FormatPropertyField fpf = new FormatPropertyField();
                        if (cpt.enumerateCollection && e != null)
                        {
                            foreach (object x in e)
                            {
                                if (x == null)
                                {
                                    // nothing to process
                                    continue;
                                }
                                fpf = new FormatPropertyField();

                                fpf.propertyValue = PSObjectHelper.FormatField(fieldFormattingDirective, x, _enumerationLimit, formatErrorObject, _expressionFactory);
                                fe.formatValueList.Add(fpf);
                            }
                        }
                        else
                        {
                            fpf = new FormatPropertyField();

                            fpf.propertyValue = PSObjectHelper.FormatField(fieldFormattingDirective, val, _enumerationLimit, formatErrorObject, _expressionFactory);
                            fe.formatValueList.Add(fpf);
                        }
                        if (formatErrorObject != null && formatErrorObject.exception != null)
                        {
                            _errorManager.LogStringFormatError(formatErrorObject);
                            fpf.propertyValue = _errorManager.FormatErrorString;
                        }
                    }
                    else
                    {
                        // An empty result that is not a leaf node should not be expanded
                        if (val == null)
                        {
                            continue;
                        }
                        IEnumerable e = PSObjectHelper.GetEnumerable(val);
                        if (cpt.enumerateCollection && e != null)
                        {
                            foreach (object x in e)
                            {
                                if (x == null)
                                {
                                    // nothing to process
                                    continue;
                                }

                                // proceed with the recursion
                                ExecuteFormatControl(level.NextLevel, cpt.control, PSObject.AsPSObject(x), fe.formatValueList);
                            }
                        }
                        else
                        {
                            // proceed with the recursion
                            ExecuteFormatControl(level.NextLevel, cpt.control, PSObjectHelper.AsPSObject(val), fe.formatValueList);
                        }
                    }
                }
                #endregion CompoundPropertyToken
            }
            #endregion foreach loop
        }
예제 #36
0
 internal GroupStartData GenerateGroupStartData(PSObject firstObjectInGroup, int enumerationLimit)
 {
     GroupStartData data = new GroupStartData();
     if (this.groupingManager != null)
     {
         object currentGroupingKeyPropertyValue = this.groupingManager.CurrentGroupingKeyPropertyValue;
         if (currentGroupingKeyPropertyValue == AutomationNull.Value)
         {
             return data;
         }
         PSObject so = PSObjectHelper.AsPSObject(currentGroupingKeyPropertyValue);
         ControlBase control = null;
         TextToken tt = null;
         if (((this.dataBaseInfo.view != null) && (this.dataBaseInfo.view.groupBy != null)) && (this.dataBaseInfo.view.groupBy.startGroup != null))
         {
             control = this.dataBaseInfo.view.groupBy.startGroup.control;
             tt = this.dataBaseInfo.view.groupBy.startGroup.labelTextToken;
         }
         data.groupingEntry = new GroupingEntry();
         if (control == null)
         {
             string textTokenString;
             StringFormatError formatErrorObject = null;
             if (this.errorManager.DisplayFormatErrorString)
             {
                 formatErrorObject = new StringFormatError();
             }
             string formatErrorString = PSObjectHelper.SmartToString(so, this.expressionFactory, enumerationLimit, formatErrorObject);
             if ((formatErrorObject != null) && (formatErrorObject.exception != null))
             {
                 this.errorManager.LogStringFormatError(formatErrorObject);
                 if (this.errorManager.DisplayFormatErrorString)
                 {
                     formatErrorString = this.errorManager.FormatErrorString;
                 }
             }
             FormatEntry item = new FormatEntry();
             data.groupingEntry.formatValueList.Add(item);
             FormatTextField field = new FormatTextField();
             if (tt != null)
             {
                 textTokenString = this.dataBaseInfo.db.displayResourceManagerCache.GetTextTokenString(tt);
             }
             else
             {
                 textTokenString = this.groupingManager.GroupingKeyDisplayName;
             }
             field.text = StringUtil.Format(FormatAndOut_format_xxx.GroupStartDataIndentedAutoGeneratedLabel, textTokenString);
             item.formatValueList.Add(field);
             FormatPropertyField field2 = new FormatPropertyField {
                 propertyValue = formatErrorString
             };
             item.formatValueList.Add(field2);
             return data;
         }
         new ComplexControlGenerator(this.dataBaseInfo.db, this.dataBaseInfo.view.loadingInfo, this.expressionFactory, this.dataBaseInfo.view.formatControlDefinitionHolder.controlDefinitionList, this.ErrorManager, enumerationLimit, this.errorContext).GenerateFormatEntries(50, control, firstObjectInGroup, data.groupingEntry.formatValueList);
     }
     return data;
 }
예제 #37
0
 public ListViewField() : base("b761477330ce4fb2a665999879324d73")
 {
     this.formatPropertyField = new FormatPropertyField();
 }
예제 #38
0
 public ListViewField() : base("b761477330ce4fb2a665999879324d73")
 {
     this.formatPropertyField = new FormatPropertyField();
 }
예제 #39
0
 internal override void Deserialize(PSObject so, FormatObjectDeserializer deserializer)
 {
     base.Deserialize(so, deserializer);
     this.formatPropertyField = (FormatPropertyField)deserializer.DeserializeMandatoryMemberObject(so, "formatPropertyField");
 }
예제 #40
0
 private void ExecuteFormatTokenList(TraversalInfo level, PSObject so, List <FormatToken> formatTokenList, List <FormatValue> formatValueList)
 {
     if (so == null)
     {
         throw PSTraceSource.NewArgumentNullException("so");
     }
     if (level.Level != level.MaxDepth)
     {
         FormatEntry item = new FormatEntry();
         formatValueList.Add(item);
         foreach (FormatToken token in formatTokenList)
         {
             TextToken tt = token as TextToken;
             if (tt != null)
             {
                 FormatTextField field = new FormatTextField {
                     text = this.db.displayResourceManagerCache.GetTextTokenString(tt)
                 };
                 item.formatValueList.Add(field);
             }
             else if (token is NewLineToken)
             {
                 item.formatValueList.Add(new FormatNewLine());
             }
             else
             {
                 FrameToken token3 = token as FrameToken;
                 if (token3 != null)
                 {
                     FormatEntry entry2 = new FormatEntry {
                         frameInfo = new FrameInfo()
                     };
                     entry2.frameInfo.firstLine        = token3.frameInfoDefinition.firstLine;
                     entry2.frameInfo.leftIndentation  = token3.frameInfoDefinition.leftIndentation;
                     entry2.frameInfo.rightIndentation = token3.frameInfoDefinition.rightIndentation;
                     this.ExecuteFormatTokenList(level, so, token3.itemDefinition.formatTokenList, entry2.formatValueList);
                     item.formatValueList.Add(entry2);
                 }
                 else
                 {
                     CompoundPropertyToken token4 = token as CompoundPropertyToken;
                     if ((token4 != null) && this.EvaluateDisplayCondition(so, token4.conditionToken))
                     {
                         object result = null;
                         if ((token4.expression == null) || string.IsNullOrEmpty(token4.expression.expressionValue))
                         {
                             result = so;
                         }
                         else
                         {
                             List <MshExpressionResult> values = this.expressionFactory.CreateFromExpressionToken(token4.expression, this.loadingInfo).GetValues(so);
                             if (values.Count > 0)
                             {
                                 result = values[0].Result;
                                 if (values[0].Exception != null)
                                 {
                                     this.errorManager.LogMshExpressionFailedResult(values[0], so);
                                 }
                             }
                         }
                         if ((token4.control == null) || (token4.control is FieldControlBody))
                         {
                             if (result == null)
                             {
                                 result = "";
                             }
                             FieldFormattingDirective fieldFormattingDirective = null;
                             StringFormatError        formatErrorObject        = null;
                             if (token4.control != null)
                             {
                                 fieldFormattingDirective = ((FieldControlBody)token4.control).fieldFormattingDirective;
                                 if ((fieldFormattingDirective != null) && this.errorManager.DisplayFormatErrorString)
                                 {
                                     formatErrorObject = new StringFormatError();
                                 }
                             }
                             IEnumerable         enumerable = PSObjectHelper.GetEnumerable(result);
                             FormatPropertyField field2     = new FormatPropertyField();
                             if (token4.enumerateCollection && (enumerable != null))
                             {
                                 foreach (object obj3 in enumerable)
                                 {
                                     if (obj3 != null)
                                     {
                                         field2 = new FormatPropertyField {
                                             propertyValue = PSObjectHelper.FormatField(fieldFormattingDirective, obj3, this.enumerationLimit, formatErrorObject, this.expressionFactory)
                                         };
                                         item.formatValueList.Add(field2);
                                     }
                                 }
                             }
                             else
                             {
                                 field2 = new FormatPropertyField {
                                     propertyValue = PSObjectHelper.FormatField(fieldFormattingDirective, result, this.enumerationLimit, formatErrorObject, this.expressionFactory)
                                 };
                                 item.formatValueList.Add(field2);
                             }
                             if ((formatErrorObject != null) && (formatErrorObject.exception != null))
                             {
                                 this.errorManager.LogStringFormatError(formatErrorObject);
                                 field2.propertyValue = this.errorManager.FormatErrorString;
                             }
                         }
                         else if (result != null)
                         {
                             IEnumerable enumerable2 = PSObjectHelper.GetEnumerable(result);
                             if (token4.enumerateCollection && (enumerable2 != null))
                             {
                                 foreach (object obj4 in enumerable2)
                                 {
                                     if (obj4 != null)
                                     {
                                         this.ExecuteFormatControl(level.NextLevel, token4.control, PSObject.AsPSObject(obj4), item.formatValueList);
                                     }
                                 }
                             }
                             else
                             {
                                 this.ExecuteFormatControl(level.NextLevel, token4.control, PSObjectHelper.AsPSObject(result), item.formatValueList);
                             }
                         }
                     }
                 }
             }
         }
     }
 }
예제 #41
0
 private void DisplayRawObject(PSObject so, List<FormatValue> formatValueList)
 {
     FormatPropertyField item = new FormatPropertyField();
     StringFormatError formatErrorObject = null;
     if (this.errorManager.DisplayFormatErrorString)
     {
         formatErrorObject = new StringFormatError();
     }
     item.propertyValue = PSObjectHelper.SmartToString(so, this.expressionFactory, this.enumerationLimit, formatErrorObject);
     if ((formatErrorObject != null) && (formatErrorObject.exception != null))
     {
         this.errorManager.LogStringFormatError(formatErrorObject);
         if (this.errorManager.DisplayFormatErrorString)
         {
             item.propertyValue = this.errorManager.FormatErrorString;
         }
     }
     formatValueList.Add(item);
     formatValueList.Add(new FormatNewLine());
 }
예제 #42
0
 private void ExecuteFormatTokenList(TraversalInfo level, PSObject so, List<FormatToken> formatTokenList, List<FormatValue> formatValueList)
 {
     if (so == null)
     {
         throw PSTraceSource.NewArgumentNullException("so");
     }
     if (level.Level != level.MaxDepth)
     {
         FormatEntry item = new FormatEntry();
         formatValueList.Add(item);
         foreach (FormatToken token in formatTokenList)
         {
             TextToken tt = token as TextToken;
             if (tt != null)
             {
                 FormatTextField field = new FormatTextField {
                     text = this.db.displayResourceManagerCache.GetTextTokenString(tt)
                 };
                 item.formatValueList.Add(field);
             }
             else if (token is NewLineToken)
             {
                 item.formatValueList.Add(new FormatNewLine());
             }
             else
             {
                 FrameToken token3 = token as FrameToken;
                 if (token3 != null)
                 {
                     FormatEntry entry2 = new FormatEntry {
                         frameInfo = new FrameInfo()
                     };
                     entry2.frameInfo.firstLine = token3.frameInfoDefinition.firstLine;
                     entry2.frameInfo.leftIndentation = token3.frameInfoDefinition.leftIndentation;
                     entry2.frameInfo.rightIndentation = token3.frameInfoDefinition.rightIndentation;
                     this.ExecuteFormatTokenList(level, so, token3.itemDefinition.formatTokenList, entry2.formatValueList);
                     item.formatValueList.Add(entry2);
                 }
                 else
                 {
                     CompoundPropertyToken token4 = token as CompoundPropertyToken;
                     if ((token4 != null) && this.EvaluateDisplayCondition(so, token4.conditionToken))
                     {
                         object result = null;
                         if ((token4.expression == null) || string.IsNullOrEmpty(token4.expression.expressionValue))
                         {
                             result = so;
                         }
                         else
                         {
                             List<MshExpressionResult> values = this.expressionFactory.CreateFromExpressionToken(token4.expression, this.loadingInfo).GetValues(so);
                             if (values.Count > 0)
                             {
                                 result = values[0].Result;
                                 if (values[0].Exception != null)
                                 {
                                     this.errorManager.LogMshExpressionFailedResult(values[0], so);
                                 }
                             }
                         }
                         if ((token4.control == null) || (token4.control is FieldControlBody))
                         {
                             if (result == null)
                             {
                                 result = "";
                             }
                             FieldFormattingDirective fieldFormattingDirective = null;
                             StringFormatError formatErrorObject = null;
                             if (token4.control != null)
                             {
                                 fieldFormattingDirective = ((FieldControlBody) token4.control).fieldFormattingDirective;
                                 if ((fieldFormattingDirective != null) && this.errorManager.DisplayFormatErrorString)
                                 {
                                     formatErrorObject = new StringFormatError();
                                 }
                             }
                             IEnumerable enumerable = PSObjectHelper.GetEnumerable(result);
                             FormatPropertyField field2 = new FormatPropertyField();
                             if (token4.enumerateCollection && (enumerable != null))
                             {
                                 foreach (object obj3 in enumerable)
                                 {
                                     if (obj3 != null)
                                     {
                                         field2 = new FormatPropertyField {
                                             propertyValue = PSObjectHelper.FormatField(fieldFormattingDirective, obj3, this.enumerationLimit, formatErrorObject, this.expressionFactory)
                                         };
                                         item.formatValueList.Add(field2);
                                     }
                                 }
                             }
                             else
                             {
                                 field2 = new FormatPropertyField {
                                     propertyValue = PSObjectHelper.FormatField(fieldFormattingDirective, result, this.enumerationLimit, formatErrorObject, this.expressionFactory)
                                 };
                                 item.formatValueList.Add(field2);
                             }
                             if ((formatErrorObject != null) && (formatErrorObject.exception != null))
                             {
                                 this.errorManager.LogStringFormatError(formatErrorObject);
                                 field2.propertyValue = this.errorManager.FormatErrorString;
                             }
                         }
                         else if (result != null)
                         {
                             IEnumerable enumerable2 = PSObjectHelper.GetEnumerable(result);
                             if (token4.enumerateCollection && (enumerable2 != null))
                             {
                                 foreach (object obj4 in enumerable2)
                                 {
                                     if (obj4 != null)
                                     {
                                         this.ExecuteFormatControl(level.NextLevel, token4.control, PSObject.AsPSObject(obj4), item.formatValueList);
                                     }
                                 }
                             }
                             else
                             {
                                 this.ExecuteFormatControl(level.NextLevel, token4.control, PSObjectHelper.AsPSObject(result), item.formatValueList);
                             }
                         }
                     }
                 }
             }
         }
     }
 }
예제 #43
0
 private TableRowEntry GenerateTableRowEntryFromFromProperties(PSObject so, int enumerationLimit)
 {
     TableRowEntry entry = new TableRowEntry();
     for (int i = 0; i < base.activeAssociationList.Count; i++)
     {
         FormatPropertyField item = new FormatPropertyField();
         FieldFormattingDirective directive = null;
         if (base.activeAssociationList[i].OriginatingParameter != null)
         {
             directive = base.activeAssociationList[i].OriginatingParameter.GetEntry("formatString") as FieldFormattingDirective;
         }
         item.propertyValue = base.GetExpressionDisplayValue(so, enumerationLimit, base.activeAssociationList[i].ResolvedExpression, directive);
         entry.formatPropertyFieldList.Add(item);
     }
     return entry;
 }