Skip to content

Commit

Permalink
Updated readme to provide less immediate walkthrough and more project…
Browse files Browse the repository at this point in the history
…-related guidance.
  • Loading branch information
tillig committed Sep 14, 2015
1 parent 763bf8b commit 8a20057
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 89 deletions.
131 changes: 44 additions & 87 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,126 +2,83 @@

Autofac is an [IoC container](http://martinfowler.com/articles/injection.html) for Microsoft .NET. It manages the dependencies between classes so that **applications stay easy to change as they grow** in size and complexity. This is achieved by treating regular .NET classes as *[components](http://autofac.readthedocs.org/en/latest/glossary.html)*.

[![Build status](https://ci.appveyor.com/api/projects/status/s0vgb4m8tv9ar7we?svg=true)](https://ci.appveyor.com/project/Autofac/autofac)

## NuGet Packages
![MyGet publish status](https://www.myget.org/BuildSource/Badge/autofac?identifier=e0f25040-634c-4b7d-aebe-0f62b9c465a8)

You can get Autofac by [grabbing the latest NuGet packages](https://github.com/autofac/Autofac/wiki/Nu-Get-Packages) or using [our NuGet script builder](http://autofac.org/scriptgen/) to get exactly what you need. A few older versions remain for download [here](https://code.google.com/p/autofac/downloads/list).
## Get Packages

## Getting Help
You can get Autofac by [grabbing the latest NuGet packages](https://github.com/autofac/Autofac/wiki/Nu-Get-Packages) or using [our NuGet script builder](http://autofac.org/scriptgen/) to get exactly what you need.

If you're feeling adventurous, [continuous integration builds are on MyGet](https://www.myget.org/gallery/autofac).

[Release notes are available on the wiki](https://github.com/autofac/Autofac/wiki/Release-Notes).

## Get Help

**Need help with Autofac?** We have [a documentation site](http://autofac.readthedocs.org/) as well as [API documentation](http://autofac.org/apidoc/). We're ready to answer your questions on [Stack Overflow](http://stackoverflow.com/questions/tagged/autofac) or check out the [discussion forum](https://groups.google.com/forum/#forum/autofac).

## Getting Started
## Get Started

Our [Getting Started](http://autofac.readthedocs.org/en/latest/getting-started/index.html) tutorial walks you through integrating Autofac with a simple application and gives you some starting points for learning more.

### Adding Components
Super-duper quick start:

_[Components are registered](http://autofac.readthedocs.org/en/latest/register/registration.html)_ with a `ContainerBuilder`:
[Register components with a `ContainerBuilder`](http://autofac.readthedocs.org/en/latest/register/registration.html) and then build the component container.

```C#
var builder = new ContainerBuilder();
```

Autofac can use [a Linq expression, a .NET type, or a pre-built instance](http://autofac.readthedocs.org/en/latest/register/registration.html) as a component:

```C#
builder.Register(c => new TaskController(c.Resolve<ITaskRepository>()));

builder.RegisterType<TaskController>();

builder.RegisterInstance(new TaskController());
```

Or, Autofac can find and register the component types in an assembly:

```C#
builder.RegisterAssemblyTypes(controllerAssembly);
```

Calling `Build()` creates a _container_:

```C#
var container = builder.Build();
```

To retrieve a _component instance_ from a container, a _[service](http://autofac.readthedocs.org/en/latest/glossary.html)_ is requested. By default, components provide their concrete type as a service:
[Resolve services from a lifetime scope](http://autofac.readthedocs.org/en/latest/resolve/index.html) - either the container or a nested scope:

```C#
var taskController = container.Resolve<TaskController>();
```

To specify that the component’s service is an interface, the `As()` method is used at registration time:

```C#
builder.RegisterType<TaskController>().As<IController>();
// enabling
var taskController = container.Resolve<IController>();
```

### Expressing Dependencies

When Autofac instantiates a component, it satisfies the component's _dependencies_ by finding and instantiating other components.

Components express their dependencies to Autofac as constructor parameters:

```C#
public class TaskController : IController
{
public TaskController(ITaskRepository tasks) { ... }
}
```

In this case Autofac will look for another component that provides the `ITaskRepository` service and call the constructor of `TaskController` with that component as a parameter.

If there is more than one constructor on a component type, Autofac will use the constructor with the most resolvable parameters.

```C#
public TaskController(ITaskRepository tasks)
public TaskController(ITaskRepository tasks, ILog log)
```

Default parameter values can be used to express optional dependencies (properties can be used instead if you prefer):

```C#
public TaskController(ITaskRepository tasks, ILog log = null)
```

[Circular references](http://autofac.readthedocs.org/en/latest/advanced/circular-dependencies.html) can be constructed by declaring one of the parameters to be of type `Lazy<T>`.

```C#
public TaskController(Lazy<ITaskRepository> tasks)
```

Autofac understands an advanced vocabulary of "[relationship types](http://autofac.readthedocs.org/en/latest/resolve/relationships.html)" like `Lazy<T>`, `Func<T>`, `IEnumerable<T>` and others, to vary the relationship between a component and its dependencies.

## Highlights

Autofac keeps out of your way and places as few constraints on your design as possible.

**Simple Extension Points:** [Activation events](http://autofac.readthedocs.org/en/latest/lifetime/events.html) like `OnActivating(e => e.Instance.Start())` can achieve a lot of customization in very little code.

**Robust Resource Management:** Autofac [takes on the burden](http://autofac.readthedocs.org/en/latest/lifetime/disposal.html) of tracking disposable components to ensure that resources are released when they should be.

**Flexible Module System:** Strike a balance between the deployment-time benefits of [XML configuration](http://autofac.readthedocs.org/en/latest/configuration/xml.html) and the clarity of C# code with [Autofac modules](http://autofac.readthedocs.org/en/latest/configuration/modules.html).

## Status

> Autofac moved to GitHub on the 22nd January, 2013. The process of cleaning up the issues list and wiki content is ongoing. You may stumble across some invalid links while we sort out problems from the migration. The code and NuGet packages all remain in a consistent state.
You can get the latest releases from [NuGet](https://www.nuget.org/packages?q=Author%3A%22Autofac+Contributors%22+Owner%3A%22alexmg%22+Autofac*). [Release notes are available on the wiki](https://github.com/autofac/Autofac/wiki/Release-Notes).

If you're feeling bold, you can get [continuous integration builds from MyGet](https://www.myget.org/gallery/autofac).
There is a growing number of [application integration libraries](http://autofac.readthedocs.org/en/latest/integration/index.html) that make using Autofac with your application a snap. Support for several popular frameworks is also available through the "Extras" packages.

![](https://www.myget.org/BuildSource/Badge/autofac?identifier=e0f25040-634c-4b7d-aebe-0f62b9c465a8)
**[Intrigued? Check out our Getting Started walkthrough!](http://autofac.readthedocs.org/en/latest/getting-started/index.html)**

There is a growing number of [integrations](http://autofac.readthedocs.org/en/latest/integration/index.html) that make using Autofac with your application a snap. Support for several popular frameworks is also available through the "Extras" packages.
## Project

Autofac is licensed under the MIT license, so you can comfortably use it in commercial applications (we still love [contributions](http://autofac.readthedocs.org/en/latest/contributors.html) though).

## Contributing
**File issues in the repo with the associated feature/code.**

- [Autofac](https://github.com/autofac/Autofac) - Core dependency resolution and common functions (this repo).
- [Autofac.Configuration](https://github.com/autofac/Autofac.Configuration) - JSON/XML file-based configuration support.
- [Autofac.Extras.AggregateService](https://github.com/autofac/Autofac.Extras.AggregateService) - Dynamic aggregate service implementation generation.
- [Autofac.Extras.AttributeMetadata](https://github.com/autofac/Autofac.Extras.AttributeMetadata) - Metadata scanning/filtering through attributes.
- [Autofac.Extras.CommonServiceLocator](https://github.com/autofac/Autofac.Extras.CommonServiceLocator) - Common Service Locator implementation backed by Autofac.
- [Autofac.Extras.DomainServices](https://github.com/autofac/Autofac.Extras.DomainServices) - RIA/domain services support.
- [Autofac.Extras.DynamicProxy](https://github.com/autofac/Autofac.Extras.DynamicProxy) - Decorators and interceptors.
- [Autofac.Extras.EnterpriseLibraryConfigurator](https://github.com/autofac/Autofac.Extras.EnterpriseLibraryConfigurator) - Enterprise Library 5 configuration support.
- [Autofac.Extras.FakeItEasy](https://github.com/autofac/Autofac.Extras.FakeItEasy) - FakeItEasy mocking framework integration.
- [Autofac.Extras.Moq](https://github.com/autofac/Autofac.Extras.Moq) - Moq mocking framework integration.
- [Autofac.Extras.MvvmCross](https://github.com/autofac/Autofac.Extras.MvvmCross) - MvvmCross integration.
- [Autofac.Extras.NHibernate](https://github.com/autofac/Autofac.Extras.NHibernate) - NHibernate integration.
- [Autofac.Mef](https://github.com/autofac/Autofac.Mef) - MEF catalog integration.
- [Autofac.Multitenant.Wcf](https://github.com/autofac/Autofac.Multitenant.Wcf) - Multitenant WCF service hosting.
- [Autofac.Multitenant](https://github.com/autofac/Autofac.Multitenant) - Multitenant dependency resolution support.
- [Autofac.Mvc.Owin](https://github.com/autofac/Autofac.Mvc.Owin) - OWIN support for ASP.NET MVC.
- [Autofac.Owin](https://github.com/autofac/Autofac.Owin) - Core OWIN support - shared middleware for request lifetime integration.
- [Autofac.SignalR](https://github.com/autofac/Autofac.SignalR) - Application integration for SignalR.
- [Autofac.Wcf](https://github.com/autofac/Autofac.Wcf) - WCF service hosting.
- [Autofac.Web](https://github.com/autofac/Autofac.Web) - ASP.NET web forms integration.
- [Autofac.WebApi.Owin](https://github.com/autofac/Autofac.WebApi.Owin) - OWIN support for Web API.
- [Autofac.WebApi](https://github.com/autofac/Autofac.WebApi) - Application integration for Web API.

## Contributing / Pull Requests

Refer to the [Readme for Autofac Developers](https://github.com/autofac/Autofac/blob/master/developers.md)
for setting up, building Autofac and generating the related documentation. We also have a [contributors guide](http://autofac.readthedocs.org/en/latest/contributors.html) to help you get started.
for setting up and building Autofac source. We also have a [contributors guide](http://autofac.readthedocs.org/en/latest/contributors.html) to help you get started.


3 changes: 1 addition & 2 deletions developers.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@ Autofac follows the [Gitflow workflow process](https://www.atlassian.com/git/tut
- **All** of the latest .NET, VS, and SQL patches through Microsoft Update.
- **All** of the latest VS updates (stable/RTM, not RC) through VS Extension
Manager.
- A git client in your path (so the `dnu sources` repo embedding works during the packaging).

## Building the Project

At a PowerShell prompt run `build.ps1`.

This will build everything in a release configuration and create NuGet packages. It will also run tests and code analysis.

**Note for developers:** If you are working on the Autofac core, there is
**Note:** If you are working on the Autofac core, there is
also a project in `test/Autofac.Tests.AppCert` that should be built/run
separately to verify changes will pass Windows App Store certification. This
build is not chained into the standard developer build since it takes time to
Expand Down

0 comments on commit 8a20057

Please sign in to comment.