private async Task <GroupedRemoteSettings> ProcessRemoteSettingsFromTargetedNotificationsAsync()
        {
            IEnumerable <LoggingContext <ActionWrapper <JObject> > > source = await GetActionsInternalAsync <JObject>("VS\\Core\\RemoteSettings", false).ConfigureAwait(false);

            if (source.Any())
            {
                List <GroupedRemoteSettings> list = new List <GroupedRemoteSettings>();
                List <Tuple <ActionWrapper <JObject>, DeserializedRemoteSettings> > list2 = new List <Tuple <ActionWrapper <JObject>, DeserializedRemoteSettings> >();
                foreach (LoggingContext <ActionWrapper <JObject> > item in source.OrderBy((LoggingContext <ActionWrapper <JObject> > x) => x.Value.Precedence))
                {
                    DeserializedRemoteSettings deserializedRemoteSettings = remoteSettingsParser.TryParseFromJObject(item.Value.Action, string.IsNullOrEmpty(item.Value.FlightName) ? null : ("Flight." + item.Value.FlightName));
                    if (deserializedRemoteSettings.Successful)
                    {
                        list.Add(new GroupedRemoteSettings(deserializedRemoteSettings, Name + "-" + item.Context));
                    }
                    else
                    {
                        logger.LogError("Error deserializing TN rule " + item.Context + ": " + deserializedRemoteSettings.Error);
                        list2.Add(Tuple.Create(item.Value, deserializedRemoteSettings));
                    }
                }
                if (list2.Any())
                {
                    string name = "VS/Core/RemoteSettings/TargetedParseSettings";
                    Dictionary <string, object> dictionary = new Dictionary <string, object>();
                    dictionary["VS.Core.RemoteSettings.TargetedRuleIds"] = string.Join(",", list2.Select((Tuple <ActionWrapper <JObject>, DeserializedRemoteSettings> x) => x.Item1.RuleId));
                    dictionary["VS.Core.RemoteSettings.TargetedErrors"]  = string.Join(",", list2.Select((Tuple <ActionWrapper <JObject>, DeserializedRemoteSettings> x) => x.Item2.Error));
                    remoteSettingsTelemetry.PostEvent(name, dictionary);
                }
                if (list.Any())
                {
                    GroupedRemoteSettings groupedRemoteSettings = list.Aggregate(delegate(GroupedRemoteSettings a, GroupedRemoteSettings b)
                    {
                        a.Merge(b, logger);
                        return(a);
                    });
                    liveStorageHandler.SaveSettings(groupedRemoteSettings);
                    Interlocked.Exchange(ref currentStorageHandler, liveStorageHandler);
                    cacheableStorageHandler.DeleteAllSettings();
                    cacheableStorageHandler.SaveSettings(groupedRemoteSettings);
                    return(groupedRemoteSettings);
                }
            }
            else
            {
                Interlocked.Exchange(ref currentStorageHandler, liveStorageHandler);
                cacheableStorageHandler.DeleteAllSettings();
            }
            return(null);
        }
Пример #2
0
 public GroupedRemoteSettings(DeserializedRemoteSettings deserializedRemoteSettings, string origin)
 {
     foreach (RemoteSetting setting in deserializedRemoteSettings.Settings)
     {
         setting.Origin = origin;
         if (!TryGetValue(setting.Path, out RemoteSettingPossibilities value))
         {
             value = new RemoteSettingPossibilities();
             this[setting.Path] = value;
         }
         if (!value.TryGetValue(setting.Name, out List <RemoteSetting> value2))
         {
             value2 = new List <RemoteSetting>();
             value[setting.Name] = value2;
         }
         value2.Add(setting);
     }
 }
Пример #3
0
 public VersionedDeserializedRemoteSettings(DeserializedRemoteSettings remoteSettings, string fileVersion = null, string changesetId = null)
     : this(remoteSettings.Scopes, remoteSettings.Settings, fileVersion, changesetId, remoteSettings.Error)
 {
 }
Пример #4
0
 public void ValidateDeserialized(DeserializedRemoteSettings remoteSettings)
 {
     ValidateScopes(remoteSettings.Scopes);
 }