{"id":22538408,"url":"https://github.com/shuttle/shuttle.core.dependencyinjection","last_synced_at":"2025-03-28T06:43:32.251Z","repository":{"id":66349402,"uuid":"504516326","full_name":"Shuttle/Shuttle.Core.DependencyInjection","owner":"Shuttle","description":"Add dependencies to `IServiceCollection` by convention.","archived":false,"fork":false,"pushed_at":"2025-02-02T05:28:47.000Z","size":36,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-02T06:23:28.608Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Shuttle.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-06-17T11:53:42.000Z","updated_at":"2024-11-11T14:58:22.000Z","dependencies_parsed_at":"2024-01-13T12:39:08.935Z","dependency_job_id":"535dac34-74a6-4422-bebd-e79523225009","html_url":"https://github.com/Shuttle/Shuttle.Core.DependencyInjection","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shuttle%2FShuttle.Core.DependencyInjection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shuttle%2FShuttle.Core.DependencyInjection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shuttle%2FShuttle.Core.DependencyInjection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shuttle%2FShuttle.Core.DependencyInjection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Shuttle","download_url":"https://codeload.github.com/Shuttle/Shuttle.Core.DependencyInjection/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245984556,"owners_count":20704794,"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":[],"created_at":"2024-12-07T11:11:57.223Z","updated_at":"2025-03-28T06:43:32.228Z","avatar_url":"https://github.com/Shuttle.png","language":"C#","readme":"# Shuttle.Core.DependencyInjection\n\n```\nPM\u003e Install-Package Shuttle.Core.DependencyInjection\n```\n\nAdd components to `IServiceCollection` by convention:\n\n```c#\nIServiceCollection services = new ServiceCollection();\n\nservices\n\t.FromAssembly(assembly)\n\t.Add();\n```\n\nThe above would be the simplest case and adds all types using either a matching interface (with the same name as the class prefixed with `I`) or the first interface found.  The default service lifetime is `Singleton`.\n\nIn order to filter the types add a `Filter` function:\n\n```c#\nIServiceCollection services = new ServiceCollection();\n\nservices\n\t.FromAssembly(assembly)\n\t.Filter(type =\u003e type.Name.Equals(\"FilteredType\", StringComparison.InvariantCultureIgnoreCase))\n\t.Add();\n```\n\nIf a particular interface should be used for a selected type it may be specified as follows:\n\n```c#\nIServiceCollection services = new ServiceCollection();\n\nservices\n\t.FromAssembly(assembly)\n\t.GetServiceType(type =\u003e typeof(ISomeInterface))\n\t.Add();\n```\n\nThe service lifetime may also be specified:\n\n```c#\nIServiceCollection services = new ServiceCollection();\n\nservices\n\t.FromAssembly(assembly)\n\t.GetServiceLifetime(type =\u003e ServiceLifetime.Transient)\n\t.Add();\n```\n\nSince this is a builder interface all the bits may be used in combination:\n\n```c#\nIServiceCollection services = new ServiceCollection();\n\nservices\n\t.FromAssembly(assembly)\n\t.Filter(type =\u003e type.Name.Equals(\"FilteredType\", StringComparison.InvariantCultureIgnoreCase))\n\t.GetServiceType(type =\u003e typeof(ISomeInterface))\n\t.GetServiceLifetime(type =\u003e ServiceLifetime.Transient)\n\t.Add();\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshuttle%2Fshuttle.core.dependencyinjection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshuttle%2Fshuttle.core.dependencyinjection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshuttle%2Fshuttle.core.dependencyinjection/lists"}