AnonymousEnumerable.cs 810 B

12345678910111213141516171819202122232425262728
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the Apache 2.0 License.
  3. // See the LICENSE file in the project root for more information.
  4. using System.Collections.Generic;
  5. namespace System.Reactive
  6. {
  7. internal sealed class AnonymousEnumerable<T> : IEnumerable<T>
  8. {
  9. private readonly Func<IEnumerator<T>> getEnumerator;
  10. public AnonymousEnumerable(Func<IEnumerator<T>> getEnumerator)
  11. {
  12. this.getEnumerator = getEnumerator;
  13. }
  14. public IEnumerator<T> GetEnumerator()
  15. {
  16. return getEnumerator();
  17. }
  18. System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
  19. {
  20. return this.GetEnumerator();
  21. }
  22. }
  23. }