public void Handle(Guid clientID, CommandMessage message) { Logger.Write("arg count is " + message.Arguments.Count.ToString()); if (message.Arguments.Count > 2 || message.Arguments.Count == 0) { return; } if (clientID == Guid.Empty) { return; } var limit = 0; if (message.Arguments.Count == 2) { Logger.Write("arg is " + message.Arguments[1]); int limitParam; if (!int.TryParse(message.Arguments[1], out limitParam)) { return; } if (limitParam <= 0) { return; } limit = limitParam; } var sb = new StringBuilder(); sb.Append(message.CorrelationID); var formatter = new CacheFormatter(); List <IGrouping <string, ICodeReference> > result; Logger.Write("Taking " + limit.ToString()); if (limit > 0) { result = _cache.Find(message.Arguments[0], limit).GroupBy(x => x.File).ToList(); } else { result = _cache.Find(message.Arguments[0]).GroupBy(x => x.File).ToList(); } result.ForEach(x => { sb.AppendLine(formatter.FormatFile(x.Key)); x.ToList() .ForEach(y => sb.AppendLine(formatter.Format(y))); }); _endpoint.Send(sb.ToString(), clientID); }
private void continuousSearch() { // The sprinkled thread sleeps is for mono 3.x // winforms stuff freaking out while (_runSearch) { if (_lastKeypress.AddMilliseconds(400) > DateTime.Now || _searchTerms.Count == 0) { System.Threading.Thread.Sleep(50); continue; } var searchText = ""; while (_searchTerms.Count > 0) { searchText = _searchTerms.Dequeue(); } try { var items = _cache.Find(searchText).Take(30).ToList(); if (items.Count > 30) { items = items.GetRange(0, 30); } _syncContext.Post(nothing => informationList.Items.Clear(), null); foreach (var item in items) { _syncContext.Post(itm => addItem((ICodeReference)itm), item); } _syncContext.Post(nothing => { if (informationList.Items.Count > 0) { informationList.Items[0].Selected = true; } informationList.Refresh(); }, items); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } } }
public override object CreateInstance(TypeId id) { var registration = _typeCache.Find(id); if (registration == null) { return(null); } var o = CreateObject( registration.GetConstructionType(id.Type), registration.Dependencies); if (registration.ShouldCache) { _objectCache.Add(id, o); } return(o); }