示例#1
0
        public static MvcHtmlString StyleSheet(this HtmlHelper helper, StyleSheetReference stylesheet)
        {
            // Check it has not already been added.

            return(ShouldOutput(helper, stylesheet)
                ? MvcHtmlString.Create(stylesheet.ToString())
                : MvcHtmlString.Empty);
        }
示例#2
0
        void IMasterPage.AddStyleSheetReference(StyleSheetReference reference)
        {
            var masterPage = Master;

            if (masterPage != null)
            {
                masterPage.AddStyleSheetReference(reference);
            }
        }
示例#3
0
        private static string StyleSheet(StyleSheetReference reference)
        {
            var builder = new TagBuilder("link");

            builder.MergeAttribute("href", reference.Url.ToString());
            builder.MergeAttribute("rel", "stylesheet");
            if (!string.IsNullOrEmpty(reference.Media))
            {
                builder.MergeAttribute("media", reference.Media);
            }
            return(builder.ToString(TagRenderMode.StartTag));
        }
示例#4
0
        private static string GenerateTemplateMetaDataCode(CompiledTemplateData compiledTemplateData)
        {
            StringBuilder builder = new StringBuilder(2048);
            LightList <CompiledTemplate> compiledTemplates = compiledTemplateData.compiledTemplates;

            builder.AppendLine($"{s_Indent12}{nameof(TemplateMetaData)}[] templateData = new {nameof(TemplateMetaData)}[{compiledTemplates.size}];");
            builder.AppendLine($"{s_Indent12}{nameof(TemplateMetaData)} template;");
            builder.AppendLine($"{s_Indent12}{nameof(StyleSheetReference)}[] styleSheetRefs;");

            for (int i = 0; i < compiledTemplates.size; i++)
            {
                TemplateMetaData meta = compiledTemplates[i].templateMetaData;

                if (meta.styleReferences != null && meta.styleReferences.Length > 0)
                {
                    builder.Append(s_Indent12);
                    builder.Append("styleSheetRefs = new StyleSheetReference[");
                    builder.Append(meta.styleReferences.Length);
                    builder.AppendLine("];");

                    for (int j = 0; j < meta.styleReferences.Length; j++)
                    {
                        StyleSheetReference sheetReference = meta.styleReferences[j];
                        builder.Append(s_Indent12);
                        builder.Append("styleSheetRefs[");
                        builder.Append(j);
                        builder.Append("] = new StyleSheetReference(");
                        builder.Append(sheetReference.alias == null ? "null" : "\"" + sheetReference.alias + "\"");
                        builder.Append(", sheetMap[@\"");
                        builder.Append(sheetReference.styleSheet.path);
                        builder.AppendLine("\"]);");
                    }

                    builder.AppendLine($"{s_Indent12}template = new {nameof(TemplateMetaData)}({compiledTemplates[i].templateId}, @\"{compiledTemplates[i].filePath}\", styleMap, styleSheetRefs);");
                }
                else
                {
                    builder.AppendLine($"{s_Indent12}template = new {nameof(TemplateMetaData)}({compiledTemplates[i].templateId}, @\"{compiledTemplates[i].filePath}\", styleMap, null);");
                }

                builder.AppendLine($"{s_Indent12}template.BuildSearchMap();");
                builder.AppendLine($"{s_Indent12}templateData[{i}] = template;");
            }

            builder.AppendLine($"{s_Indent12}return templateData;");

            return(builder.ToString());
        }
示例#5
0
        private static bool ShouldOutput(HtmlHelper helper, StyleSheetReference stylesheet)
        {
            var paths = helper.ViewData[Key] as IDictionary <string, StyleSheetReference>;

            if (paths == null)
            {
                paths = new Dictionary <string, StyleSheetReference>();
                helper.ViewData[Key]   = paths;
                paths[stylesheet.Path] = stylesheet;
                return(true);
            }

            var shouldOutput = !paths.ContainsKey(stylesheet.Path);

            paths[stylesheet.Path] = stylesheet;
            return(shouldOutput);
        }
示例#6
0
        internal void AddStyleSheet(StyleSheetReference styleSheetRef)
        {
            if (styleSheetRef == null || string.IsNullOrEmpty(styleSheetRef.CssPath) || !this.Cacheable)
            {
                return;
            }

            if (CachedStyleSheets == null)
            {
                CachedStyleSheets = new List <StyleSheetReference>();
            }

            if (CachedStyleSheets.Any(ssref => ssref.CssPath == styleSheetRef.CssPath))
            {
                return;
            }

            CachedStyleSheets.Add(styleSheetRef);
        }
示例#7
0
        public void Add(StyleSheetReference reference)
        {
            if (_useStandardStyleSheetReferences && IsReferenceIncluded(StandardStyleSheetReferences, reference))
            {
                return;
            }

            if (_styleSheetReferences == null)
            {
                _styleSheetReferences = new StyleSheetReferences {
                    reference
                };
            }
            else
            {
                if (!IsReferenceIncluded(_styleSheetReferences, reference))
                {
                    _styleSheetReferences.Add(reference);
                }
            }
        }
示例#8
0
文件: Page.cs 项目: formist/LinkMe
 public void AddStyleSheetReference(StyleSheetReference reference)
 {
     Master.AddStyleSheetReference(reference);
 }
示例#9
0
 void IMasterPage.AddStyleSheetReference(StyleSheetReference reference)
 {
     CheckNotRendered();
     _headInfo.Add(reference);
 }
示例#10
0
 public static void AddStandardStyleSheetReference(StyleSheetReference reference)
 {
     HeadInfo.AddStandard(reference);
 }
示例#11
0
 protected void AddStyleSheetReference(StyleSheetReference reference)
 {
     LinkMePage.AddStyleSheetReference(reference);
 }
示例#12
0
 public void AddStyleSheetReference(StyleSheetReference reference)
 {
 }
示例#13
0
 public static void AddStandard(StyleSheetReference reference)
 {
     StandardStyleSheetReferences.Add(reference);
 }