/// <summary>
        ///     Instructs the renderer to render to the supplied proxy.
        /// </summary>
        /// <param name="proxy">The proxy to render to.</param>
        /// <param name="arg">The object to render.</param>
        /// <param name="culture">The culture to use for the render.</param>
        public override void Render(IConsoleProxy proxy, object arg, CultureInfo culture)
        {
            if (this.Template.Styles.TryGetValue(this.Config, out var style))
            {
                proxy.GetStyle(out var original);
                proxy.Style(style);
                foreach (var subRenderer in this.SubRenderes)
                {
                    subRenderer.Render(proxy, arg, culture);
                }

                proxy.Style(original);
            }
            else
            {
                foreach (var subRenderer in this.SubRenderes)
                {
                    subRenderer.Render(proxy, arg, culture);
                }
            }
        }
예제 #2
0
        /// <summary>
        ///     Instructs the renderer change color to the specified value, render all SubRenderes and the change the color back to the original color.
        /// </summary>
        /// <param name="proxy">The proxy to render to.</param>
        /// <param name="arg">The object to render.</param>
        /// <param name="culture">The culture to use for the render.</param>
        public override void Render(IConsoleProxy proxy, object arg, CultureInfo culture)
        {
            var consoleColor = this.GetColorFromConfigValue();

            if (consoleColor == null)
            {
                foreach (var subRenderer in this.SubRenderes)
                {
                    subRenderer.Render(proxy, arg, culture);
                }

                return;
            }

            proxy.GetStyle(out var original);
            proxy.Style(new ConsoleStyle("temp", consoleColor));
            foreach (var subRenderer in this.SubRenderes)
            {
                subRenderer.Render(proxy, arg, culture);
            }

            proxy.Style(original);
        }