public AggregatedConfiguration ParseConfiguration(string jsonConfiguration, string[] roles = null, string userName = null)
 {
     var json = new JsonSerializer();
     json.MissingMemberHandling = MissingMemberHandling.Ignore;
     var config = json.Deserialize<ConfigurationContainer>(new JsonTextReader(new StringReader(jsonConfiguration)));
     var result = new AggregatedConfiguration();
     result.Entries = new List<ConfigurationEntry>();
     foreach (var entry in config.Global)
     {
         result.Entries.Add(entry);
     }
     if (roles != null && config.Roles != null)
     {
         foreach (var role in roles)
         {
             if (config.Roles.Any(r => r.Role.ToLower() == role.ToLower()))
             {
                 foreach (var roleConfig in config.Roles.FirstOrDefault(r=>r.Role.ToLower() == role.ToLower()).Entries)
                 {
                     var existingEntry =
                         result.Entries.FirstOrDefault(e => e.Key.ToLower() == roleConfig.Key.ToLower());
                     if (existingEntry!=null)
                     {
                         result.Entries.Remove(existingEntry);
                     }
                     result.Entries.Add(roleConfig);
                 }
             }
         }
     }
     if (userName != null && config.Users != null)
     {
         if (config.Users.Any(r => r.User.ToLower() == userName.ToLower()))
         {
             foreach (
                 var userConfig in
                     config.Users.FirstOrDefault(r => r.User.ToLower() == userName.ToLower()).Entries)
             {
                 var existingEntry =
                     result.Entries.FirstOrDefault(e => e.Key.ToLower() == userConfig.Key.ToLower());
                 if (existingEntry != null)
                 {
                     result.Entries.Remove(existingEntry);
                 }
                 result.Entries.Add(userConfig);
             }
         }
     }
     return result;
 }
 public void LoadConfiguration(string jsonConfiguration, string[] roles = null, string userName = null)
 {
     _configurationCache = ParseConfiguration(jsonConfiguration, roles, userName);
 }