Exemplo n.º 1
0
        private static string GetObjectName(object x, MshExpressionFactory expressionFactory)
        {
            if ((x is PSObject) && ((LanguagePrimitives.IsBoolOrSwitchParameterType(((PSObject)x).BaseObject.GetType()) || LanguagePrimitives.IsNumeric(Type.GetTypeCode(((PSObject)x).BaseObject.GetType()))) || LanguagePrimitives.IsNull(x)))
            {
                return(x.ToString());
            }
            if (x == null)
            {
                return("$null");
            }
            MethodInfo info = x.GetType().GetMethod("ToString", Type.EmptyTypes, null);

            if (info.DeclaringType.Equals(info.ReflectedType))
            {
                return(AsPSObject(x).ToString());
            }
            MshExpressionResult displayName = GetDisplayName(AsPSObject(x), expressionFactory);

            if ((displayName != null) && (displayName.Exception == null))
            {
                return(AsPSObject(displayName.Result).ToString());
            }
            string str = AsPSObject(x).ToString();

            if (str == string.Empty)
            {
                object obj2 = PSObject.Base(x);
                if (obj2 != null)
                {
                    str = obj2.ToString();
                }
            }
            return(str);
        }
Exemplo n.º 2
0
        private static string GetSmartToStringDisplayName(
            object x,
            MshExpressionFactory expressionFactory)
        {
            MshExpressionResult displayName = PSObjectHelper.GetDisplayName(PSObjectHelper.AsPSObject(x), expressionFactory);

            return(displayName != null && displayName.Exception == null?PSObjectHelper.AsPSObject(displayName.Result).ToString() : PSObjectHelper.AsPSObject(x).ToString());
        }
Exemplo n.º 3
0
        private static string GetSmartToStringDisplayName(object x, MshExpressionFactory expressionFactory)
        {
            MshExpressionResult displayName = GetDisplayName(AsPSObject(x), expressionFactory);

            if ((displayName != null) && (displayName.Exception == null))
            {
                return(AsPSObject(displayName.Result).ToString());
            }
            return(AsPSObject(x).ToString());
        }
Exemplo n.º 4
0
 internal void LogMshExpressionFailedResult(MshExpressionResult result, object sourceObject)
 {
     if (this.formatErrorPolicy.ShowErrorsAsMessages)
     {
         MshExpressionError item = new MshExpressionError {
             result = result,
             sourceObject = sourceObject
         };
         this.formattingErrorList.Add(item);
     }
 }
Exemplo n.º 5
0
 internal void LogMshExpressionFailedResult(MshExpressionResult result, object sourceObject)
 {
     if (this.formatErrorPolicy.ShowErrorsAsMessages)
     {
         MshExpressionError item = new MshExpressionError {
             result       = result,
             sourceObject = sourceObject
         };
         this.formattingErrorList.Add(item);
     }
 }
Exemplo n.º 6
0
        /// <summary>
        /// log a failed evaluation of an MshExpression
        /// </summary>
        /// <param name="result">MshExpressionResult containing the failed evaluation data</param>
        /// <param name="sourceObject">object used to evaluate the MshExpression</param>
        internal void LogMshExpressionFailedResult(MshExpressionResult result, object sourceObject)
        {
            if (!_formatErrorPolicy.ShowErrorsAsMessages)
            {
                return;
            }
            MshExpressionError error = new MshExpressionError();

            error.result       = result;
            error.sourceObject = sourceObject;
            _formattingErrorList.Add(error);
        }
Exemplo n.º 7
0
        private static string GetSmartToStringDisplayName(object x, MshExpressionFactory expressionFactory)
        {
            MshExpressionResult r = PSObjectHelper.GetDisplayName(PSObjectHelper.AsPSObject(x), expressionFactory);

            if ((r != null) && (r.Exception == null))
            {
                return(PSObjectHelper.AsPSObject(r.Result).ToString());
            }
            else
            {
                return(PSObjectHelper.AsPSObject(x).ToString());
            }
        }
