Example #1
0
        private void WritePluginJs(PluginAssembly plugin, StringBuilder js)
        {
            var jsBlocks = new List <JsBlock>();

            //除了放在 commands 文件夹下的 js,都加载进来。
            var assembly  = plugin.Assembly;
            var resources = assembly.GetManifestResourceNames()
                            .Where(r => !r.ToLower().Contains("commands.") && r.ToLower().Contains(".js"))
                            .ToArray();

            foreach (var resource in resources)
            {
                var stream = assembly.GetManifestResourceStream(resource);
                using (var sr = new StreamReader(stream))
                {
                    var jsContent = sr.ReadToEnd();
                    WebCommandJsHelper.LoadCommandJsBlocks(jsContent, jsBlocks);
                }
            }

            JsBlock.SortByHierachy(jsBlocks);

            foreach (var jsBlock in jsBlocks)
            {
                js.AppendLine(jsBlock.JavascriptCode);
            }
        }