Ejemplo n.º 1
0
        public void ObtainDefaultSheet()
        {
            var engine = new CssStyleEngine();

            Assert.IsNotNull(engine.Default);
            Assert.AreEqual("text/css", engine.Type);
            var sheet = engine.Default as CSSStyleSheet;

            Assert.IsNotNull(sheet);
            Assert.AreEqual(49, sheet.Rules.Length);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Registers the default styling service with a new CSS style engine
        /// to retrieve, if no other styling service has been registered yet.
        /// </summary>
        /// <param name="configuration">The configuration to extend.</param>
        /// <param name="setup">Optional setup for the style engine.</param>
        /// <returns>The new instance with the service.</returns>
        public static IConfiguration WithCss(this IConfiguration configuration, Action <CssStyleEngine> setup = null)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            if (!configuration.GetServices <IStylingProvider>().Any())
            {
                var service = new StylingService();
                var engine  = new CssStyleEngine();
                setup?.Invoke(engine);
                service.Register(engine);
                return(configuration.With(service));
            }

            return(configuration);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Registers the default styling service with a new CSS style engine
        /// to retrieve, if no other styling service has been registered yet.
        /// </summary>
        /// <param name="configuration">The configuration to extend.</param>
        /// <param name="setup">Optional setup for the style engine.</param>
        /// <returns>The new instance with the service.</returns>
        public static IConfiguration WithCss(this IConfiguration configuration, Action <CssStyleEngine> setup = null)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            if (configuration.GetServices <IStylingService>().Any() == false)
            {
                var service = new StylingService();
                var engine  = new CssStyleEngine();

                if (setup != null)
                {
                    setup(engine);
                }

                service.Register(engine);
                return(configuration.With(service));
            }

            return(configuration);
        }