Beispiel #1
0
        protected string GetExpressionDisplayValue(PSObject so, int enumerationLimit, MshExpression ex, FieldFormattingDirective directive, out MshExpressionResult expressionResult)
        {
            StringFormatError formatErrorObject = null;

            if (this.errorManager.DisplayFormatErrorString)
            {
                formatErrorObject = new StringFormatError();
            }
            string errorString = PSObjectHelper.GetExpressionDisplayValue(so, enumerationLimit, ex, directive, formatErrorObject, this.expressionFactory, out expressionResult);

            if (expressionResult != null)
            {
                if (expressionResult.Exception != null)
                {
                    this.errorManager.LogMshExpressionFailedResult(expressionResult, so);
                    if (this.errorManager.DisplayErrorStrings)
                    {
                        errorString = this.errorManager.ErrorString;
                    }
                    return(errorString);
                }
                if ((formatErrorObject != null) && (formatErrorObject.exception != null))
                {
                    this.errorManager.LogStringFormatError(formatErrorObject);
                    if (this.errorManager.DisplayErrorStrings)
                    {
                        errorString = this.errorManager.FormatErrorString;
                    }
                }
            }
            return(errorString);
        }
        protected string GetExpressionDisplayValue(PSObject so, int enumerationLimit, PSPropertyExpression ex,
                                                   FieldFormattingDirective directive, out PSPropertyExpressionResult expressionResult)
        {
            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 retVal = PSObjectHelper.GetExpressionDisplayValue(so, enumerationLimit, ex,
                                                                     directive, formatErrorObject, expressionFactory, out expressionResult);

            if (expressionResult != null)
            {
                // we obtained a result, check if there is an error
                if (expressionResult.Exception != null)
                {
                    _errorManager.LogPSPropertyExpressionFailedResult(expressionResult, so);
                    if (_errorManager.DisplayErrorStrings)
                    {
                        retVal = _errorManager.ErrorString;
                    }
                }
                else 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.DisplayErrorStrings)
                    {
                        retVal = _errorManager.FormatErrorString;
                    }
                }
            }

            return(retVal);
        }