{"id":19700430,"url":"https://github.com/balazs-kis/dilite","last_synced_at":"2025-06-14T19:08:22.627Z","repository":{"id":56563439,"uuid":"242977544","full_name":"balazs-kis/dilite","owner":"balazs-kis","description":"DiLite /dɪˈlʌɪt/ is a minimalist, lightweight DI framework.","archived":false,"fork":false,"pushed_at":"2020-10-31T12:57:28.000Z","size":105,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-29T13:41:46.789Z","etag":null,"topics":["csharp","csharp-library","dependency-injection","dependency-injection-container","inversion-of-control","ioc","ioc-container","netcore","netstandard"],"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/balazs-kis.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":"2020-02-25T10:55:04.000Z","updated_at":"2020-11-20T12:11:57.000Z","dependencies_parsed_at":"2022-08-15T21:00:46.435Z","dependency_job_id":null,"html_url":"https://github.com/balazs-kis/dilite","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/balazs-kis/dilite","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/balazs-kis%2Fdilite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/balazs-kis%2Fdilite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/balazs-kis%2Fdilite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/balazs-kis%2Fdilite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/balazs-kis","download_url":"https://codeload.github.com/balazs-kis/dilite/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/balazs-kis%2Fdilite/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259868583,"owners_count":22924236,"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":["csharp","csharp-library","dependency-injection","dependency-injection-container","inversion-of-control","ioc","ioc-container","netcore","netstandard"],"created_at":"2024-11-11T21:06:01.072Z","updated_at":"2025-06-14T19:08:22.597Z","avatar_url":"https://github.com/balazs-kis.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"![DiLite](/logo.png)\n\nDiLite /dɪˈlʌɪt/ is a minimalist, lightweight DI framework. Registrations and resolutions will look very familiar to those accustomed to Autofac.\n\n[![Build Status](https://github.com/balazs-kis/dilite/workflows/build/badge.svg \"Build Status\")](https://github.com/balazs-kis/dilite/actions?query=workflow%3A%22build%22)\n[![Coverage Status](https://codecov.io/gh/balazs-kis/dilite/branch/master/graph/badge.svg)](https://codecov.io/gh/balazs-kis/dilite)\n[![Nuget](https://img.shields.io/nuget/v/di-lite)](https://www.nuget.org/packages/di-lite)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n## Usage\n\nCreate a `ContainerBuilder`, make the registrations, then build your `Container`:\n```csharp\nvar containerBuilder = new ContainerBuilder();\ncontainerBuilder.RegisterType\u003cMyClass\u003e().As\u003cIMyClass\u003e();\nvar container = containerBuilder.Build();\n```\nThen simply resolve what you need from the `Container`:\n```csharp\nvar myInstance = container.Resolve\u003cIMyClass\u003e();\n```\n\n\n## Features\n\n### 1. Single instance\nEach resolution call to the container will create a new instance of the registered type, unless it is specified as a singleton during registration. To register a type as a singleton, just use the `AsSingleInstance` method:\n```csharp\ncontainerBuilder.RegisterType\u003cMyClass\u003e().As\u003cIMyClass\u003e().AsSingleInstance();\n```\n\n### 2. As self\nIf no *alias* is specified during the registration of a type, it will be registered as itself.\n```csharp\ncontainerBuilder.RegisterType\u003cMyClass\u003e();\n```\nIt can be resolved as:\n```csharp\nvar myInstance = container.Resolve\u003cMyClass\u003e();\n```\n\nIf another *alias* is specified, but the registration as itself is also needed, the `AsSelf` method must be used:\n```csharp\ncontainerBuilder.RegisterType\u003cMyClass\u003e().As\u003cIMyClass\u003e().AsSelf();\n```\n\n### 3. Multiple registrations for the same *alias*\nMultiple registrations can be made for the same *alias*:\n```csharp\ncontainerBuilder.RegisterType\u003cMyClassImplementation1\u003e().As\u003cIMyClass\u003e();\ncontainerBuilder.RegisterType\u003cMyClassImplementation2\u003e().As\u003cIMyClass\u003e();\n```\nIn this case, the `Resolve` method will return an instance of `MyClassImplementation2` because it was the last one registered for that *alias*. By using the `ResolveAll` method, all registrations for the *alias* will be returned:\n```csharp\nIEnumerable\u003cIMyClass\u003e myInstances = container.ResolveAll\u003cIMyClass\u003e();\n```\n\n### 4. Factory method registrations\nFactory methods can also be registered as `Func\u003cIContainer, T\u003e`:\n```csharp\ncontainerBuilder.RegisterFactoryMethod(container =\u003e\n{\n    var dep1 = container.Resolve\u003cIDependency1\u003e();\n    var dep2 = container.Resolve\u003cIDependency2\u003e();\n    return new MyClass(dep1, dep2);\n}).As\u003cIMyClass\u003e();\n```\nThese registrations can be resolved as their simple type counterparts:\n```csharp\nvar myInstance = container.Resolve\u003cIMyClass\u003e();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbalazs-kis%2Fdilite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbalazs-kis%2Fdilite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbalazs-kis%2Fdilite/lists"}