c# - Can I preserve Dictionary<string, string> key casing when storing in Bot Framework ConversationData? -


i have use case want store list<string, string> in bot framework's context.conversationdata (using azure table storage backend, via tablebotdatastore class). however, when so, upon retrieving stored list, casing of keys has changed.

for example, store list this:

idictionary<string, string> dict = new dictionary<string, string>(); dict.add("mykey", "n"); context.conversationdata.setvalue("mydictionary", dict); 

i try retrieve data in later dialog:

idictionary<string, string> dict; context.conversationdata.trygetvalue("mydictionary", out dict) var found = dict.containskey("mykey"); 

however, in example, found set false, dict contains key/value pair {"mykey", "n"} after deserialization. can work around lowercasing keys beforehand, there way can configure serialization/deserialization of conversationdata preserve casing?

i able resolve issue changing way json formatter configured. updated register method in webapiconfig.cs, follows:

public static void register(httpconfiguration config) {     // json settings     config.formatters.jsonformatter.serializersettings.nullvaluehandling = nullvaluehandling.ignore;     config.formatters.jsonformatter.serializersettings.contractresolver = new camelcasepropertynamescontractresolver { namingstrategy = new camelcasenamingstrategy { processdictionarykeys = false } };     config.formatters.jsonformatter.serializersettings.formatting = formatting.indented;     jsonconvert.defaultsettings = () => new jsonserializersettings()     {         contractresolver = new camelcasepropertynamescontractresolver { namingstrategy = new camelcasenamingstrategy { processdictionarykeys = false } },         formatting = formatting.indented,         nullvaluehandling = nullvaluehandling.ignore,     };  //... } 

now, camelcasepropertynamescontractresolver preserve casing of dictionary keys when storing , retrieving user's conversationdata azure table storage.


Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -