private bool SetupInspectionMaster() { string src = AssetManager.LoadTextData("Data/ChatWord"); if (string.IsNullOrEmpty(src)) { DebugUtility.LogError("ChatWindow Error:[Data/ChatWord] is Not Found or Not Data!"); return(false); } try { JSON_ChatInspectionMaster[] jsonArray = JSONParser.parseJSONArray <JSON_ChatInspectionMaster>(src); if (jsonArray == null) { throw new InvalidJSONException(); } this.mChatInspectionMaster.Clear(); foreach (JSON_ChatInspectionMaster json in jsonArray) { ChatInspectionMaster inspectionMaster = new ChatInspectionMaster(); if (inspectionMaster.Deserialize(json)) { this.mChatInspectionMaster.Add(inspectionMaster); } } } catch (Exception ex) { DebugUtility.LogWarning("ChatWindow/SetupInspectionMaster parse error! e=" + ex.ToString()); return(false); } return(true); }
private string FilterMessage(string message) { string[] strArray = this.isIllegalWord(message); if (strArray != null && strArray.Length > 0) { for (int index = 0; index < strArray.Length; ++index) { string oldValue = strArray[index]; string newValue = new StringBuilder().Insert(0, "*", oldValue.Length).ToString(); message = message.Replace(oldValue, newValue); } } if (this.mChatInspectionMaster != null && this.mChatInspectionMaster.Count > 0) { using (List <ChatInspectionMaster> .Enumerator enumerator = this.mChatInspectionMaster.GetEnumerator()) { while (enumerator.MoveNext()) { ChatInspectionMaster current = enumerator.Current; StringBuilder stringBuilder; if (!string.IsNullOrEmpty(current.word)) { for (; message.ToLower().Contains(current.word.ToLower()); message = stringBuilder.ToString()) { string str = new StringBuilder().Insert(0, "*", current.word.Length).ToString(); int num = message.ToLower().IndexOf(current.word.ToLower()); stringBuilder = new StringBuilder(message); stringBuilder.Remove(num, current.word.Length); stringBuilder.Insert(num, str); } } } } } return(message); }