Resource/Extensions.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.Threading.Tasks;
6 
7 namespace Microsoft.Bot.Builder.Resource
8 {
9  #region Documentation
10  #endregion
12  public static partial class Extensions
13  {
15  public const string SEPARATOR = ";";
16 
18  public const string ESCAPED_SEPARATOR = "__semi";
19 
20  #region Documentation
21  #endregion
27  public static string MakeList(IEnumerable<string> elements, string separator = SEPARATOR, string escape = ESCAPED_SEPARATOR)
28  {
29  return string.Join(separator, from elt in elements select elt.Replace(separator, escape));
30  }
31 
32  #region Documentation
33  #endregion
37  public static string MakeList(params string[] elements)
38  {
39  return MakeList(elements.AsEnumerable());
40  }
41 
42  #region Documentation
43  #endregion
49  public static string[] SplitList(this string str, string separator = SEPARATOR, string escape = ESCAPED_SEPARATOR)
50  {
51  var elements = str.Split(separator[0]);
52  return (from elt in elements select elt.Replace(escape, separator)).ToArray();
53  }
54  }
55 }
static string MakeList(IEnumerable< string > elements, string separator=SEPARATOR, string escape=ESCAPED_SEPARATOR)
Makes a string list.
static string[] SplitList(this string str, string separator=SEPARATOR, string escape=ESCAPED_SEPARATOR)
A string extension method that splits a list.
static string MakeList(params string[] elements)
Makes a list from parameters.