Runnable console applications for Skymly/DesignPatterns — Strategy, Chain of Responsibility, Composite, Factory Registry, Decorator, Event Aggregator, State transition table, Singleton, and MSDI integration.
- .NET SDK 8 (see
global.json)
Samples default to a local sibling of the generator repo for development:
<workspace-root>/
Skymly/
DesignPatterns/
DesignPatterns/
DesignPatterns.Samples/ ← this repo
DesignPatterns.Docs/
git clone https://github.com/Skymly/DesignPatterns.git
git clone https://github.com/Skymly/DesignPatterns.Samples.git
cd DesignPatterns.SamplesWhen ../DesignPatterns/DesignPatterns.slnx exists, UseLocalDesignPatterns is true by default (Directory.Build.props).
dotnet run --project DesignPatterns.Samples.Strategy -c Release
dotnet run --project DesignPatterns.Samples.DependencyInjection -c Release./build.ps1 --target Ci --configuration ReleaseEquivalent: dotnet run --project build/_build.csproj -- --root . --target Ci --configuration Release
| Sample | Demonstrates |
|---|---|
| DesignPatterns.Samples.Strategy | [RegisterStrategy] → Keys + static Instance registry; sync pay + async ExecuteAsync; guard predicate (TryGetWithGuard); execution tracing (ExecuteTracedAsync) |
| DesignPatterns.Samples.Chain | [HandlerOrder] → generated handler pipeline; traced invocation (InvokeTracedAsync); exception observability (IHandlerExceptionObserver) |
| DesignPatterns.Samples.Composite | [CompositePart] → BuildForest() / TraverseForest (+ BuildRoot, manual builder) |
| DesignPatterns.Samples.Factory | [RegisterFactory] factory registry; async factory (IAsyncFactoryRegistry); pooled factory (IPooledFactoryRegistry with RentAsync/Return) |
| DesignPatterns.Samples.RegisterFactory | Manual FactoryRegistryBuilder registration |
| DesignPatterns.Samples.Decorator | [Decorator] → stack + DecoratorOrder + conditional Add |
| DesignPatterns.Samples.EventAggregator | IEventAggregator publish/subscribe; error isolation (ContinueOnError); publish tracing (PublishTracedAsync) |
| DesignPatterns.Samples.GenerateSingleton | [GenerateSingleton] lazy singleton |
| DesignPatterns.Samples.DependencyInjection | RegisterDi for Strategy / Factory / Handler |
| DesignPatterns.Samples.State | Manual TransitionTableBuilder + [StateMachine] / [Transition] order lifecycle; guard predicates; entry/exit actions; IStateMachine wrapper; TransitionTrace |
| DesignPatterns.Samples.PluginAssemblies | Multi-assembly [RegisterStrategy] + RegisterAutofac + RegistryConfiguration (IConfiguration; see nested README) |
The published 0.2.3-preview2 package is pinned in Directory.Build.props. To run
the package-backed samples, set UseLocalDesignPatterns=false:
dotnet run --project build/_build.csproj -- --root . --target Ci --configuration Release --use-local-design-patterns falsePluginAssemblies also works fully from NuGet (Skymly.DesignPatterns + Autofac + Configuration extensions) when UseLocalDesignPatterns=false.
| Link | Description |
|---|---|
| DesignPatterns | Runtime, source generators, tests |
| DesignPatterns.Docs | User documentation (VitePress) |
MIT — see LICENSE.