private void CreateTestableBatch <TStrategy>(BatchedObservableCollection <int> testableSource, int batchSize) where TStrategy : IBatchApplyingStrategy <int>, new() { using (var batch = testableSource.StartBatch <TStrategy>()) { for (int elementIndex = 0; elementIndex < batchSize; elementIndex++) { batch.AddToBatch(elementIndex); } } }
public async void Preview(object parameter) { IsBusy = true; IsPreviewVisible = false; WorkItemsListProvider.Clear(); PreviewFields.Clear(); BatchedObservableCollection <WorkItem> foundWorkItems = new BatchedObservableCollection <WorkItem>(); await Task.Run(() => { QueryDefinition query = TfsContext.WorkItemStore.GetQueryDefinition(queryItem.Id); WorkItemCollection workItems = TfsContext.WorkItemStore.Query(query.QueryText, TfsContext.WorkItemManager.Context); workItemFieldMap = new Dictionary <int, List <string> >(); fieldMatches = new HashSet <string>(); foreach (WorkItem workItem in workItems) { bool matchedCurrent = false; foreach (Field field in workItem.Fields.Cast <Field>().Where(f => IsStringField(f.FieldDefinition))) { if (field.Value.ToString().Contains(SearchTerm)) { if (!matchedCurrent) { foundWorkItems.Add(workItem); matchedCurrent = true; workItemFieldMap.Add(workItem.Id, new List <string>()); } fieldMatches.Add(field.Name); workItemFieldMap[workItem.Id].Add(field.Name); } } } }); WorkItemsListProvider.AddWorkItems(foundWorkItems); PreviewFields.AddRange(fieldMatches); bool matchFound = WorkItemsListProvider.VisibleCount > 0; StatusText = matchFound? "" : "No matches found."; IsPreviewVisible = matchFound; IsBusy = false; }
public WorkItemsSection() { WorkItemsListProvider = new WorkItemsListProvider(); OpenWorkItemCommand = new DelegateCommand <Uri>(OpenWorkItem); SelectedWorkItems = new BatchedObservableCollection <WorkItemValueProvider>(); }
public BatchedObservableCollectionTests() { testableCollection = new BatchedObservableCollection <int>(); }
public static IEnumerable <WorkItem> AsWorkItems(this BatchedObservableCollection <WorkItemValueProvider> items) { return(items.Select(provider => provider.WorkItem)); }