{"id":16356988,"url":"https://github.com/ocinbat/anetta","last_synced_at":"2025-10-26T04:30:22.541Z","repository":{"id":86119073,"uuid":"131061424","full_name":"ocinbat/Anetta","owner":"ocinbat","description":"Anetta is a tool for extending Microsoft.Extensions.DependencyInjection DI capabilities with annotations.","archived":false,"fork":false,"pushed_at":"2020-01-29T11:48:01.000Z","size":34,"stargazers_count":7,"open_issues_count":1,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-01-31T14:17:12.302Z","etag":null,"topics":["annotations","aspnetcore","configuration","dependency-injection","di-capabilities"],"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/ocinbat.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":"2018-04-25T20:43:37.000Z","updated_at":"2023-07-20T02:13:39.000Z","dependencies_parsed_at":"2023-03-08T11:00:28.230Z","dependency_job_id":null,"html_url":"https://github.com/ocinbat/Anetta","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/ocinbat%2FAnetta","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ocinbat%2FAnetta/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ocinbat%2FAnetta/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ocinbat%2FAnetta/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ocinbat","download_url":"https://codeload.github.com/ocinbat/Anetta/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238254146,"owners_count":19441797,"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":["annotations","aspnetcore","configuration","dependency-injection","di-capabilities"],"created_at":"2024-10-11T01:44:41.345Z","updated_at":"2025-10-26T04:30:17.214Z","avatar_url":"https://github.com/ocinbat.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Anetta - Simple DI helper.\n\n[![Build status](https://ci.appveyor.com/api/projects/status/gtme5qrorat8r37w?svg=true)](https://ci.appveyor.com/project/ocinbat/anetta)\n\nAnetta is a tool for extending Microsoft.Extensions.DependencyInjection DI capabilities with annotations.\n\n## Installation\n\n```shell\nPM\u003e Install-Package Anetta\n```\n\nor\n\n```shell\n\u003e dotnet add package Anetta\n```\n\n## Annotations Example\n\nIn your ```ConfigureServices``` method use ```AddAnnotations``` method provided by Anetta.Extensions namespace.\n\n```csharp\nusing Anetta.Extensions;\n\npublic IServiceProvider ConfigureServices(IServiceCollection services)\n{\n    services.AddAnnotations();\n\n    /// other service registrations\n}\n```\n\nNow you can mark your classes with 3 different lifetime attributes: ```Singleton, Scoped, Transient```.\n\n```csharp\nusing Anetta.Attributes;\n\n[Singleton]\npublic class SomeClass\n{\n    /// other class behaviour\n}\n```\n\n## Configurations Example\n\nYou can register your configurations with ```Configuration``` attribute.\n\nCreate a class that represents configuration from your ```IConfiguration``` instance.\n\n```csharp\nusing Anetta.Configuration;\n\n[Configuration]\npublic class AppSettings\n{\n    public string Key { get; set; }\n}\n```\n\nalso you are free to change underlying section name.\n\n```csharp\nusing Anetta.Configuration;\n\n[Configuration(\"SettingsGroup:SomeSettings:AppSettings\")]\npublic class AppSettings\n{\n    public string Key { get; set; }\n}\n```\n\nand in your ```ConfigureServices``` method use ```AddConfigurations``` method provided by ```Anetta.Configuration``` namespace.\n\n```csharp\nusing Anetta.ServiceConfiguration;\n\npublic IConfiguration Configuration { get; }\n\npublic IServiceProvider ConfigureServices(IServiceCollection services)\n{\n    services.AddConfigurations(Configuration);\n\n    /// other service registrations\n}\n```\n\nNow you can inject your settings into any class that's registered to DI container.\n\n```csharp\npublic class SampleService\n{\n    private readonly IOptionsMonitor\u003cAppSettings\u003e _appSettings;\n\n    public SampleService(IOptionsMonitor\u003cAppSettings\u003e appSettings)\n    {\n        _appSettings = appSettings;\n    }\n\n    public void Execute()\n    {\n        Console.WriteLine(\"SampleService is executed.\");\n    }\n}\n```\n\n## ServiceConfigurator Example\n\nYou can extract logic from ```ConfigureServices``` to seperate classes by using ```IServiceConfigurator``` interface.\n\nCreate a class that implements ```IServiceConfigurator``` interface.\n\n```csharp\nusing Anetta.ServiceConfiguration;\n\npublic class SampleServiceWithConfiguratorConfigurator : IServiceConfigurator\n{\n    public void Configure(IServiceCollection services, IConfiguration configuration)\n    {\n        services.AddSingleton\u003cSampleServiceWithConfigurator\u003e();\n    }\n}\n```\n\nand in your ```ConfigureServices``` method use ```AddServiceConfigurators``` method provided by ```Anetta.ServiceConfiguration``` namespace.\n\n```csharp\nusing Anetta.ServiceConfiguration;\n\npublic IConfiguration Configuration { get; }\n\npublic IServiceProvider ConfigureServices(IServiceCollection services)\n{\n    services.AddServiceConfigurators(Configuration);\n\n    /// other service registrations\n}\n```\n\n## Contributing\n\nIn lieu of a formal style guide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details\n\n## References\n- https://github.com/aspnet/DependencyInjection","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Focinbat%2Fanetta","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Focinbat%2Fanetta","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Focinbat%2Fanetta/lists"}