private bool SimplifyMultiplication() { int i = 0; while (i < this.m_tokens.Count) { if (this.m_tokens[i].type == WowTextParser.TokenType.Multiply) { if (i == 0 || i + 1 >= this.m_tokens.Count || this.m_tokens[i - 1].type != WowTextParser.TokenType.Number || this.m_tokens[i + 1].type != WowTextParser.TokenType.Number) { throw new Exception("SimplifyMultiply(): Invalid multiply in string " + this.m_input); } double num = Convert.ToDouble(this.m_tokens[i - 1].stringValue); double num2 = Convert.ToDouble(this.m_tokens[i + 1].stringValue); double num3 = num * num2; int num4 = (int)num3; this.m_tokens.RemoveAt(i + 1); this.m_tokens.RemoveAt(i); WowTextParser.ParseToken item = default(WowTextParser.ParseToken); item.type = WowTextParser.TokenType.Number; item.stringValue = num4.ToString(); this.m_tokens.Insert(i, item); this.m_tokens.RemoveAt(i - 1); return(true); } else { i++; } } return(false); }
private bool SimplifyMultiplication() { for (int i = 0; i < this.m_tokens.Count; i++) { if (this.m_tokens[i].type == WowTextParser.TokenType.Multiply) { if (i == 0 || i + 1 >= this.m_tokens.Count || this.m_tokens[i - 1].type != WowTextParser.TokenType.Number || this.m_tokens[i + 1].type != WowTextParser.TokenType.Number) { throw new Exception(string.Concat("SimplifyMultiply(): Invalid multiply in string ", this.m_input)); } WowTextParser.ParseToken item = this.m_tokens[i - 1]; double num = Convert.ToDouble(item.stringValue); WowTextParser.ParseToken parseToken = this.m_tokens[i + 1]; double num1 = Convert.ToDouble(parseToken.stringValue); int num2 = (int)(num * num1); this.m_tokens.RemoveAt(i + 1); this.m_tokens.RemoveAt(i); WowTextParser.ParseToken parseToken1 = new WowTextParser.ParseToken() { type = WowTextParser.TokenType.Number, stringValue = num2.ToString() }; this.m_tokens.Insert(i, parseToken1); this.m_tokens.RemoveAt(i - 1); return(true); } } return(false); }
private void AddColorEndToken() { WowTextParser.ParseToken item = default(WowTextParser.ParseToken); item.type = WowTextParser.TokenType.ColorEnd; item.stringValue = this.m_currentValue; this.m_currentValue = string.Empty; this.m_tokens.Add(item); }
private void AddMultiplyToken() { WowTextParser.ParseToken item = default(WowTextParser.ParseToken); item.type = WowTextParser.TokenType.Multiply; item.stringValue = "*"; this.m_currentValue = string.Empty; this.m_tokens.Add(item); }
private void AddMinusToken() { WowTextParser.ParseToken item = default(WowTextParser.ParseToken); item.type = WowTextParser.TokenType.Subtract; item.stringValue = "-"; this.m_currentValue = string.Empty; this.m_tokens.Add(item); }
private void AddOpenBracketToken() { WowTextParser.ParseToken item = default(WowTextParser.ParseToken); item.type = WowTextParser.TokenType.OpenBracket; item.stringValue = "{"; this.m_currentValue = string.Empty; this.m_tokens.Add(item); this.m_bracketLevel++; }
private void AddMultiplyToken() { WowTextParser.ParseToken parseToken = new WowTextParser.ParseToken() { type = WowTextParser.TokenType.Multiply, stringValue = "*" }; this.m_currentValue = string.Empty; this.m_tokens.Add(parseToken); }
private void AddMinusToken() { WowTextParser.ParseToken parseToken = new WowTextParser.ParseToken() { type = WowTextParser.TokenType.Subtract, stringValue = "-" }; this.m_currentValue = string.Empty; this.m_tokens.Add(parseToken); }
private void AddColorStartToken() { WowTextParser.ParseToken parseToken = new WowTextParser.ParseToken() { type = WowTextParser.TokenType.ColorStart, stringValue = this.m_currentValue }; this.m_currentValue = string.Empty; this.m_tokens.Add(parseToken); }
private void AddNumericToken() { WowTextParser.ParseToken parseToken = new WowTextParser.ParseToken() { type = WowTextParser.TokenType.Number, stringValue = this.m_currentValue }; this.m_currentValue = string.Empty; this.m_tokens.Add(parseToken); }
private void AddOpenBracketToken() { WowTextParser.ParseToken parseToken = new WowTextParser.ParseToken() { type = WowTextParser.TokenType.OpenBracket, stringValue = "{" }; this.m_currentValue = string.Empty; this.m_tokens.Add(parseToken); this.m_bracketLevel++; }
private void AddTextToken() { if (this.m_currentValue == string.Empty) { return; } WowTextParser.ParseToken item = default(WowTextParser.ParseToken); item.type = WowTextParser.TokenType.Text; item.stringValue = this.m_currentValue; this.m_currentValue = string.Empty; this.m_tokens.Add(item); }
private void AddCloseBracketToken() { WowTextParser.ParseToken item = default(WowTextParser.ParseToken); item.type = WowTextParser.TokenType.ClosedBracket; item.stringValue = "}"; this.m_currentValue = string.Empty; this.m_tokens.Add(item); this.m_bracketLevel--; if (this.m_bracketLevel < 0) { throw new Exception("AddCloseBracketToken(): Mismatched brackets in string " + this.m_input); } }
private void AddTextToken() { if (this.m_currentValue == string.Empty) { return; } WowTextParser.ParseToken parseToken = new WowTextParser.ParseToken() { type = WowTextParser.TokenType.Text, stringValue = this.m_currentValue }; this.m_currentValue = string.Empty; this.m_tokens.Add(parseToken); }
private void AddCloseBracketToken() { WowTextParser.ParseToken parseToken = new WowTextParser.ParseToken() { type = WowTextParser.TokenType.ClosedBracket, stringValue = "}" }; this.m_currentValue = string.Empty; this.m_tokens.Add(parseToken); this.m_bracketLevel--; if (this.m_bracketLevel < 0) { throw new Exception(string.Concat("AddCloseBracketToken(): Mismatched brackets in string ", this.m_input)); } }