From 068f39a85d42323758f019dd6d1ed61db8942088 Mon Sep 17 00:00:00 2001 From: huyfei Date: Sun, 4 Feb 2024 13:18:04 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8DGuruServices=20?= =?UTF-8?q?=E6=96=87=E6=A1=A3=E5=AF=BC=E5=85=A5=E5=99=A8=E8=A7=A3=E6=9E=90?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Helper/GuruServiceConverterHelper.cs | 36 ++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/Editor/GuruManager/Helper/GuruServiceConverterHelper.cs b/Editor/GuruManager/Helper/GuruServiceConverterHelper.cs index 6572654..d64fea5 100644 --- a/Editor/GuruManager/Helper/GuruServiceConverterHelper.cs +++ b/Editor/GuruManager/Helper/GuruServiceConverterHelper.cs @@ -10,11 +10,13 @@ namespace Guru.Editor public class GuruServiceConverterHelper { - const string k_app_settings = "app_settings"; - const string k_adjust_settings = "adjust_settings"; - const string k_fb_settings = "fb_settings"; - const string k_ad_settings = "ad_settings"; - const string k_iap_settings = "iap_settings"; + const string K_APP_SETTINGS = "app_settings"; + const string K_ADJUST_SETTINGS = "adjust_settings"; + const string K_FB_SETTINGS = "fb_settings"; + const string K_AD_SETTINGS = "ad_settings"; + const string K_IAP_SETTINGS = "iap_settings"; + const char K_SPLITTER_TAB = '\t'; + const char K_SPLITTER_COMMA = ','; #region Export JSON @@ -41,10 +43,10 @@ namespace Guru.Editor if (!IsInvalidLine(line)) { //---------------- app_settings ---------------- - if (line.StartsWith(k_app_settings)) + if (line.StartsWith(K_APP_SETTINGS)) { index++; - while (!line.StartsWith(k_adjust_settings)) + while (!line.StartsWith(K_ADJUST_SETTINGS)) { line = lines[index]; FillAppSettings(guru_service, line); @@ -53,25 +55,25 @@ namespace Guru.Editor } } //---------------- adjust_settings ---------------- - if (line.StartsWith(k_adjust_settings)) + if (line.StartsWith(K_ADJUST_SETTINGS)) { index++; FillAdjustSettings(guru_service, lines, ref index); } //---------------- fb_settings ---------------- - if (line.StartsWith(k_fb_settings)) + if (line.StartsWith(K_FB_SETTINGS)) { index++; FillFacebookSettings(guru_service, lines, ref index); } //---------------- ad_settings ---------------- - if (line.StartsWith(k_ad_settings)) + if (line.StartsWith(K_AD_SETTINGS)) { index++; FillAdSettings(guru_service, lines, ref index); } //---------------- iap_settings ---------------- - if (line.StartsWith(k_iap_settings)) + if (line.StartsWith(K_IAP_SETTINGS)) { index++; FillProducts(guru_service, lines, ref index); @@ -183,7 +185,7 @@ namespace Guru.Editor bool pass = false; List events = new List(20); - while (!lines[index].StartsWith(k_fb_settings)) + while (!lines[index].StartsWith(K_FB_SETTINGS)) { line = lines[index]; if (!IsInvalidLine(line)) @@ -214,7 +216,7 @@ namespace Guru.Editor if(settings.fb_settings == null) settings.fb_settings = new GuruFbSettings(); var line = ""; - while (!lines[index].StartsWith(k_ad_settings)) + while (!lines[index].StartsWith(K_AD_SETTINGS)) { line = lines[index]; if (!IsInvalidLine(line)) @@ -258,7 +260,7 @@ namespace Guru.Editor //------- 开始记录广告配置; string[] arr; - while (!lines[index].StartsWith(k_iap_settings)) + while (!lines[index].StartsWith(K_IAP_SETTINGS)) { line = lines[index]; @@ -414,7 +416,7 @@ namespace Guru.Editor private static bool IsInvalidLine(string line) { - return (string.IsNullOrEmpty(line) || line.StartsWith("\t")); + return (string.IsNullOrEmpty(line) || line.StartsWith(K_SPLITTER_TAB)); } @@ -423,14 +425,14 @@ namespace Guru.Editor value = ""; // default if (line.StartsWith(key)) { - value = line.Split('\t')[1]; + value = line.Split(K_SPLITTER_TAB)[1]; if (string.IsNullOrEmpty(value)) value = "empty"; return true; } return false; } - private static string[] GetStringArray(string line, int startIndex = 0, int length = 0, char spliter = '\t') + private static string[] GetStringArray(string line, int startIndex = 0, int length = 0, char spliter = K_SPLITTER_TAB) { if (IsInvalidLine(line)) return null;