{"id":27878856,"url":"https://github.com/structuremap/structuremap.microsoft.dependencyinjection","last_synced_at":"2025-05-05T03:15:52.231Z","repository":{"id":36311239,"uuid":"40615870","full_name":"structuremap/StructureMap.Microsoft.DependencyInjection","owner":"structuremap","description":"StructureMap integration for ASP.NET Core","archived":false,"fork":false,"pushed_at":"2021-01-19T18:54:29.000Z","size":600,"stargazers_count":72,"open_issues_count":13,"forks_count":29,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-05-05T03:15:46.316Z","etag":null,"topics":["aspnetcore","structuremap"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/structuremap.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-08-12T17:55:00.000Z","updated_at":"2023-04-08T14:08:09.000Z","dependencies_parsed_at":"2022-09-05T06:51:12.145Z","dependency_job_id":null,"html_url":"https://github.com/structuremap/StructureMap.Microsoft.DependencyInjection","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/structuremap%2FStructureMap.Microsoft.DependencyInjection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/structuremap%2FStructureMap.Microsoft.DependencyInjection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/structuremap%2FStructureMap.Microsoft.DependencyInjection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/structuremap%2FStructureMap.Microsoft.DependencyInjection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/structuremap","download_url":"https://codeload.github.com/structuremap/StructureMap.Microsoft.DependencyInjection/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252429977,"owners_count":21746574,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aspnetcore","structuremap"],"created_at":"2025-05-05T03:15:51.652Z","updated_at":"2025-05-05T03:15:52.225Z","avatar_url":"https://github.com/structuremap.png","language":"C#","readme":"# :warning: As [StructureMap has been sunsetted](https://jeremydmiller.com/2018/01/29/sunsetting-structuremap/), it's recommended to move to [Lamar](https://jasperfx.github.io/lamar/), StructureMap's successor, which is more compatible with ASP.NET Core's DI system. :warning:\n\n# StructureMap integration for ASP.NET Core [![Build status](https://ci.appveyor.com/api/projects/status/i8r7pb6kqcvj9vdq/branch/master?svg=true)](https://ci.appveyor.com/project/khellang/structuremap-microsoft-dependencyinjection/branch/master)\n\n\nThis repository contains the source of two NuGet packages:\n\n - StructureMap.AspNetCore\n - StructureMap.Microsoft.DependencyInjection (formerly known as StructureMap.Dnx)\n\nThese packages provide integration with ASP.NET Core and the built-in container on different levels.\n\n## StructureMap.AspNetCore\n\nAdds integration with the ASP.NET Core hosting mechanism.\n\n### Installation\n\nAdd `StructureMap.AspNetCore` to your project:\n\n```json\n\u003cItemGroup\u003e\n  \u003cPackageReference Include=\"StructureMap.AspNetCore\" Version\"\u003cversion\u003e\" /\u003e\n\u003c/ItemGroup\u003e\n```\n\n### Usage\n\nThe package adds the `UseStructureMap` extension method to `IWebHostBuilder`. Calling this method will instruct the ASP.NET Core host to\ncreate a StructureMap `Registry` and optionally let the user configure it using a `Startup.ConfigureContainer(Registry)` method.\n\n### Example\n\n```csharp\nusing System.IO;\nusing Microsoft.AspNetCore.Hosting;\nusing StructureMap.AspNetCore;\n\npublic static class Program\n{\n    public static void Main(string[] args)\n    {\n        CreateWebHostBuilder(args).Build().Run();\n    }\n\n    public static IWebHostBuilder CreateWebHostBuilder(string[] args) =\u003e\n        WebHost.CreateDefaultBuilder(args)\n            .UseStructureMap() // Add support for StructureMap\n            .UseStartup\u003cStartup\u003e();\n}\n```\n\nThe runtime will then look for a `ConfigureContainer` method on the specified `Startup` class:\n\n```csharp\npublic class Startup\n{\n    public void ConfigureServices(IServiceCollection services)\n    {\n        // Configure the ASP.NET specific stuff.\n    }\n\n    public void ConfigureContainer(Registry registry)\n    {\n        // Use StructureMap-specific APIs to register services in the registry.\n    }\n\n    public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)\n    {\n    }\n}\n```\n\n\n## StructureMap.Microsoft.DependencyInjection\n\nAdds StructureMap support for [Microsoft.Extensions.DependencyInjection](https://github.com/aspnet/DependencyInjection)\n\n### Installation\n\nAdd `StructureMap.Microsoft.DependencyInjection` to your project:\n\n```json\n\u003cItemGroup\u003e\n  \u003cPackageReference Include=\"StructureMap.Microsoft.DependencyInjection\" Version\"\u003cversion\u003e\" /\u003e\n\u003c/ItemGroup\u003e\n```\n\n### Usage\n\nThe package contains a single, public extension method, `Populate`.\nIt's used to populate a StructureMap container using a set of `ServiceDescriptors` or an `IServiceCollection`.\n\n#### Example\n\n```csharp\nusing System;\nusing Microsoft.Extensions.DependencyInjection;\nusing StructureMap;\n\npublic class Startup\n{\n    public IServiceProvider ConfigureServices(IServiceCollection services)\n    {\n        services.AddMvc();\n        services.AddWhatever();\n\n        var container = new Container();\n        \n        // You can populate the container instance in one of two ways:\n        \n        // 1. Use StructureMap's `Configure` method and call\n        //    `Populate` on the `ConfigurationExpression`.\n        \n        container.Configure(config =\u003e\n        {\n            // Register stuff in container, using the StructureMap APIs...\n\n            config.Populate(services);\n        });\n        \n        // 2. Call `Populate` directly on the container instance.\n        //    This will internally do a call to `Configure`.\n        \n        // Register stuff in container, using the StructureMap APIs...\n\n        // Here we populate the container using the service collection.\n        // This will register all services from the collection\n        // into the container with the appropriate lifetime.\n        container.Populate(services);\n\n        // Finally, make sure we return an IServiceProvider. This makes\n        // ASP.NET use the StructureMap container to resolve its services.\n        return container.GetInstance\u003cIServiceProvider\u003e();\n    }\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstructuremap%2Fstructuremap.microsoft.dependencyinjection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstructuremap%2Fstructuremap.microsoft.dependencyinjection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstructuremap%2Fstructuremap.microsoft.dependencyinjection/lists"}