Microsoft.Bot.Builder.Azure/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.Azure
8 {
9  internal static class StringExtensions
10  {
11  private static readonly Dictionary<string, string> _DefaultReplacementsForCharactersDisallowedByAzure = new Dictionary<string, string>() { { "/", "|s|" }, { @"\", "|b|" }, { "#", "|h|" }, { "?", "|q|" } };
12 
16  internal static string SanitizeForAzureKeys(this string input, Dictionary<string, string> replacements = null)
17  {
18  var repmap = replacements ?? _DefaultReplacementsForCharactersDisallowedByAzure;
19  return input.Trim().Replace("/", repmap["/"]).Replace(@"\", repmap[@"\"]).Replace("#", repmap["#"]).Replace("?", repmap["?"]);
20  }
21 
22  }
23 }