Ejemplo n.º 1
0
        private static void OverrideValue([NotNull] JObject target, [NotNull] JProperty prop)
        {
            JetBrainsHelpers.assume(prop.Name != null);

            switch (prop.Value)
            {
            case null:
                break;

            case JValue val:
                target[prop.Name] = val;
                break;

            case JArray a:
                target[prop.Name] = a;
                break;

            case JObject obj:
                Apply(obj, (JObject)target[prop.Name].NotNull());
                break;

            default:
                throw new InvalidOperationException($"unknown value-type: '{prop.Value.GetType().Name}'");
            }
        }
Ejemplo n.º 2
0
        private void ApplyCommandLineValueOverride([NotNull] JObject configuration, [NotNull] Match match)
        {
            var path = match.Groups["path"]?.Value ?? string.Empty;

            if (string.IsNullOrWhiteSpace(path))
            {
                return;
            }

            var group = match.Groups["value"];

            JetBrainsHelpers.assume(group != null);

            var    stringValue = group.Success ? group.Value : "true";
            JToken value       = JsonBuilder.ValueFromString(stringValue);

            var valueConfiguration = JsonBuilder.Construct(path.Split('/'), value);

            JsonBuilder.Apply(valueConfiguration, configuration);
        }
Ejemplo n.º 3
0
        private static void OverrideProperty([NotNull] JObject target, [NotNull] JProperty prop)
        {
            JetBrainsHelpers.assume(prop.Name != null);

            if (!target.ContainsKey(prop.Name))
            {
                target[prop.Name] = prop.Value;
                return;
            }

            JetBrainsHelpers.assume(target[prop.Name] != null);
            if (prop.Value?.GetType() != target[prop.Name].GetType())
            {
                target[prop.Name] = prop.Value;
            }
            else
            {
                OverrideValue(target, prop);
            }
        }
Ejemplo n.º 4
0
        public async Task NotifyAsync(string subject, string body)
        {
            using (_Logger.LogScope(LogLevel.Information, $"Dispatching notification '{subject}'/'{body}'"))
            {
                var tasks = _NotificationChannels.Select(
                    async channel =>
                {
                    JetBrainsHelpers.assume(channel != null);
                    using (_Logger.LogScope(
                               LogLevel.Debug,
                               $"Dispatching notification '{subject}'/'{body}' to channel '{_TypeHelper.NameOf(channel.GetType())}'"))
                    {
                        await channel.SendNotificationAsync(subject, body);
                    }
                })
                            .ToList();

                await Task.WhenAll(tasks).NotNull();
            }
        }