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); }
void IMasterPage.AddStyleSheetReference(StyleSheetReference reference) { var masterPage = Master; if (masterPage != null) { masterPage.AddStyleSheetReference(reference); } }
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)); }
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()); }
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); }
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); }
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); } } }
public void AddStyleSheetReference(StyleSheetReference reference) { Master.AddStyleSheetReference(reference); }
void IMasterPage.AddStyleSheetReference(StyleSheetReference reference) { CheckNotRendered(); _headInfo.Add(reference); }
public static void AddStandardStyleSheetReference(StyleSheetReference reference) { HeadInfo.AddStandard(reference); }
protected void AddStyleSheetReference(StyleSheetReference reference) { LinkMePage.AddStyleSheetReference(reference); }
public void AddStyleSheetReference(StyleSheetReference reference) { }
public static void AddStandard(StyleSheetReference reference) { StandardStyleSheetReferences.Add(reference); }