Exemplo n.º 8
0
 internal static bool Evaluate(PSObject obj, MshExpression ex, out MshExpressionResult expressionResult)
 {
     expressionResult = null;
     List<MshExpressionResult> res = ex.GetValues(obj);
     if (res.Count == 0)
         return false;
     if (res[0].Exception != null)
     {
         expressionResult = res[0];
         return false;
     }
     return LanguagePrimitives.IsTrue(res[0].Result);
 }
Exemplo n.º 9
0
        private static string GetObjectName(object x, MshExpressionFactory expressionFactory)
        {
            string objName;

            // check if the underlying object is of primitive type
            // if so just return its value
            if (x is PSObject &&
                (LanguagePrimitives.IsBoolOrSwitchParameterType((((PSObject)x).BaseObject).GetType()) ||
                 LanguagePrimitives.IsNumeric(((((PSObject)x).BaseObject).GetType()).GetTypeCode()) ||
                 LanguagePrimitives.IsNull(x)))
            {
                objName = x.ToString();
            }
            else if (x == null)
            {
                // use PowerShell's $null variable to indicate that the value is null...
                objName = "$null";
            }
            else
            {
                MethodInfo toStringMethod = x.GetType().GetMethod("ToString", PSTypeExtensions.EmptyTypes);
                // TODO:CORECLR double check with CORE CLR that x.GetType() == toStringMethod.ReflectedType
                // Check if the given object "x" implements "toString" method. Do that by comparing "DeclaringType" which 'Gets the class that declares this member' and the object type
                if (toStringMethod.DeclaringType == x.GetType())
                {
                    objName = PSObjectHelper.AsPSObject(x).ToString();
                }
                else
                {
                    MshExpressionResult r = PSObjectHelper.GetDisplayName(PSObjectHelper.AsPSObject(x), expressionFactory);
                    if ((r != null) && (r.Exception == null))
                    {
                        objName = PSObjectHelper.AsPSObject(r.Result).ToString();;
                    }
                    else
                    {
                        objName = PSObjectHelper.AsPSObject(x).ToString();
                        if (objName == string.Empty)
                        {
                            var baseObj = PSObject.Base(x);
                            if (baseObj != null)
                            {
                                objName = baseObj.ToString();
                            }
                        }
                    }
                }
            }

            return(objName);
        }
Exemplo n.º 10
0
        internal static bool Evaluate(PSObject obj, MshExpression ex, out MshExpressionResult expressionResult)
        {
            expressionResult = null;
            List <MshExpressionResult> res = ex.GetValues(obj);

            if (res.Count == 0)
            {
                return(false);
            }
            if (res[0].Exception != null)
            {
                expressionResult = res[0];
                return(false);
            }
            return(LanguagePrimitives.IsTrue(res[0].Result));
        }
Exemplo n.º 11
0
        internal List <MshExpressionResult> GetValues(PSObject target, bool expand, bool eatExceptions)
        {
            List <MshExpressionResult> list = new List <MshExpressionResult>();

            if (this._script != null)
            {
                MshExpressionResult item = new MshExpression(this._script).GetValue(target, eatExceptions);
                list.Add(item);
                return(list);
            }
            foreach (MshExpression expression2 in this.ResolveNames(target, expand))
            {
                MshExpressionResult result2 = expression2.GetValue(target, eatExceptions);
                list.Add(result2);
            }
            return(list);
        }
Exemplo n.º 12
0
        internal static string GetExpressionDisplayValue(
            PSObject so,
            int enumerationLimit,
            MshExpression ex,
            FieldFormattingDirective directive,
            StringFormatError formatErrorObject,
            MshExpressionFactory expressionFactory,
            out MshExpressionResult result)
        {
            result = (MshExpressionResult)null;
            List <MshExpressionResult> values = ex.GetValues(so);

            if (values.Count == 0)
            {
                return("");
            }
            result = values[0];
            return(result.Exception != null ? "" : PSObjectHelper.FormatField(directive, result.Result, enumerationLimit, formatErrorObject, expressionFactory));
        }
