Class BatchableSource<T>
Represents a batch of items that can be split if not all items can be processed at once.
public sealed class BatchableSource<T> : IBatchableSource<T>
Type Parameters
T
The type of the items.
- Inheritance
-
BatchableSource<T>
- Implements
- Inherited Members
Constructors
BatchableSource(IEnumerable<T>)
Initializes a new instance of the BatchableSource<T> class.
[Obsolete("Use one of the other constructors instead.")]
public BatchableSource(IEnumerable<T> batch)
Parameters
batch
IEnumerable<T>The single batch.
Remarks
Use this overload when you know the batch is small and won't have to be broken up into sub-batches. In that case using this overload is simpler than using an enumerator and using the other constructor.
BatchableSource(IEnumerator<T>)
Initializes a new instance of the BatchableSource<T> class.
[Obsolete("Use one of the other constructors instead.")]
public BatchableSource(IEnumerator<T> enumerator)
Parameters
enumerator
IEnumerator<T>The enumerator that will provide the items for the batch.
BatchableSource(IReadOnlyList<T>, bool)
Initializes a new instance of the BatchableSource<T> class.
public BatchableSource(IReadOnlyList<T> items, bool canBeSplit = false)
Parameters
items
IReadOnlyList<T>The items.
canBeSplit
boolif set to
true
the batch can be split.
BatchableSource(IReadOnlyList<T>, int, int, bool)
Initializes a new instance of the BatchableSource<T> class.
public BatchableSource(IReadOnlyList<T> items, int offset, int count, bool canBeSplit)
Parameters
items
IReadOnlyList<T>The items.
offset
intThe offset.
count
intThe count.
canBeSplit
boolif set to
true
the batch can be split.
Properties
AllItemsWereProcessed
Gets a value indicating whether all items were processed.
public bool AllItemsWereProcessed { get; }
Property Value
- bool
true
if all items were processed; otherwise,false
.
CanBeSplit
Gets a value indicating whether the batch can be split.
public bool CanBeSplit { get; }
Property Value
- bool
true
if the batch can be split; otherwise,false
.
Count
Gets the count.
public int Count { get; }
Property Value
- int
The count.
Items
Gets the items.
public IReadOnlyList<T> Items { get; }
Property Value
- IReadOnlyList<T>
The items.
Offset
Gets the offset.
public int Offset { get; }
Property Value
- int
The offset.
ProcessedCount
Gets the count of processed items. Equal to zero until SetProcessedCount has been called.
public int ProcessedCount { get; }
Property Value
- int
The count of processed items.
Methods
AdvancePastProcessedItems()
Advances past the processed items.
public void AdvancePastProcessedItems()
GetBatchItems()
Gets the items in the batch.
public IReadOnlyList<T> GetBatchItems()
Returns
- IReadOnlyList<T>
The items in the batch.
GetProcessedItems()
Gets the items that were processed.
public IReadOnlyList<T> GetProcessedItems()
Returns
- IReadOnlyList<T>
The items that were processed.
GetUnprocessedItems()
Gets the items that were not processed.
public IReadOnlyList<T> GetUnprocessedItems()
Returns
- IReadOnlyList<T>
The items that were not processed.
SetProcessedCount(int)
Sets the processed count.
public void SetProcessedCount(int value)
Parameters
value
intThe value.