示例#1
0
        public string Styles(string styleLibraryName, bool outputDefaults = false)
        {
            // LR: Load the style library
            Dictionary <string, string> styleLibrary = this.StyleLibraries.GetStyleLibrary(styleLibraryName);

            if (!outputDefaults)
            {
                return(InlineCss(styleLibrary));
            }

            // LR: Default CSS Component Properties
            Dictionary <string, string> defaultStyles = new Dictionary <string, string>();

            foreach (KeyValuePair <string, string> attribute in Attributes)
            {
                if (string.IsNullOrWhiteSpace(attribute.Value))
                {
                    continue;
                }

                if (!CssHelper.IsCssProperty(attribute.Key))
                {
                    // Console.WriteLine($"[IsCssProperty] => Omitted {attribute.Key} as it's not a CssProperty");
                    continue;
                }

                defaultStyles.Add(attribute.Key, attribute.Value);
            }

            // LR: Merge style library into default styles.
            // CAUTION: This will include unessary properties to be outputted to CSS.
            return(InlineCss(defaultStyles.MergeLeft(styleLibrary)));
        }