Add examples for DynamicProxy, Pooling, DotGraph, and multitenant ASP.NET Core - #40
Merged
Conversation
….NET Core Four shipping packages had no example at all, which left the documentation as the only reference for them. DynamicProxyExample shows interception wired both ways, on the registration and by attribute on the contract, because which one to reach for is the question people actually have. PoolingExample leans on its own output: sequential scopes share one instance while overlapping scopes each construct their own, and the use count printed after reuse proves the policy reset the instance on its way back to the pool. That distinction is the whole difference between pooling and a singleton. DotGraphExample includes a decorator so the captured graph has an adapter chain worth looking at, rather than a flat list nobody needs a picture of. AspNetCoreMultitenantExample writes its own ITenantIdentificationStrategy, since the package deliberately ships none, and covers the case people get wrong: a tenant with no override falls back to the container default rather than failing. Part of #32
9 tasks
Matches the MultitenantExample.ConsoleApplication, .MvcApplication and .WcfService naming already used for the other multitenant samples, so all four sort together. Namespaces follow the project name, as they do in the sibling projects. It stays in the ASP.NET Core solution folder and the ASP.NET Core section of the README, since that is where someone looking for ASP.NET Core would go first. Part of #32
…ile each The rename in the previous commit left MultitenantExample.AspNetCore sitting in the alphabetical slot its old name occupied. DotGraphExample kept six types in a single Services.cs, which does not match the rest of the repository or the two sibling examples added alongside it. Split with no behaviour change: the captured graph renders byte for byte identically. Part of #32
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #32
First half of item 8. The middleware example for autofac/Documentation#160 follows separately, alongside the documentation changes it needs.
Proposed Changes
Four shipping packages had no example at all. Now they do.
DynamicProxyExample[Intercept]on the contractPoolingExampleDotGraphExampleAspNetCoreMultitenantExampleEach one is registered in
Examples.slnx, has a launch configuration, a README, and a row in the root README table.Choices worth reviewing
PoolingExampleis built around its own output. A pooled registration looks like a singleton until you can see otherwise, so the example prints a line per construction and reports which instance each scope received. Sequential scopes share one instance; overlapping scopes each construct their own. The use count printed after reuse is1rather than2, which is the proof that the policy reset the instance on its way back into the pool — that reset is the actual difference between pooling andSingleInstance.DotGraphExampleregisters a decorator on purpose. A graph of three unrelated services is not worth rendering; an adapter chain is.AspNetCoreMultitenantExamplewrites its ownITenantIdentificationStrategy. The package deliberately ships none — I checked the public surface rather than assuming, since the package README shows aQueryStringTenantIdentificationStrategythat the reader is expected to supply. The example also covers the case people get wrong: a tenant with no registered override falls back to the container default rather than failing.DynamicProxyExampleshows both wiring styles side by side, because "which one do I use" is the question, and either one alone reads like the only option.Verification
All 19 projects build with 0 errors and 0 warnings in Release under the analyzer rules from #37, and both gates pass. Every example was executed:
DynamicProxyExample— both interceptor styles log the call and the return value.PoolingExample— 2 connections constructed across 4 resolves, use count reset on return.DotGraphExample— emits a.dotfile, and I rendered it with Graphviz to confirm it actually parses rather than just looking plausible.AspNetCoreMultitenantExample— no tenant and?tenant=gammaboth resolve the default;alphaandbetaresolve their own overrides.The launch configurations are checked with the same validator from #38: 11 configurations, 11 launchable projects, nothing missing and nothing orphaned. All 95 markdown links resolve, with repo links verified against each clone's
originremote and doc links mapped back to.rstfiles in the Documentation repo.