public static Plugin Load(string name) { var p = new Plugin(); var z = new ZipFile(name); var parts = z.Entries; var pa = parts.ToList(); p.Archive = z; StringBuilder sources = new StringBuilder(); for (int i = 0; i < pa.Count; i++) { var part = pa[i]; if (part.FileName.StartsWith("Icons") && !part.IsDirectory) { var strm = part.OpenReader(); var img = Image.FromStream(strm); var n = part.FileName.Remove(0, "Icons/".Length); p.Icons.Add(n, img); } if (part.FileName.EndsWith(".js") && part.FileName.StartsWith("Sources/")) { var src = new StreamReader(z[part.FileName].OpenReader()).ReadToEnd(); sources.AppendLine(src); } if (part.FileName == "info.json") { var json = new StreamReader(part.OpenReader()).ReadToEnd(); p.Info = ((ObjectValue)Json.Parse(json)).Value; p.Filename = name; } } p.ReadItemtemplates(z); p._engine = new JScriptEngine(WindowsScriptEngineFlags.EnableJITDebugging); p.InitEngine(z); p.ReadDependencies(); p._engine.Execute(sources.ToString()); p._engine.Execute(new StreamReader(z["main.js"].OpenReader()).ReadToEnd()); return(p); }
public static Plugin Load(string name) { var p = new Plugin(); var z = new ZipFile(name); var parts = z.Entries; var pa = parts.ToList(); p.Archive = z; StringBuilder sources = new StringBuilder(); for (int i = 0; i < pa.Count; i++) { var part = pa[i]; if (part.FileName.StartsWith("Icons") && !part.IsDirectory) { var strm = part.OpenReader(); var img = Image.FromStream(strm); var n = part.FileName.Remove(0, "Icons/".Length); p.Icons.Add(n, img); } if (part.FileName.EndsWith(".js") && part.FileName.StartsWith("Sources/")) { var src = new StreamReader(z[part.FileName].OpenReader()).ReadToEnd(); sources.AppendLine(src); } if (part.FileName == "info.json") { var json = new StreamReader(part.OpenReader()).ReadToEnd(); p.Info = ((ObjectValue)Json.Parse(json)).Value; p.Filename = name; } } p.ReadItemtemplates(z); p._engine = new JScriptEngine(WindowsScriptEngineFlags.EnableJITDebugging); p.InitEngine(z); p.ReadDependencies(); p._engine.Execute(sources.ToString()); p._engine.Execute(new StreamReader(z["main.js"].OpenReader()).ReadToEnd()); return p; }
public static Plugin Load(string name) { var p = new Plugin(); var z = new ZipFile(name); var parts = z.Entries; var pa = parts.ToList(); string props = ""; for (int i = 0; i < pa.Count; i++) { var part = pa[i]; if (part.FileName.StartsWith("Icons") && !part.IsDirectory) { var strm = part.OpenReader(); var img = Image.FromStream(strm); var n = part.FileName.Remove(0, "Icons/".Length); p.Icons.Add(n, img); } if(part.FileName == "Sources/properties.js") { var src = new StreamReader(z["Sources/properties.js"].OpenReader()).ReadToEnd(); props = src; } if (part.FileName == "info.json") { var json = new StreamReader(part.OpenReader()).ReadToEnd(); p.Info = ((ObjectValue)Json.Parse(json)).Value; p.Filename = name; } } p.ReadItemtemplates(z); if (p.Info.ContainsKey("Language")) { p.Language = p.Info["Language"].ToString(); switch (p.Info["Language"].ToString()) { case "JavaScript": p._engine = new JScriptEngine(WindowsScriptEngineFlags.EnableJITDebugging); break; case "VBScript": p._engine = new VBScriptEngine(WindowsScriptEngineFlags.EnableJITDebugging); break; } } else { p._engine = new JScriptEngine(WindowsScriptEngineFlags.EnableJITDebugging); p.Language = "JavaScript"; } p.InitEngine(z); p.ReadDependencies(); p._engine.Execute(props); p._engine.Execute(new StreamReader(z["main.js"].OpenReader()).ReadToEnd()); return p; }
public static Plugin Load(string name) { var p = new Plugin(); var z = new ZipFile(name); var parts = z.Entries; var pa = parts.ToList(); string props = ""; for (int i = 0; i < pa.Count; i++) { var part = pa[i]; if (part.FileName.StartsWith("Icons") && !part.IsDirectory) { var strm = part.OpenReader(); var img = Image.FromStream(strm); var n = part.FileName.Remove(0, "Icons/".Length); p.Icons.Add(n, img); } if (part.FileName == "Sources/properties.js") { var src = new StreamReader(z["Sources/properties.js"].OpenReader()).ReadToEnd(); props = src; } if (part.FileName == "info.json") { var json = new StreamReader(part.OpenReader()).ReadToEnd(); p.Info = ((ObjectValue)Json.Parse(json)).Value; p.Filename = name; } } p.ReadItemtemplates(z); if (p.Info.ContainsKey("Language")) { p.Language = p.Info["Language"].ToString(); switch (p.Info["Language"].ToString()) { case "JavaScript": p._engine = new JScriptEngine(WindowsScriptEngineFlags.EnableJITDebugging); break; case "VBScript": p._engine = new VBScriptEngine(WindowsScriptEngineFlags.EnableJITDebugging); break; } } else { p._engine = new JScriptEngine(WindowsScriptEngineFlags.EnableJITDebugging); p.Language = "JavaScript"; } p.InitEngine(z); p.ReadDependencies(); p._engine.Execute(props); p._engine.Execute(new StreamReader(z["main.js"].OpenReader()).ReadToEnd()); return(p); }