autofac/Examples
关于
Example projects that consume and demonstrate Autofac IoC functionality and integration
开发工具可以做什么
- 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
实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- 正在收集历史
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文Autofac 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.
探索相关项目
加载中…