Class PartitionProvider<TPartitionBase>
Provides efficient storage and retrieval of partitions keyed by their exact concrete Type.
public sealed class PartitionProvider<TPartitionBase> where TPartitionBase : class
Type Parameters
TPartitionBase
- Inheritance
-
PartitionProvider<TPartitionBase>
- Inherited Members
Remarks
The first two concrete types are stored inline. Additional types use provider-owned overflow storage that is cleared and retained after compaction so a later promotion can reuse it. Enumeration and compaction preserve registration order.
Constructors
PartitionProvider()
public PartitionProvider()
Properties
Count
Gets the current number of partitions stored in the provider.
public int Count { get; }
Property Value
IsEmpty
Indicates whether the provider currently contains any partitions. Returns true if empty; otherwise, false.
public bool IsEmpty { get; }
Property Value
Methods
Clear()
Removes all partitions from the provider, clearing its internal storage.
public void Clear()
Has(Type)
Determines whether the provider contains a partition associated with the specified concrete type.
public bool Has(Type partitionType)
Parameters
partitionTypeType
Returns
Has<T>()
Determines whether the provider contains a partition of the specified type. Returns true if such a partition exists; otherwise, false.
public bool Has<T>() where T : TPartitionBase
Returns
Type Parameters
T
TryAdd(Type, TPartitionBase)
Attempts to add a partition to the provider with the specified type key. Returns true if the partition was added; false if a partition with the same type already exists.
public bool TryAdd(Type partitionType, TPartitionBase partition)
Parameters
partitionTypeTypepartitionTPartitionBase
Returns
TryGet(Type, out TPartitionBase?)
Attempts to retrieve a partition associated with the specified concrete type.
public bool TryGet(Type partitionType, out TPartitionBase? partition)
Parameters
partitionTypeTypepartitionTPartitionBase
Returns
TryGet<T>(out T?)
Attempts to retrieve a partition of the specified type. Returns true and sets the out parameter if the partition exists and is of the requested type; otherwise, returns false.
public bool TryGet<T>(out T? partition) where T : TPartitionBase
Parameters
partitionT
Returns
Type Parameters
T
TryRemove(Type, out TPartitionBase?)
Attempts to remove a partition associated with the specified type. If successful, the removed partition is returned in the out parameter. Returns true if the partition was removed; otherwise, false.
public bool TryRemove(Type partitionType, out TPartitionBase? partition)
Parameters
partitionTypeTypepartitionTPartitionBase