Class DeferEnumerable<T>
Wraps a load delegate in order to defer an expensive load operation until we know it's actually needed (via a call from somewhere else to GetEnumerator()).
Ensures that the load method will never be called more than once by holding a local reference to the loaded enumeration for return to future calls to
GetEnumerator(), and by substituting an empty T[] result if the loadDelegate happens to return null.
Note that this requires the loadDelegate to be parameterless since it cannot be expected to handle different parameters over time.
Inheritance
DeferEnumerable<T>
Assembly: Estrelica.Utility.dll
Syntax
[Serializable]
[DoNotObfuscateType]
public class DeferEnumerable<T> : IEnumerable<T>, IEnumerable, IDeferrable, ISerializable
Type Parameters
Constructors
Declaration
public DeferEnumerable(Func<IEnumerable<T>> loadDelegate, int reloadMinutes = 0)
Parameters
Declaration
protected DeferEnumerable(SerializationInfo info, StreamingContext context)
Parameters
Properties
Declaration
public IEnumerable<T> Reload { get; }
Property Value
Returns true if the deferred action has been called, false otherwise
Declaration
public bool Resolved { get; }
Property Value
Implements
Methods
Declaration
public IEnumerator<T> GetEnumerator()
Returns
Declaration
[SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.SerializationFormatter)]
public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
Parameters
Implements
Events
Declaration
public event EventHandler OnLoad
Event Type
Implements
Declaration
public event EventHandler OnReset
Event Type
Implements
Operators
Declaration
public static implicit operator DeferEnumerable<T>(Func<IEnumerable<T>> loader)
Parameters
Returns
Declaration
public static implicit operator DeferEnumerable<T>(Expression<Func<IEnumerable<T>>> loader)
Parameters
Returns
Declaration
public static implicit operator DeferEnumerable<T>(LambdaExpression loader)
Parameters
Returns
Extension Methods