public static LiveListState <T> CreateState(ObservableType executionType, IBaseListCollection <T> list, int startingIndex, TimeSpan timeout) { var tracker = new ListCollectionIndexOffsetTracker <T>(); tracker.SetOriginalIndexAndResetCurrent(startingIndex); list.CollectionChangedEvent += tracker.HandleEvent; list.CollectionChangedEvent += (_, e) => { if (e != null) { lock (tracker) { Monitor.Pulse(tracker); } } }; return(new LiveListState <T>() { List = list, Tracker = tracker, Timeout = timeout, ExecutionType = executionType }); }
private readonly ExpressionMethodVisitor <int> metricCollector = new ExpressionMethodVisitor <int>(); // Can't be static in-case async operation is used. Hopefully evaluate is never invoked async. public ListStorageEvaluator(IRegistryStorage storage, IBaseListCollection <ILogEntry> data) { this.dataRegistryStorage = storage; this.data = data; this.metricCollector.MethodVisitHandler = (mexp, d, unused, visit) => { var method = mexp.Method; if (method.IsGenericMethod) { method = method.GetGenericMethodDefinition(); } expressionMethodCounter.Increment(method.ToString()); visit(mexp.Arguments[0]); return(mexp); }; }
/// <summary> /// Searches the entire sorted <see cref="IBaseListCollection{T}"/> for an element using the specified comparer and returns the zero-based index of the element. /// </summary> /// <typeparam name="T">The type of elements in the collection.</typeparam> /// <param name="collection">The collection to search.</param> /// <param name="item">The object to locate. The value can be <b>null</b> for reference types.</param> /// <param name="comparer">The <see cref="IComparer{T}"/> implementation to use when comparing elements.</param> /// <returns>The zero-based index of item in the sorted <see cref="IBaseListCollection{T}"/>, if <paramref name="item"/> is found; otherwise, a negative number that is the bitwise complement of the index of the next element that is larger than <paramref name="item"/> or, if there is no larger element, the bitwise complement of <see cref="Count"/>.</returns> public static int BinarySearch <T>(this IBaseListCollection <T> collection, T item, IComparer <T> comparer) { return(collection.BinarySearch(0, collection.Count, item, comparer)); }
/// <summary> /// Searches the entire sorted <see cref="IBaseListCollection{T}"/> for an element using the default comparer and returns the zero-based index of the element. /// </summary> /// <typeparam name="T">The type of elements in the collection.</typeparam> /// <param name="collection">The collection to search.</param> /// <param name="item">The object to locate. The value can be <b>null</b> for reference types.</param> /// <returns>The zero-based index of item in the sorted <see cref="IBaseListCollection{T}"/>, if <paramref name="item"/> is found; otherwise, a negative number that is the bitwise complement of the index of the next element that is larger than <paramref name="item"/> or, if there is no larger element, the bitwise complement of <see cref="Count"/>.</returns> public static int BinarySearch <T>(this IBaseListCollection <T> collection, T item) { return(collection.BinarySearch(0, collection.Count, item, null)); }