public static void AllocationFreeForEach(IEnumerable <KeyValuePair <TKey, TValue> > instance, ref TState state, StructEnumeratorForEachDelegate <KeyValuePair <TKey, TValue>, TState> itemCallback)
#pragma warning restore CA1000 // Do not declare static members on generic types
        => StructEnumerator <IEnumerable <KeyValuePair <TKey, TValue> >, KeyValuePair <TKey, TValue>, TState> .AllocationFreeForEach(instance, ref state, itemCallback);
        public static StructEnumerator <IEnumerable <KeyValuePair <TKey, TValue> >, KeyValuePair <TKey, TValue>, TState> .AllocationFreeForEachDelegate FindAllocationFreeForEachDelegate(IEnumerable <KeyValuePair <TKey, TValue> > instance)
#pragma warning restore CA1000 // Do not declare static members on generic types
        => StructEnumerator <IEnumerable <KeyValuePair <TKey, TValue> >, KeyValuePair <TKey, TValue>, TState> .FindAllocationFreeForEachDelegate(instance);
示例#3
0
        /// <summary>
        /// Enumerates over an <see cref="IEnumerable{TItem}" /> instance without allocation if a struct GetEnumerator is available.
        /// </summary>
        /// <param name="instance">The enumerable instance.</param>
        /// <param name="state">State to be passed on each call.</param>
        /// <param name="itemCallback">Delegate to be called as items are retrieved from the enumerator.</param>
#pragma warning disable CA1000 // Do not declare static members on generic types
        public static void AllocationFreeForEach(TEnumerable instance, ref TState state, StructEnumeratorForEachDelegate <TItem, TState> itemCallback)
#pragma warning restore CA1000 // Do not declare static members on generic types
        {
            Debug.Assert(itemCallback != null);

            StructEnumerator <TEnumerable, TItem, TState> .AllocationFreeForEachDelegate allocationFreeForEachDelegate = FindAllocationFreeForEachDelegate(
                instance);

            allocationFreeForEachDelegate(instance, ref state, itemCallback);
        }