Ejemplo n.º 1
0
        public static void AddPreferencesRenderer(List <string> names, IOutputPreferencesRenderer renderer)
        {
            if (renderer == null)
            {
                throw new ArgumentNullException(nameof(renderer));
            }
            if (names == null || !names.Any())
            {
                throw new ArgumentNullException(nameof(names));
            }
            lock (_preferencesRendersLock) {
                foreach (var name in names)
                {
                    var ignoreCaseName = name.ToLowerInvariant();
                    if (!_preferencesRenders.ContainsKey(ignoreCaseName))
                    {
                        _preferencesRenders.Add(ignoreCaseName, renderer);
                    }
                }

                if (names.All(name => string.Compare(name, renderer.Name, StringComparison.OrdinalIgnoreCase) != 0))
                {
                    var ignoreCaseName = renderer.Name.ToLowerInvariant();
                    if (!_preferencesRenders.ContainsKey(ignoreCaseName))
                    {
                        _preferencesRenders.Add(ignoreCaseName, renderer);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public static void AddPreferencesRenderer(IOutputPreferencesRenderer renderer)
        {
            if (renderer == null)
            {
                throw new ArgumentNullException(nameof(renderer));
            }
            var ignoreCaseName = renderer.Name.ToLowerInvariant();

            // ReSharper disable once InconsistentlySynchronizedField
            if (!_preferencesRenders.ContainsKey(ignoreCaseName))
            {
                lock (_preferencesRendersLock) {
                    if (!_preferencesRenders.ContainsKey(ignoreCaseName))
                    {
                        _preferencesRenders.Add(ignoreCaseName, renderer);
                    }
                }
            }
        }
Ejemplo n.º 3
0
 private static void RenderPropertyTokenForPreferencesRenderer(PropertyOutputMessageToken token, IOutputPreferencesRenderer renderer,
                                                               StringBuilder stringBuilder, LogEvent logEvent, StringBuilder targetMessageBuilder, IFormatProvider formatProvider = null)
 {
     if (token == null || renderer == null || renderer.IsNull)
     {
         return;
     }
     renderer.Render(token.FormatEvents, token.Params, stringBuilder, logEvent, targetMessageBuilder, formatProvider);
 }