/// <summary>
        /// スクリプトのエクスポートを行う。
        /// </summary>
        /// <param name="console">コンソールのインスタンス。</param>
        public void ExportScript(WarlockConsole console = null)
        {
            // スクリプトのロード
            if (console != null) console.WriteLine("========== エクスポート開始 ==========");

            // 出力フォルダがなければ作成
            if (!Directory.Exists(DataFolderFullPath))
            {
                Directory.CreateDirectory(DataFolderFullPath);
            }

            var scriptDatas = new List<ScriptData>();
            foreach (var definition in GetAllScripts())
            {
                var scriptData = new ScriptData();

                if (definition is ClassDefinition)
                {
                    var castedDefinition = (ClassDefinition)definition;

                    scriptData.Guid = castedDefinition.Guid;
                    scriptData.DisplayName = castedDefinition.FullName;

                    if (console != null) console.WriteLine("{0}({1}) -> {2}", castedDefinition.FullName, castedDefinition.Guid ,scriptData.DisplayName);
                    scriptData.SourceCode = castedDefinition.ToScript();
                }
                else if (definition is ScriptDefinition)
                {
                    var castedDefinition = (ScriptDefinition)definition;

                    scriptData.Guid = castedDefinition.Guid;
                    scriptData.DisplayName = castedDefinition.DisplayName;

                    if (console != null) console.WriteLine("{0} -> {1}", castedDefinition.FileName, scriptData.DisplayName);
                    if (!castedDefinition.IsFolder && File.Exists(GetScriptFullPath(castedDefinition.FileName)))
                    {
                        using (var sr = new StreamReader(GetScriptFullPath(castedDefinition.FileName)))
                        {
                            scriptData.SourceCode = sr.ReadToEnd();
                        }
                    }
                    else
                    {
                        scriptData.SourceCode = "";
                    }
                }
                else
                {
                    throw new NotImplementedException();
                }

                scriptDatas.Add(scriptData);
            }

            if (console != null) console.WriteLine("スクリプトをセーブ中 - {0}", ScriptFilePath);
            File.Copy(
                ScriptFilePath,
                String.Format("{0}.{1:yyyyMMddHHmmss}.bak", ScriptFilePath, DateTime.Now),
                overwrite: true
            );
            WarlockDatabase.SaveScript(ScriptFilePath, scriptDatas);

            if (console != null) console.WriteLine("スクリプトの再インポート実行");
            ImportScript();

            if (console != null) console.WriteLine("========== エクスポート完了 ==========");
        }
        /// <summary>
        /// スクリプトのデコードを行う。
        /// </summary>
        /// <param name="data">スクリプトデータのインスタンス。</param>
        /// <returns>スクリプトのデコード結果。</returns>
        private static dynamic DecodeScript(dynamic data)
        {
            var scriptList = new List<ScriptData>();

            foreach (List<dynamic> item in data)
            {
                var script = new ScriptData()
                {
                    Guid = item[0],
                    DisplayName = Encoding.UTF8.GetString((byte[])item[1])
                };

                byte[] src = (byte[])item[2];
                using (MemoryStream ms = new MemoryStream(src))
                {
                    // 2バイト読み飛ばす
                    ms.ReadByte(); ms.ReadByte();

                    var dst = new List<byte>();
                    using (DeflateStream ds = new DeflateStream(ms, CompressionMode.Decompress))
                    {
                        while (true)
                        {
                            byte[] buf = new byte[4096];
                            var readSize = ds.Read(buf, 0, buf.Length - 1);
                            if (readSize <= 0) break;

                            Array.Resize(ref buf, readSize);
                            dst.AddRange(buf);
                        }
                    }

                    script.SourceCode = Encoding.UTF8.GetString(dst.ToArray());
                }

                scriptList.Add(script);
            }

            return scriptList;
        }