NSAttributedString BuildAttributedString(BufferLine line, int cols) { var res = new NSMutableAttributedString(); int attr = 0; basBuilder.Clear(); for (int col = 0; col < cols; col++) { var ch = line [col]; if (col == 0) { attr = ch.Attribute; } else { if (attr != ch.Attribute) { res.Append(new NSAttributedString(basBuilder.ToString(), GetAttributes(attr))); basBuilder.Clear(); attr = ch.Attribute; } } basBuilder.Append(ch.Code == 0 ? ' ' : (char)ch.Rune); } res.Append(new NSAttributedString(basBuilder.ToString(), GetAttributes(attr))); return(res); }
NSAttributedString BuildAttributedString(BufferLine line, int cols) { if (line == null) { return(new NSAttributedString(string.Empty, GetAttributes(CharData.Null.Attribute))); } var res = new NSMutableAttributedString(); int attr = 0; basBuilder.Clear(); for (int col = 0; col < cols; col++) { var ch = line [col]; if (col == 0) { attr = ch.Attribute; } else { if (attr != ch.Attribute) { res.Append(new NSAttributedString(basBuilder.ToString(), GetAttributes(attr))); basBuilder.Clear(); attr = ch.Attribute; } } basBuilder.Append(ch.Code == 0 ? " " : ch.Rune.ToString()); } res.Append(new NSAttributedString(basBuilder.ToString(), GetAttributes(attr))); return(res); }
static async Task <Dictionary <string, List <int> > > Run(string[] args) { IBuffer <ILineItem> _buffer = new BufferLine(); IReader _reader = new Reader(); IParser _parser = new Parser(); var readerTask = Task.Run(() => _reader.Read(@"d:/grom2.txt", _buffer)); var parserTask = Task.Run(() => _parser.Parse(_buffer)); await Task.WhenAll(readerTask, parserTask); return(parserTask.Result); }