/// <summary> /// Includes a resource that is already defined in a resource manifest /// </summary> /// <remarks> /// You can define resources in resource manifest files with ResourceManifestBuilder. /// For examples take a look at any ResourceManifest.cs file. /// </remarks> /// <param name="resourceName"></param> /// <returns></returns> public virtual RequireSettings Require(string resourceName) { if (resourceName == null) { throw new ArgumentNullException("resourceName"); } var settings = ResourceManager.Require(ResourceType, resourceName); if (_viewVirtualPath != null) { settings.WithBasePath(ResourceDefinition.GetBasePathFromViewPath(ResourceType, _viewVirtualPath)); } return(settings); }
private static TagBuilder GetTagBuilder(ResourceDefinition resource, string url) { var tagBuilder = new TagBuilder(resource.TagName); tagBuilder.MergeAttributes(resource.TagBuilder.Attributes); if (!String.IsNullOrEmpty(resource.FilePathAttributeName)) { if (!String.IsNullOrEmpty(url)) { if (VirtualPathUtility.IsAppRelative(url)) { url = VirtualPathUtility.ToAbsolute(url); } tagBuilder.MergeAttribute(resource.FilePathAttributeName, url, true); } } return(tagBuilder); }
public static void WriteResource(TextWriter writer, ResourceDefinition resource, string url, string condition, Dictionary <string, string> attributes) { if (!string.IsNullOrEmpty(condition)) { if (condition == NotIE) { writer.WriteLine("<!--[if " + condition + "]>-->"); } else { writer.WriteLine("<!--[if " + condition + "]>"); } } var tagBuilder = GetTagBuilder(resource, url); if (attributes != null) { // todo: try null value tagBuilder.MergeAttributes(attributes, true); } writer.WriteLine(tagBuilder.ToString(resource.TagRenderMode)); if (!string.IsNullOrEmpty(condition)) { if (condition == NotIE) { writer.WriteLine("<!--<![endif]-->"); } else { writer.WriteLine("<![endif]-->"); } } }
/// <summary> /// Includes a resource with the specified path /// </summary> /// <param name="resourceDebugPath">The relative or absolute path of the resource to be used in debug mode</param> /// <param name="resourcePath">The relative or absolute path of the resource</param> public RequireSettings Include(string resourceDebugPath, string resourcePath) { if (resourcePath == null) { throw new ArgumentNullException("resourcePath"); } return(ResourceManager.Include(ResourceType, resourcePath, resourceDebugPath, ResourceDefinition.GetBasePathFromViewPath(ResourceType, _viewVirtualPath))); }