private HtmlElement EmbedResourceInTag(string tagName, string mimeType, string filename) { var block = HtmlPage.Document.CreateElement(tagName); block.SetAttribute("type", mimeType); string scriptOrStyle = DynamicApplication.GetResource(filename); var ieScriptOrStyleSet = false; if (HtmlPage.BrowserInformation.UserAgent.Contains("MSIE")) { if (tagName == "script") { block.SetProperty("text", scriptOrStyle); ieScriptOrStyleSet = true; } else if (tagName == "style") { (block.GetProperty("styleSheet") as ScriptObject).SetProperty("cssText", scriptOrStyle); ieScriptOrStyleSet = true; } } if (!ieScriptOrStyleSet) { var textNode = HtmlPage.Document.Invoke("createTextNode", new string[] { scriptOrStyle }); (block as ScriptObject).Invoke("appendChild", new object[] { textNode }); } return(block); }
public static void LoadByExtension(string fileExtension) { var path = string.Format("init{0}", fileExtension); var code = DynamicApplication.GetResource(path); if (code == null) { return; } var dyneng = DynamicApplication.Current.Engine; dyneng.Engine = dyneng.Runtime.GetEngineByFileExtension(fileExtension); dyneng.Engine.CreateScriptSourceFromString(code, path).Execute(dyneng.CreateScope()); }
private IReplFormatter GetReplFormatter(Repl instance) { _neutralFormatter = new LanguageNeutralFormatter(this); if (_engine.Setup.FileExtensions.Count > 0) { string path = string.Format("repl_formatter{0}", _engine.Setup.FileExtensions[0]); string code = DynamicApplication.GetResource(path); if (code != null) { var scope = _engine.CreateScope(); try { _engine.CreateScriptSourceFromString(code, path).Execute(scope); var CreateReplFormatter = scope.GetVariable <Func <Repl, IReplFormatter, IReplFormatter> >("create_repl_formatter"); if (CreateReplFormatter != null) { return(CreateReplFormatter(this, _neutralFormatter)); } } catch (Exception e) { DynamicApplication.Current.HandleException(this, e); } } } return(_neutralFormatter); }