src/Misc/EFTools/XmlCore/Common/Diagnostics/EFToolsTraceUtils.cs
/// <summary>
///     Formats a dictionary of key-value pairs into a string, calling the appropriate converter delegate
///     on each key and value to get a string
/// </summary>
Formats a dictionary of key-value pairs into a string, calling the appropriate converter delegate
on each key and value to get a string
Formats a dictionary of key - value pairs into a string calling the appropriate converter delegate on each key and value to get a string
internal static string FormatDictionary<T, U>(
            IDictionary<T, U> dictionary, Func<T, string> keyConverter, Func<U, string> valueConverter, bool newlineForEach = false,
            string newlineIndent = DefaultIndent, string listStart = DefaultListStart, string listEnd = DefaultListEnd,
            string listSeparator = DefaultListSeparator,
            string dictionaryStart = DefaultDictionaryStart, string dictionaryEnd = DefaultDictionaryEnd,
            string mapsTo = DefaultDictionaryMapsTo)
        {
            var sb = new StringBuilder(listStart);
            var first = true;
            foreach (var pair in dictionary)
            {
                if (first)
                {
                    first = false;
                }
                else
                {
                    if (newlineForEach)
                    {
                        sb.AppendLine();
                        sb.Append(newlineIndent);
                    }
                    else
                    {
                        sb.Append(listSeparator);
                    }
                }
                sb.Append(dictionaryStart + keyConverter(pair.Key) + mapsTo + valueConverter(pair.Value) + dictionaryEnd);
            }
            sb.AppendLine(listEnd);
            return sb.ToString();
        }
internal static string FormatDictionary < T , U > ( IDictionary < T , U > dictionary , Func < T , string > keyConverter , Func < U , string > valueConverter , bool newlineForEach = false , string newlineIndent = DefaultIndent , string listStart = DefaultListStart , string listEnd = DefaultListEnd , string listSeparator = DefaultListSeparator , string dictionaryStart = DefaultDictionaryStart , string dictionaryEnd = DefaultDictionaryEnd , string mapsTo = DefaultDictionaryMapsTo ) { var sb = new StringBuilder ( listStart ) ; var first = true ; foreach ( var pair in dictionary ) { if ( first ) { first = false ; } else { if ( newlineForEach ) { sb . AppendLine ( ) ; sb . Append ( newlineIndent ) ; } else { sb . Append ( listSeparator ) ; } } sb . Append ( dictionaryStart + keyConverter ( pair . Key ) + mapsTo + valueConverter ( pair . Value ) + dictionaryEnd ) ; } sb . AppendLine ( listEnd ) ; return sb . ToString ( ) ; }
Formats a dictionary of key-value pairs into a string, calling the appropriate converter delegate
on each key and value to get a string
Formats a dictionary of key - value pairs into a string calling the appropriate converter delegate on each key and value to get a string
dictionary
IDictionary<T, U>
keyConverter
Func<T, string>
valueConverter
Func<U, string>
newlineForEach
bool
newlineIndent
string
listStart
string
listEnd
string
listSeparator
string
dictionaryStart
string
dictionaryEnd
string
mapsTo
string