autofac/Examples
소개
Example projects that consume and demonstrate Autofac IoC functionality and integration
개발 도구What you can do
- GenericHostBuilderExample - The generic host without ASP.NET Core, for worker services - Autofac.Extensions.DependencyInjection
- ConfigurationExample - Registering from autofac.json, including an unreferenced plugin assembly - Autofac.Configuration
- AttributeMetadataExample - Metadata by string, class, interface, and attribute, then filtering on it - Autofac.Extras.AttributeMetadata
- MultitenantExample.ConsoleApplication - Per-tenant overrides with no web request in sight - Autofac.Multitenant
측정된 스타 증가
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 기록 수집 중
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
OriginalAutofac Examples
Example projects that consume and demonstrate Autofac functionality and integration.
The Examples
Each example has its own README with what it shows and how to run it.
ASP.NET Core
| Example | Demonstrates | Packages |
|---|---|---|
| AspNetCoreExample | A Startup class whose ConfigureContainer takes a ContainerBuilder |
Autofac.Extensions.DependencyInjection |
| AspNetCoreNoStartupExample | The same wiring in the minimal hosting model, with no Startup class |
Autofac.Extensions.DependencyInjection |
| AspNetCoreChildLifetimeScope | Two hosts sharing one container, each rooted in its own child scope | Autofac.Extensions.DependencyInjection |
| MultitenantExample.AspNetCore | Per-tenant registration overrides, with the tenant read from the query string | Autofac.AspNetCore.Multitenant |
Hosting and core features
| Example | Demonstrates | Packages |
|---|---|---|
| GenericHostBuilderExample | The generic host without ASP.NET Core, for worker services | Autofac.Extensions.DependencyInjection |
| ConfigurationExample | Registering from autofac.json, including an unreferenced plugin assembly |
Autofac.Configuration |
| AttributeMetadataExample | Metadata by string, class, interface, and attribute, then filtering on it | Autofac.Extras.AttributeMetadata |
| MultitenantExample.ConsoleApplication | Per-tenant overrides with no web request in sight | Autofac.Multitenant |
| DynamicProxyExample | Method interception, wired both on the registration and by attribute | Autofac.Extras.DynamicProxy |
| PoolingExample | Reusing expensive instances across scopes, with a reset-on-return policy | Autofac.Pooling |
| DotGraphExample | Capturing a resolve operation as a Graphviz graph for troubleshooting | Autofac.Diagnostics.DotGraph |
| MiddlewarePipelineExample | Resolve middleware for auditing, timing, caching, ambient state, and scope guards | Autofac |
.NET Framework
These target net481 and need Windows. Most run under IIS Express from Visual Studio.
| Example | Demonstrates | Packages |
|---|---|---|
| MvcExample | MVC 5 controllers, action filters, and view pages, plus a WCF client | Autofac.Mvc5, Autofac.Wcf |
| WebFormsExample | Property injection into pages that cannot take constructor arguments | Autofac.Web |
| WcfExample | A WCF service whose implementation is resolved from the container | Autofac.Wcf |
| WebApiExample.OwinSelfHost | Web API 2 self-hosted under OWIN instead of IIS | Autofac.Owin, Autofac.WebApi2, Autofac.WebApi2.Owin |
| MultitenantExample.WcfService | A WCF service resolving a different implementation per tenant | Autofac.Multitenant.Wcf, Autofac.Wcf |
| MultitenantExample.MvcApplication | The client half, carrying tenant identity across the service boundary | Autofac.Multitenant, Autofac.Mvc5 |
ConfigurationExampleInterface and ConfigurationExamplePlugin are supporting libraries for ConfigurationExample rather than examples themselves.
Reading the Examples
The examples in the repo are always for the latest Autofac versions and libraries. Look at the tags on this repo to see examples for older and/or deprecated functionality.
The examples attempt to stick pretty close to the Autofac documentation so it helps to have that available.
Open this repo in Visual Studio Code.
Building the Examples
Examples.slnx contains every sample. The ASP.NET MVC, Web Forms, WCF, and OWIN self-host samples target .NET Framework, so building the whole solution requires Windows; the rest build anywhere.
관련 프로젝트 살펴보기
불러오는 중…