public JavaScriptEvaluationResult Evaluate(string filename, string[] contents, List <string> attributes, bool mergeBlocks) { var joinedString = string.Join("", contents); if ((!joinedString.Contains("script", StringComparison.OrdinalIgnoreCase) && attributes.Any(x => joinedString.Contains(x, StringComparison.OrdinalIgnoreCase)))) { return(null); } var pageLevel = JsBlockContentEvaluator.Evaluate(contents, PageEvaluationMode.Any, mergeBlocks); var references = JsReferencesEvaluator.Evaluate(joinedString); var block = JsBlockEvaluator.Evaluate(joinedString, attributes); var razor = JsRazorEvaluator.Evaluate(joinedString, attributes); if (pageLevel.Any() || references > 0 || block.Any() || razor.Any()) { return(new JavaScriptEvaluationResult { FileName = filename, PageInstances = pageLevel, References = references, Block = block, Razor = razor, }); } return(null); }
public void Razor() { var raw = AssetRetriever.GetFileAndContent(AvailableTestingResources.TestingResource); var evaluator = new JsRazorEvaluator(); var result = evaluator.Evaluate(string.Join("", raw.Contents), JsAttributesProvider.Attributes); Assert.AreEqual(1, result.Count); Assert.AreEqual(1, result[0].InlineJavascriptTags.Count); Assert.AreEqual("onclick", result[0].AttributeName); }