private bool ModifyIt(string parameter, Dictionary <string, object> source, ModifyConfigurationIniNode iniNode)
        {
            try
            {
                var    ModifyData = source[parameter] as object[];
                string strLeft = parameter.Substring(4) + "_left";
                string strTop = parameter.Substring(4) + "_top";
                int    Left, Top;
                bool   Modified = false;
                if (int.TryParse(iniNode.Get(strLeft), out Left))
                {
                    ModifyData[0] = Left;
                    Modified      = true;
                }
                if (int.TryParse(iniNode.Get(strTop), out Top))
                {
                    ModifyData[1] = Top;
                    Modified      = true;
                }
                return(Modified);
            }
            catch (Exception e)
            {
                ErrorReporter.SendErrorReport(e, string.Format("魔改参数错误,{0}.{1}", source["api_filename"], parameter));
            }

            return(false);
        }
        private void MakaiOnBeforeResponse(Session oSession)
        {
            if (oSession.fullUrl.Contains("/kcsapi/api_start2"))
            {
                string api_start2full = oSession.GetResponseBodyAsString();

                var    mod             = ModifyConfiguration.Instance;
                bool   changed         = false;
                string api_start2_json = api_start2full.Substring(7);
                Dictionary <string, object> api_start2 =
                    JavaScriptSerializer.DeserializeObject(api_start2_json) as Dictionary <string, object>;
                try
                {
                    var api_data          = api_start2["api_data"] as Dictionary <string, object>;
                    var api_mst_ship      = api_data["api_mst_ship"] as object[];
                    var api_mst_shipgraph = api_data["api_mst_shipgraph"] as object[];

                    string shipCache = Path.Combine(settings.CacheFolder, @"kcs\resources\swf\ships");
                    //for debug//shipCache = Path.Combine(Application.StartupPath, "Settings");
                    foreach (var shipgraph_data_obj in api_mst_shipgraph)
                    {
                        var shipgraph_data = shipgraph_data_obj as Dictionary <string, object>;
                        if (shipgraph_data["api_sortno"].ToString() == "0")
                        {
                            continue;
                        }
                        string shipid       = shipgraph_data["api_id"].ToString();
                        string api_filename = shipgraph_data["api_filename"].ToString();
                        var    ship_data    =
                            api_mst_ship.FirstOrDefault(e => (e as Dictionary <string, object>)["api_id"].ToString() == shipid) as
                            Dictionary <string, object>;

                        string configFile = null;
                        //if (Configuration.Config.CacheSettings.CacheEnabled)
                        {
                            configFile = Path.Combine(shipCache, api_filename + ".config.ini");
                        }
                        if (File.Exists(configFile))                     //岛风GO格式
                        {
                            IniFile iniFile = new IniFile(configFile);
                            ModifyConfigurationIniNode IniNode = new ModifyConfigurationIniNode();
                            IniNode.api_filename = api_filename;
                            IniNode.api_name     = iniFile.ReadString("info", "ship_name", null);
                            IniNode.api_getmes   = iniFile.ReadString("info", "getmes", null);
                            //IniNode.api_info = iniFile.ReadString("info", "sinfo", null);
                            IniNode.api_config_parameter = iniFile.ReadSectionValues("graph");

                            bool flag = ModifyIt("api_boko_n", shipgraph_data, IniNode);
                            flag |= ModifyIt("api_boko_d", shipgraph_data, IniNode);
                            flag |= ModifyIt("api_kaisyu_n", shipgraph_data, IniNode);
                            flag |= ModifyIt("api_kaisyu_d", shipgraph_data, IniNode);
                            flag |= ModifyIt("api_kaizo_n", shipgraph_data, IniNode);
                            flag |= ModifyIt("api_kaizo_d", shipgraph_data, IniNode);
                            flag |= ModifyIt("api_map_n", shipgraph_data, IniNode);
                            flag |= ModifyIt("api_map_d", shipgraph_data, IniNode);
                            flag |= ModifyIt("api_ensyuf_n", shipgraph_data, IniNode);
                            flag |= ModifyIt("api_ensyuf_d", shipgraph_data, IniNode);
                            flag |= ModifyIt("api_ensyue_n", shipgraph_data, IniNode);
                            flag |= ModifyIt("api_battle_n", shipgraph_data, IniNode);
                            flag |= ModifyIt("api_battle_d", shipgraph_data, IniNode);
                            flag |= ModifyIt("api_weda", shipgraph_data, IniNode);
                            flag |= ModifyIt("api_wedb", shipgraph_data, IniNode);

                            if (flag)
                            {
                                changed = true;
                            }

                            // 魔改名称
                            if (!string.IsNullOrEmpty(IniNode.api_name))
                            {
                                ship_data["api_name"] = IniNode.api_name;
                                flag    = true;
                                changed = true;
                            }
                            // 魔改获得信息
                            if (!string.IsNullOrEmpty(IniNode.api_getmes))
                            {
                                ship_data["api_getmes"] = IniNode.api_getmes;
                                flag    = true;
                                changed = true;
                            }

                            if (flag)
                            {
                                ElectronicObserver.Utility.Logger.Add(2, string.Format("应用魔改: {0} → {1}", IniNode.api_filename, IniNode.api_name));
                            }
                        }
                        else                     //ApiModify.json格式
                        {
                            var ModifyNode = ModifyConfiguration.Instance.GetModifyNode(api_filename);
                            if (ModifyNode == null)
                            {
                                continue;
                            }

                            // 魔改立绘坐标
                            bool flag = ModifyIt("api_boko_n", shipgraph_data, ModifyNode.api_parameter);
                            flag |= ModifyIt("api_boko_d", shipgraph_data, ModifyNode.api_parameter);
                            flag |= ModifyIt("api_kaisyu_n", shipgraph_data, ModifyNode.api_parameter);
                            flag |= ModifyIt("api_kaisyu_d", shipgraph_data, ModifyNode.api_parameter);
                            flag |= ModifyIt("api_kaizo_n", shipgraph_data, ModifyNode.api_parameter);
                            flag |= ModifyIt("api_kaizo_d", shipgraph_data, ModifyNode.api_parameter);
                            flag |= ModifyIt("api_map_n", shipgraph_data, ModifyNode.api_parameter);
                            flag |= ModifyIt("api_map_d", shipgraph_data, ModifyNode.api_parameter);
                            flag |= ModifyIt("api_ensyuf_n", shipgraph_data, ModifyNode.api_parameter);
                            flag |= ModifyIt("api_ensyuf_d", shipgraph_data, ModifyNode.api_parameter);
                            flag |= ModifyIt("api_ensyue_n", shipgraph_data, ModifyNode.api_parameter);
                            flag |= ModifyIt("api_battle_n", shipgraph_data, ModifyNode.api_parameter);
                            flag |= ModifyIt("api_battle_d", shipgraph_data, ModifyNode.api_parameter);
                            flag |= ModifyIt("api_weda", shipgraph_data, ModifyNode.api_parameter);
                            flag |= ModifyIt("api_wedb", shipgraph_data, ModifyNode.api_parameter);

                            if (flag)
                            {
                                changed = true;
                            }

                            // 魔改名称
                            if (!string.IsNullOrEmpty(ModifyNode.api_name))
                            {
                                ship_data["api_name"] = ModifyNode.api_name;
                                flag    = true;
                                changed = true;
                            }
                            if (flag)
                            {
                                ElectronicObserver.Utility.Logger.Add(2, string.Format("应用魔改: {0} → {1}", ModifyNode.api_filename, ModifyNode.api_name));
                            }
                        }
                    }

                    // 如果有变动
                    if (changed)
                    {
                        oSession.utilSetResponseBody("svdata=" + JavaScriptSerializer.Serialize(api_start2));
                        // Nekoxy defaults to ASCII so we need to manually add this
                        oSession.oResponse.headers["Content-Type"] += ";charset=UTF-8";
                    }
                }
                catch (Exception e)
                {
                    ElectronicObserver.Utility.Logger.Add(3, "应用魔改过程中出现错误:" + e.Message + Environment.NewLine + e.StackTrace);
                }
            }
        }