{"id":20626587,"url":"https://github.com/genryianchev/annotationservicebuilder.patterns","last_synced_at":"2026-02-09T07:34:31.286Z","repository":{"id":256075120,"uuid":"854260581","full_name":"genryianchev/AnnotationServiceBuilder.Patterns","owner":"genryianchev","description":"AnnotationServiceBuilder.Patterns is a library that provides support for implementing common design patterns in .NET applications using custom annotations. ","archived":false,"fork":false,"pushed_at":"2024-09-09T04:33:19.000Z","size":18,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-22T14:53:39.267Z","etag":null,"topics":["annotations","injection","patterns","visual-studio"],"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/genryianchev.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":"2024-09-08T19:45:41.000Z","updated_at":"2024-09-09T04:33:22.000Z","dependencies_parsed_at":"2024-09-09T09:48:38.340Z","dependency_job_id":null,"html_url":"https://github.com/genryianchev/AnnotationServiceBuilder.Patterns","commit_stats":null,"previous_names":["genryianchev/annotationservicebuilder.patterns"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/genryianchev/AnnotationServiceBuilder.Patterns","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/genryianchev%2FAnnotationServiceBuilder.Patterns","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/genryianchev%2FAnnotationServiceBuilder.Patterns/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/genryianchev%2FAnnotationServiceBuilder.Patterns/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/genryianchev%2FAnnotationServiceBuilder.Patterns/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/genryianchev","download_url":"https://codeload.github.com/genryianchev/AnnotationServiceBuilder.Patterns/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/genryianchev%2FAnnotationServiceBuilder.Patterns/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29258759,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-09T04:11:57.159Z","status":"ssl_error","status_checked_at":"2026-02-09T04:11:56.117Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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","injection","patterns","visual-studio"],"created_at":"2024-11-16T13:14:05.210Z","updated_at":"2026-02-09T07:34:31.271Z","avatar_url":"https://github.com/genryianchev.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# ![AnnotationServiceBuilder Icon](https://github.com/genryianchev/AnnotationServiceBuilder/raw/main/AnnotationServiceBuilder/icon.png) AnnotationServiceBuilder.Patterns\n\n**AnnotationServiceBuilder.Patterns** is a library that provides support for implementing common design patterns in .NET applications using custom annotations. This library is part of the [AnnotationServiceBuilder](https://github.com/genryianchev/AnnotationServiceBuilder) ecosystem and focuses on facilitating the use of design patterns such as Factory via annotation-based service registration.\n\n## Key Features\n\n- **Factory Pattern**: Easily register factories with the DI container using `[FactoryPattern]`, allowing for flexible object creation and dependency management.\n- Simplifies codebase by removing the need for manual service registration.\n- Integrates seamlessly with .NET dependency injection.\n\n## Installation\n\nTo install **AnnotationServiceBuilder.Patterns**, use the following command:\n\n```bash\ndotnet add package AnnotationServiceBuilder.Patterns\n```\n\nAlternatively, you can install it through the NuGet Package Manager in Visual Studio.\n\n## Usage\n\n### Factory Pattern\n\nThe `FactoryPatternAttribute` allows for the annotation-based registration of factory classes. These classes should implement a factory interface, typically following the Factory Design Pattern, to create instances of specific types.\n\n```csharp\n[FactoryPattern(typeof(IMyFactory), ServiceLifetime.Scoped)]\npublic class MyFactory : IMyFactory\n{\n    public MyObject Create()\n    {\n        return new MyObject();\n    }\n}\n```\n\n- **`IMyFactory`**: The interface that the factory implements.\n- **`ServiceLifetime.Scoped`**: The lifetime of the factory in the DI container (can also be `Singleton` or `Transient`).\n\n```csharp\nAnnotationDesignPatternRegistrar.AddFactoryPatternServices(builder.Services);\n```\n\nThis will automatically scan your assembly for classes marked with the `[FactoryPattern]` attribute and register them in the DI container.\n\n### Example: Registering Factory Services in `Program.cs`\n\nIn a minimal API setup (for .NET 6 and higher), here’s how you can initialize and register factory services:\n\n```csharp\nvar builder = WebApplication.CreateBuilder(args);\n\n// Initialize the assembly with all patterns\nAnnotationDesignPatternRegistrar.Initialize(Assembly.GetExecutingAssembly());\n\n// Register all factory pattern services\nAnnotationDesignPatternRegistrar.AddFactoryPatternServices(builder.Services);\n\nvar app = builder.Build();\n\n// Add your middlewares and endpoints here\n\napp.Run();\n```\n\nThis will ensure that all factory services marked with `[FactoryPattern]` are properly registered in the DI container.\n\n### Example: Registering Factory Services in `Startup.cs`\n\nIf you are using a traditional `Startup.cs` class (for example, in an ASP.NET Core MVC app), here's how to register factory services:\n\n```csharp\npublic class Startup\n{\n    public void ConfigureServices(IServiceCollection services)\n    {\n        // Initialize the assembly with all patterns\n        AnnotationDesignPatternRegistrar.Initialize(Assembly.GetExecutingAssembly());\n\n        // Register all factory pattern services\n        services.AddFactoryPatternServices();\n    }\n}\n```\n\n## Contributing\n\nIf you'd like to contribute to **AnnotationServiceBuilder.Patterns**, feel free to submit a pull request or open an issue on the [GitHub repository](https://github.com/genryianchev/AnnotationServiceBuilder).\n\n---\n\n### License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgenryianchev%2Fannotationservicebuilder.patterns","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgenryianchev%2Fannotationservicebuilder.patterns","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgenryianchev%2Fannotationservicebuilder.patterns/lists"}