Ejemplo n.º 1
0
        /// <summary>
        /// Converts the provided PSObject to a string preserving PowerShell formatting.
        /// </summary>
        /// <param name="liveObject">PSObject to be converted to a string.</param>
        internal string ConvertToString(PSObject liveObject)
        {
            StringFormatError formatErrorObject = new StringFormatError();
            string            smartToString     = PSObjectHelper.SmartToString(liveObject,
                                                                               _expressionFactory,
                                                                               InnerFormatShapeCommand.FormatEnumerationLimit(),
                                                                               formatErrorObject);

            if (formatErrorObject.exception != null)
            {
                // There was a formatting error that should be sent to the console.
                this.WriteError(
                    new ErrorRecord(
                        formatErrorObject.exception,
                        "ErrorFormattingType",
                        ErrorCategory.InvalidResult,
                        liveObject)
                    );
            }
            return(smartToString);
        }
Ejemplo n.º 2
0
        internal string ConvertToString(PSObject liveObject)
        {
            StringFormatError formatErrorObject = new StringFormatError();
            string            str = PSObjectHelper.SmartToString(liveObject, this.expressionFactory, InnerFormatShapeCommand.FormatEnumerationLimit(), formatErrorObject);

            if (formatErrorObject.exception != null)
            {
                base.WriteError(new ErrorRecord(formatErrorObject.exception, "ErrorFormattingType", ErrorCategory.InvalidResult, liveObject));
            }
            return(str);
        }