-
Notifications
You must be signed in to change notification settings - Fork 0
04 01 Overview
Cyberdyne Development edited this page Feb 9, 2026
·
3 revisions
TypeCollections are enhanced enums with O(1) lookups and rich behavior. They replace traditional enums with strongly-typed classes.
- O(1) lookups - Source-generated dictionaries by ID and name
- No reflection - All lookup code generated at compile time
- Rich behavior - Add properties and methods to each option
- Type-safe - Compile-time validation
- Polymorphism - Use properties instead of switch statements
From FilterOperators.cs:
// Access via static property (generated)
var equalOp = FilterOperators.Equal;
Console.WriteLine($" FilterOperators.Equal: {equalOp.Name}");
// Access via lookup
var greaterThan = FilterOperators.ByName("GreaterThan");
Console.WriteLine($" FilterOperators.ByName(\"GreaterThan\"): {greaterThan.Name}");
// Iterate all options
Console.WriteLine($" All operators: {string.Join(", ", FilterOperators.All().Select(p => p.Name))}");
// Use behavior - no switch statements needed!
// Each operator knows how to generate SQL predicates, etc.For TypeCollections with terminal state handling, see ExecutionStatuses:
From IExecutionStatus.cs:12-27:
public interface IExecutionStatus : ITypeOption<int, ExecutionStatusBase>
{
bool IsTerminal { get; }
bool IsSuccess { get; }
bool IsFailure { get; }
bool AllowsRetry { get; }
bool AllowsResume { get; }
bool IsInProgress { get; }
bool HasWarnings { get; }
}| Component | Purpose |
|---|---|
Interface (IPaymentMethod) |
Contract with behavior properties |
Base class (PaymentMethodBase) |
Constructor parameters, get-only properties |
Options (CashPayment, etc.) |
Concrete implementations |
Collection (PaymentMethods) |
Source-generated lookups |
- Base Classes - Defining base classes
- Concrete Options - Creating type options
- Collection Declaration - The [TypeCollection] attribute
- Generated Lookups - Using the generated code