Esempio n. 1
0
 public virtual ResourceDefinition DefineResource(string resourceType, string resourceName)
 {
     var definition = new ResourceDefinition(this, resourceType, resourceName);
     var resources = GetResources(resourceType);
     resources[resourceName] = definition;
     return definition;
 }
Esempio n. 2
0
 public void Style(HtmlHelper Html, TextWriter Output, ResourceDefinition Resource, string Url, string Condition, Dictionary<string, string> TagAttributes)
 {
     // do not write to Output directly as Styles are rendered in Zones
     ResourceManager.WriteResource(Html.ViewContext.Writer, Resource, Url, Condition, TagAttributes);
 }
Esempio n. 3
0
 public void Resource(TextWriter Output, ResourceDefinition Resource, string Url, string Condition, Dictionary<string, string> TagAttributes)
 {
     ResourceManager.WriteResource(Output, Resource, Url, Condition, TagAttributes);
 }
Esempio n. 4
0
 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;
 }
Esempio n. 5
0
 protected virtual void ExpandDependencies(ResourceDefinition resource, RequireSettings settings, OrderedDictionary allResources)
 {
     if (resource == null)
     {
         return;
     }
     // Settings is given so they can cascade down into dependencies. For example, if Foo depends on Bar, and Foo's required
     // location is Head, so too should Bar's location.
     // forge the effective require settings for this resource
     // (1) If a require exists for the resource, combine with it. Last settings in gets preference for its specified values.
     // (2) If no require already exists, form a new settings object based on the given one but with its own type/name.
     settings = allResources.Contains(resource)
         ? ((RequireSettings)allResources[resource]).Combine(settings)
         : new RequireSettings { Type = resource.Type, Name = resource.Name }.Combine(settings);
     if (resource.Dependencies != null)
     {
         var dependencies = from d in resource.Dependencies
                            select FindResource(new RequireSettings { Type = resource.Type, Name = d });
         foreach (var dependency in dependencies)
         {
             if (dependency == null)
             {
                 continue;
             }
             ExpandDependencies(dependency, settings, allResources);
         }
     }
     allResources[resource] = settings;
 }
Esempio n. 6
0
        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]-->");
                }
            }
        }