forked from ServiceStack/ServiceStack.Text
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMapExtensions.cs
More file actions
39 lines (35 loc) · 953 Bytes
/
MapExtensions.cs
File metadata and controls
39 lines (35 loc) · 953 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//
// https://github.com/ServiceStack/ServiceStack.Text
// ServiceStack.Text: .NET C# POCO JSON, JSV and CSV Text Serializers.
//
// Authors:
// Demis Bellot (demis.bellot@gmail.com)
//
// Copyright 2012 ServiceStack Ltd.
//
// Licensed under the same terms of ServiceStack: new BSD license.
//
using System.Collections.Generic;
using System.Text;
using ServiceStack.Text.Common;
namespace ServiceStack.Text
{
public static class MapExtensions
{
public static string Join<K, V>(this Dictionary<K, V> values)
{
return Join(values, JsWriter.ItemSeperatorString, JsWriter.MapKeySeperatorString);
}
public static string Join<K, V>(this Dictionary<K, V> values, string itemSeperator, string keySeperator)
{
var sb = new StringBuilder();
foreach (var entry in values)
{
if (sb.Length > 0)
sb.Append(itemSeperator);
sb.Append(entry.Key).Append(keySeperator).Append(entry.Value);
}
return sb.ToString();
}
}
}