public void Init(IValueProvider valueProvider, IPathProvider pathProvider) { var needAttr = htmlElement.htmlAttribute() .ToDictionary( key => key.htmlAttributeName().TAG_NAME().GetText().ToUpper(), value => new HtmlAttributeManager(value).Value ); if (needAttr["REL"]?.ToUpper() != "STYLESHEET") { return; } var fileName = needAttr["HREF"]; if (fileName == null) { return; } string path = pathProvider.GetPathFile(fileName); File = valueProvider.GetFile(path); if (File == null) { return; } htmlElement.AddChild(new BufferValueContext <File>(htmlElement, File)); }
public void Init(IValueProvider valueProvider, IPathProvider pathProvider) { var curContent = scriptContext.htmlContent(); foreach (var attr in scriptContext.htmlAttribute()) { if (attr.htmlAttributeName().TAG_NAME().GetText().ToUpper() == "SRC") { HtmlAttributeManager manager = new HtmlAttributeManager(attr); string path = pathProvider.GetPathFile(manager.Value); File = valueProvider.GetFile(path); if (File == null) { return; } } } if (curContent == null) { return; } HtmlContentContext content = null; if (File == null) { var stream = curContent.GetStream(); File = new ParseFile().ToParse(IO.Path.GetRandomFileName(), stream, FileType.Js); File.IsInternal = true; valueProvider.AddFile(File); content = new ContentContext(scriptContext, File); } else { BufferValueContext <File> bufferValue = new BufferValueContext <File>(scriptContext, File); scriptContext.AddChild(bufferValue); content = new HtmlContentContext(scriptContext, 0); } scriptContext.Replace(curContent, content); }