private EcmaValue ParseFloat(EcmaHeadObject obj, EcmaValue[] arg) { string input = arg[0].ToString(State).Trim(); if (input.StartsWith("Infinity")) { return(EcmaValue.Number(Double.PositiveInfinity)); } StringBuilder builder = new StringBuilder(); int i = 0; for (; i < input.Length; i++) { char c = input[i]; if (!EcmaChar.IsDigit(c)) { break; } builder.Append(c); } if (i >= input.Length || input[i] != '.') { if (builder.Length == 0) { return(EcmaValue.Number(0)); } return(EcmaValue.Number(Double.Parse(builder.ToString()))); } builder.Append("."); i++; for (; i < input.Length; i++) { if (!EcmaChar.IsDigit(input[i])) { return(EcmaValue.Number(Double.Parse(builder.ToString()))); } builder.Append(input[i]); } return(EcmaValue.Number(Double.Parse(builder.ToString()))); }
private void ParseMessage(string message) { char[] chars = message.ToCharArray(); MessagePart msg = new MessagePart(); int length = chars.Length; for (int i = 0; i < length; i++) { char c = chars[i]; if (c == 3) { if (i + 1 < length && EcmaChar.IsDigit((int)chars[i + 1])) { i++; string code = chars[i].ToString(); if (EcmaChar.IsDigit(chars[i + 1])) { i++; code += chars[i]; } this.message.Add(msg); msg = msg.Clone(); msg.FontColor = IrcColorPlate.GetColor(code); //now background color if (chars[i + 1] == ',') { i++; if (EcmaChar.IsDigit(chars[i + 1])) { i++; code = chars[i].ToString(); if (EcmaChar.IsDigit(chars[i + 1])) { i++; code += chars[i]; } msg.BackGround = IrcColorPlate.GetColor(code); } else { msg.BackGround = Color.White; } } } else { this.message.Add(msg); msg = new MessagePart(); } } else { msg.Text += chars[i]; } } if (msg.Text.Length > 0) { this.message.Add(msg); } }