public StringBuilder ReplaceWord(StringBuilder sb, bool bWordToCode) { if (!this.UseReplaceWord) { return(sb); } if (bWordToCode) { ListCompressor.TextDef[] textDefs = this.TextDefs; for (int i = 0; i < textDefs.Length; i++) { ListCompressor.TextDef textDef = textDefs[i]; sb = sb.Replace(textDef.word, textDef.code); } } else { ListCompressor.TextDef[] textDefs2 = this.TextDefs; for (int j = 0; j < textDefs2.Length; j++) { ListCompressor.TextDef textDef2 = textDefs2[j]; sb = sb.Replace(textDef2.code, textDef2.word); } } return(sb); }
public string ReplaceWord(string str, bool bWordToCode) { if (!this.UseReplaceWord) { return(str); } StringBuilder stringBuilder = new StringBuilder(512); if (bWordToCode) { stringBuilder.Append(str.ToLower()); ListCompressor.TextDef[] textDefs = this.TextDefs; for (int i = 0; i < textDefs.Length; i++) { ListCompressor.TextDef textDef = textDefs[i]; stringBuilder = stringBuilder.Replace(textDef.word, textDef.code); } } else { ListCompressor.TextDef[] textDefs2 = this.TextDefs; for (int j = 0; j < textDefs2.Length; j++) { ListCompressor.TextDef textDef2 = textDefs2[j]; stringBuilder = stringBuilder.Replace(textDef2.code, textDef2.word); } } return(stringBuilder.ToString()); }