Skip to content

Commit

Permalink
Updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
khellang committed Dec 19, 2016
1 parent b3cd70f commit 663c55a
Showing 1 changed file with 77 additions and 4 deletions.
81 changes: 77 additions & 4 deletions README.md
@@ -1,10 +1,83 @@
# StructureMap.Microsoft.DependencyInjection [![Build status](https://ci.appveyor.com/api/projects/status/tpk77374afp3dk8v?svg=true)](https://ci.appveyor.com/project/khellang/structuremap-dnx)
# StructureMap integration with ASP.NET Core [![Build status](https://ci.appveyor.com/api/projects/status/tpk77374afp3dk8v?svg=true)](https://ci.appveyor.com/project/khellang/structuremap-dnx)

This repository contains the source of two NuGet packages:

- StructureMap.AspNetCore
- StructureMap.Microsoft.DependencyInjection

These packages provide integration with ASP.NET Core and the built-in container on different levels.

## StructureMap.AspNetCore

Adds integration with the ASP.NET Core hosting mechanism.

### Installation

Add `StructureMap.AspNetCore` to your **project.json**:

```json
"dependencies": {
"StructureMap.AspNetCore": "<version>"
}
```

### Usage

The package adds the `UseStructureMap` extension method to `IWebHostBuilder`. Calling this method will instruct the ASP.NET Core host to
create a StructureMap `Registry` and optionally let the user configure it using a `Startup.ConfigureContainer(Registry)` method.

### Example

```csharp
using System.IO;
using Microsoft.AspNetCore.Hosting;

public class Program
{
public static void Main(string[] args)
{
var host = new WebHostBuilder()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseStartup<Startup>()
.UseIISIntegration()
.UseStructureMap()
.UseKestrel()
.Build();

host.Run();
}
}
```

The runtime will then look for a `ConfigureContainer` method on the specified `Startup` class:

```csharp
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
// Configure the ASP.NET specific stuff.
}

public void ConfigureContainer(Registry registry)
{
// Use StructureMap-specific APIs to register services in the registry.
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
}
}
```


## StructureMap.Microsoft.DependencyInjection

(Formerly known as StructureMap.Dnx)

Adds StructureMap support for [Microsoft.Extensions.DependencyInjection](https://github.com/aspnet/DependencyInjection)

## Installation
### Installation

Add `StructureMap.Microsoft.DependencyInjection` to your **project.json**:

Expand All @@ -14,12 +87,12 @@ Add `StructureMap.Microsoft.DependencyInjection` to your **project.json**:
}
```

## Usage
### Usage

The package contains a single, public extension method, `Populate`.
It's used to populate a StructureMap container using a set of `ServiceDescriptors` or an `IServiceCollection`.

### Example
#### Example

```csharp
using System;
Expand Down

0 comments on commit 663c55a

Please sign in to comment.