Skip to content

Factory Registry

Namespace: DesignPatterns.Creational

Overview

Map keys to product factories — similar to Strategy but for creating instances (Create() / IFactoryRegistry).

Runtime

  • IFactoryRegistry<TKey, TProduct> — extends read-only registry with Create
  • FactoryRegistryBuilder<TKey, TProduct> — fluent manual registration

Source generator

[RegisterFactory(typeof(TProduct), "key")] on factory types; partial static registry holder.

csharp
[RegisterFactory(typeof(IProduct), "standard")]
public sealed class StandardProductFactory : IProductFactory { ... }

Diagnostics

DP020–DP023, DP025 (unknown literal keys). See Registry key conventions.

Samples

SampleFocus
FactoryGenerated registry
RegisterFactoryManual builder

Maintainer doc: docs/FactoryRegistry.md (中文).

Released under the MIT License.