Esempio n. 1
0
        private static LayoutRenderer ApplyWrappers(ConfigurationItemFactory configurationItemFactory, LayoutRenderer lr, List<LayoutRenderer> orderedWrappers)
        {
            for (var i = orderedWrappers.Count - 1; i >= 0; --i)
            {
                var newRenderer = (WrapperLayoutRendererBase) orderedWrappers[i];
                InternalLogger.Trace("Wrapping {0} with {1}", lr.GetType().Name, newRenderer.GetType().Name);
                if (CanBeConvertedToLiteral(lr))
                {
                    lr = ConvertToLiteral(lr);
                }

                newRenderer.Inner = new SimpleLayout(new[] {lr}, string.Empty, configurationItemFactory);
                lr = newRenderer;
            }

            return lr;
        }
Esempio n. 2
0
 internal SimpleLayout(LayoutRenderer[] renderers, string text, ConfigurationItemFactory configurationItemFactory)
 {
     this.configurationItemFactory = configurationItemFactory;
     SetRenderers(renderers, text);
 }
Esempio n. 3
0
        internal void SetRenderers(LayoutRenderer[] renderers, string text)
        {
            Renderers = new ReadOnlyCollection<LayoutRenderer>(renderers);
            if (Renderers.Count == 1 && Renderers[0] is LiteralLayoutRenderer)
            {
                fixedText = ((LiteralLayoutRenderer) Renderers[0]).Text;
            }
            else
            {
                fixedText = null;
            }

            layoutText = text;
        }
Esempio n. 4
0
 private static LayoutRenderer ConvertToLiteral(LayoutRenderer renderer)
 {
     return new LiteralLayoutRenderer(renderer.Render(LogEventInfo.CreateNullEvent()));
 }
Esempio n. 5
0
        private static bool CanBeConvertedToLiteral(LayoutRenderer lr)
        {
            foreach (var renderable in ObjectGraphScanner.FindReachableObjects<IRenderable>(lr))
            {
                if (renderable.GetType() == typeof (SimpleLayout))
                {
                    continue;
                }

                if (!renderable.GetType().IsDefined(typeof (AppDomainFixedOutputAttribute), false))
                {
                    return false;
                }
            }

            return true;
        }