/// <summary> /// Loads configs from json files in blob storage to Configurations dictionary /// </summary> private async Task LoadConfigs(ReaderWriterLockSlim ConfigurationsLock) { Dictionary <string, JToken> newConfigurations = new Dictionary <string, JToken>(); foreach (var file in configurationFilesPathes) { var content = await blobStorageProvider.GetFileContentsAsync(containerName, file); if (content != null) { var configs = JsonConvert.DeserializeObject <Dictionary <string, JToken> >(content); foreach (var config in configs) { if (!newConfigurations.ContainsKey(config.Key)) { newConfigurations.Add(config.Key, config.Value); } else { System.Diagnostics.Trace.TraceWarning($"Failed adding key {config.Key} from file {file}. It already exists."); } } } } UpdateConfigs(newConfigurations, ConfigurationsLock); }
public BlobStorageMessageProvider(IBlobStorageProvider blobStorageMessageProvider, string containerName, IEnumerable <string> messageFilesPathes) { messages = new Dictionary <string, string>(); blobStorageProvider = blobStorageMessageProvider; foreach (var file in messageFilesPathes) { var contents = blobStorageProvider.GetFileContentsAsync(containerName, file).GetAwaiter().GetResult(); var fileDictionary = JsonConvert.DeserializeObject <Dictionary <string, string> >(contents); foreach (var value in fileDictionary) { if (messages.ContainsKey(value.Key)) { Trace.TraceWarning($"Messages dictionary has duplicate key {value.Key}"); messages[value.Key] = value.Value; } else { messages.Add(value.Key, value.Value); } } } }