Exemplo n.º 13
0
        internal List <MshExpressionResult> GetValues(PSObject target, bool expand, bool eatExceptions)
        {
            List <MshExpressionResult> retVal = new List <MshExpressionResult>();

            // process the script case
            if (Script != null)
            {
                MshExpression       scriptExpression = new MshExpression(Script);
                MshExpressionResult r = scriptExpression.GetValue(target, eatExceptions);
                retVal.Add(r);
                return(retVal);
            }

            // process the expression
            List <MshExpression> resolvedExpressionList = this.ResolveNames(target, expand);

            foreach (MshExpression re in resolvedExpressionList)
            {
                MshExpressionResult r = re.GetValue(target, eatExceptions);
                retVal.Add(r);
            }

            return(retVal);
        }
Exemplo n.º 14
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;
 }
Exemplo n.º 15
0
        /// <summary>
        /// helper to retrieve the value of an MshExpression and to format it
        /// </summary>
        /// <param name="so">shell object to process</param>
        /// <param name="enumerationLimit">limit on IEnumerable enumeration</param>
        /// <param name="ex">expression to use for retrieval</param>
        /// <param name="directive">format directive to use for formatting</param>
        /// <param name="formatErrorObject"></param>
        /// <param name="expressionFactory">expression factory to create MshExpression</param>
        /// <param name="result"> not null if an error condition arose</param>
        /// <returns>formatted string</returns>
        internal static string GetExpressionDisplayValue(
            PSObject so,
            int enumerationLimit,
            MshExpression ex,
            FieldFormattingDirective directive,
            StringFormatError formatErrorObject,
            MshExpressionFactory expressionFactory,
            out MshExpressionResult result)
        {
            result = null;
            List <MshExpressionResult> resList = ex.GetValues(so);

            if (resList.Count == 0)
            {
                return(string.Empty);
            }

            result = resList[0];
            if (result.Exception != null)
            {
                return(string.Empty);
            }
            return(PSObjectHelper.FormatField(directive, result.Result, enumerationLimit, formatErrorObject, expressionFactory));
        }
Exemplo n.º 16
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;
 }
Exemplo n.º 17
0
 /// <summary>
 /// log a failed evaluation of an MshExpression
 /// </summary>
 /// <param name="result">MshExpressionResult containing the failed evaluation data</param>
 /// <param name="sourceObject">object used to evaluate the MshExpression</param>
 internal void LogMshExpressionFailedResult(MshExpressionResult result, object sourceObject)
 {
     if (!_formatErrorPolicy.ShowErrorsAsMessages)
         return;
     MshExpressionError error = new MshExpressionError();
     error.result = result;
     error.sourceObject = sourceObject;
     _formattingErrorList.Add(error);
 }
Exemplo n.º 18
0
 private void ProcessActiveAssociationList(PSObject so, TraversalInfo currentLevel, List <MshResolvedExpressionParameterAssociation> activeAssociationList, List <FormatValue> formatValueList)
 {
     foreach (MshResolvedExpressionParameterAssociation association in activeAssociationList)
     {
         FormatTextField item = new FormatTextField {
             text = association.ResolvedExpression.ToString() + " = "
         };
         formatValueList.Add(item);
         List <MshExpressionResult> values = association.ResolvedExpression.GetValues(so);
         object errorString = null;
         if (values.Count >= 1)
         {
             MshExpressionResult result = values[0];
             if (result.Exception != null)
             {
                 this.errorManager.LogMshExpressionFailedResult(result, so);
                 if (this.errorManager.DisplayErrorStrings)
                 {
                     errorString = this.errorManager.ErrorString;
                 }
                 else
                 {
                     errorString = "";
                 }
             }
             else
             {
                 errorString = result.Result;
             }
         }
         TraversalInfo level = currentLevel;
         if (association.OriginatingParameter != null)
         {
             object entry = association.OriginatingParameter.GetEntry("depth");
             if (entry != AutomationNull.Value)
             {
                 int maxDepth = (int)entry;
                 level = new TraversalInfo(currentLevel.Level, maxDepth);
             }
         }
         IEnumerable e = null;
         if ((errorString != null) || (level.Level >= level.MaxDepth))
         {
             e = PSObjectHelper.GetEnumerable(errorString);
         }
         if (e != null)
         {
             formatValueList.Add(new FormatNewLine());
             this.DisplayEnumeration(e, level.NextLevel, this.AddIndentationLevel(formatValueList));
         }
         else if ((errorString == null) || TreatAsLeafNode(errorString, level))
         {
             this.DisplayLeaf(errorString, formatValueList);
         }
         else
         {
             formatValueList.Add(new FormatNewLine());
             this.DisplayObject(PSObject.AsPSObject(errorString), level.NextLevel, null, this.AddIndentationLevel(formatValueList));
         }
     }
 }
Exemplo n.º 19
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);
        }
Exemplo n.º 20
0
        protected string GetExpressionDisplayValue(PSObject so, int enumerationLimit, MshExpression ex,
                    FieldFormattingDirective directive, out MshExpressionResult 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.LogMshExpressionFailedResult(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;
        }
        private void ProcessActiveAssociationList(PSObject so,
                                                  TraversalInfo currentLevel,
                                                  List <MshResolvedExpressionParameterAssociation> activeAssociationList,
                                                  List <FormatValue> formatValueList)
        {
            foreach (MshResolvedExpressionParameterAssociation a in activeAssociationList)
            {
                FormatTextField ftf = new FormatTextField();

                ftf.text = a.ResolvedExpression.ToString() + " = ";
                formatValueList.Add(ftf);

                // compute the value of the entry
                List <MshExpressionResult> resList = a.ResolvedExpression.GetValues(so);
                object val = null;
                if (resList.Count >= 1)
                {
                    MshExpressionResult result = resList[0];
                    if (result.Exception != null)
                    {
                        _errorManager.LogMshExpressionFailedResult(result, so);
                        if (_errorManager.DisplayErrorStrings)
                        {
                            val = _errorManager.ErrorString;
                        }
                        else
                        {
                            val = string.Empty;
                        }
                    }
                    else
                    {
                        val = result.Result;
                    }
                }

                // extract the optional max depth
                TraversalInfo level = currentLevel;
                if (a.OriginatingParameter != null)
                {
                    object maxDepthKey = a.OriginatingParameter.GetEntry(FormatParameterDefinitionKeys.DepthEntryKey);
                    if (maxDepthKey != AutomationNull.Value)
                    {
                        int parameterMaxDept = (int)maxDepthKey;
                        level = new TraversalInfo(currentLevel.Level, parameterMaxDept);
                    }
                }

                IEnumerable e = null;
                if (val != null || (level.Level >= level.MaxDepth))
                {
                    e = PSObjectHelper.GetEnumerable(val);
                }

                if (e != null)
                {
                    formatValueList.Add(new FormatNewLine());
                    DisplayEnumeration(e, level.NextLevel, AddIndentationLevel(formatValueList));
                }
                else if (val == null || TreatAsLeafNode(val, level))
                {
                    DisplayLeaf(val, formatValueList);
                }
                else
                {
                    formatValueList.Add(new FormatNewLine());

                    // we need to go one more level down
                    DisplayObject(PSObject.AsPSObject(val), level.NextLevel, null,
                                  AddIndentationLevel(formatValueList));
                }
            } // for each
        }
Exemplo n.º 22
0
        protected string GetExpressionDisplayValue(PSObject so, int enumerationLimit, MshExpression ex,
                                                   FieldFormattingDirective directive, out MshExpressionResult 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.LogMshExpressionFailedResult(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);
        }
Exemplo n.º 23
0
        protected FormatPropertyField GenerateFormatPropertyField(List <FormatToken> formatTokenList, PSObject so, int enumerationLimit, out MshExpressionResult result)
        {
            result = null;
            FormatPropertyField fpf = new FormatPropertyField();

            if (formatTokenList.Count != 0)
            {
                FormatToken        token = formatTokenList[0];
                FieldPropertyToken fpt   = token as FieldPropertyToken;
                if (fpt != null)
                {
                    MshExpression 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 = "";
            }
            return(fpf);
        }
Exemplo n.º 24
0
        /// <summary>
        /// helper to retrieve the value of an MshExpression and to format it
        /// </summary>
        /// <param name="so">shell object to process</param>
        /// <param name="enumerationLimit">limit on IEnumerable enumeration</param>
        /// <param name="ex">expression to use for retrieval</param>
        /// <param name="directive">format directive to use for formatting</param>
        /// <param name="formatErrorObject"></param>
        /// <param name="expressionFactory">expression factory to create MshExpression</param>
        /// <param name="result"> not null if an error condition arose</param>
        /// <returns>formatted string</returns>
        internal static string GetExpressionDisplayValue(
            PSObject so,
            int enumerationLimit,
            MshExpression ex,
            FieldFormattingDirective directive,
            StringFormatError formatErrorObject,
            MshExpressionFactory expressionFactory,
            out MshExpressionResult result)
        {
            result = null;
            List<MshExpressionResult> resList = ex.GetValues(so);

            if (resList.Count == 0)
            {
                return "";
            }

            result = resList[0];
            if (result.Exception != null)
            {
                return "";
            }
            return PSObjectHelper.FormatField(directive, result.Result, enumerationLimit, formatErrorObject, expressionFactory);
        }
Exemplo n.º 25
0
 internal static string SmartToString(
     PSObject so,
     MshExpressionFactory expressionFactory,
     int enumerationLimit,
     StringFormatError formatErrorObject)
 {
     if (so == null)
     {
         return("");
     }
     try
     {
         IEnumerable enumerable = PSObjectHelper.GetEnumerable((object)so);
         if (enumerable == null)
         {
             return(so.ToString());
         }
         StringBuilder stringBuilder = new StringBuilder();
         stringBuilder.Append("{");
         bool flag = true;
         int  num  = 0;
         if (enumerable.GetEnumerator() != null)
         {
             foreach (object obj in enumerable)
             {
                 if (LocalPipeline.GetExecutionContextFromTLS().CurrentPipelineStopping)
                 {
                     throw new PipelineStoppedException();
                 }
                 if (enumerationLimit >= 0)
                 {
                     if (num == enumerationLimit)
                     {
                         stringBuilder.Append("...");
                         break;
                     }
                     ++num;
                 }
                 string str;
                 if (obj is PSObject && (LanguagePrimitives.IsBoolOrSwitchParameterType(((PSObject)obj).BaseObject.GetType()) || LanguagePrimitives.IsNumeric(Type.GetTypeCode(((PSObject)obj).BaseObject.GetType())) || LanguagePrimitives.IsNull(obj)))
                 {
                     str = obj.ToString();
                 }
                 else if (obj == null)
                 {
                     str = "$null";
                 }
                 else
                 {
                     MethodInfo method = obj.GetType().GetMethod("ToString", Type.EmptyTypes, (ParameterModifier[])null);
                     if (method.DeclaringType.Equals(method.ReflectedType))
                     {
                         str = PSObjectHelper.AsPSObject(obj).ToString();
                     }
                     else
                     {
                         MshExpressionResult displayName = PSObjectHelper.GetDisplayName(PSObjectHelper.AsPSObject(obj), expressionFactory);
                         str = displayName == null || displayName.Exception != null?PSObjectHelper.AsPSObject(obj).ToString() : PSObjectHelper.AsPSObject(displayName.Result).ToString();
                     }
                 }
                 if (!flag)
                 {
                     stringBuilder.Append(", ");
                 }
                 stringBuilder.Append(str);
                 if (flag)
                 {
                     flag = false;
                 }
             }
         }
         stringBuilder.Append("}");
         return(stringBuilder.ToString());
     }
     catch (ExtendedTypeSystemException ex)
     {
         if (formatErrorObject != null)
         {
             formatErrorObject.sourceObject = (object)so;
             formatErrorObject.exception    = (Exception)ex;
         }
         return("");
     }
 }