{"id":20626592,"url":"https://github.com/genryianchev/annotationservicebuilderexamples","last_synced_at":"2026-04-18T08:02:30.327Z","repository":{"id":256091073,"uuid":"849148189","full_name":"genryianchev/AnnotationServiceBuilderExamples","owner":"genryianchev","description":"AnnotationServiceBuilderExamples is a repository containing example projects that demonstrate how to use the AnnotationServiceBuilder library. These examples cover various scenarios such as using Scoped, Singleton, and Transient services, as well as using Refit clients.","archived":false,"fork":false,"pushed_at":"2024-09-08T22:53:17.000Z","size":1861,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-15T04:35:36.688Z","etag":null,"topics":["annotations","refit","singleton","transient"],"latest_commit_sha":null,"homepage":"","language":"CSS","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"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":null,"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-08-29T04:16:07.000Z","updated_at":"2024-09-08T22:53:20.000Z","dependencies_parsed_at":"2024-09-08T23:47:29.107Z","dependency_job_id":"aeb6f8d6-e950-4d71-980c-6541a86a3a9c","html_url":"https://github.com/genryianchev/AnnotationServiceBuilderExamples","commit_stats":null,"previous_names":["genryianchev/annotationservicebuilderexamples"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/genryianchev/AnnotationServiceBuilderExamples","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/genryianchev%2FAnnotationServiceBuilderExamples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/genryianchev%2FAnnotationServiceBuilderExamples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/genryianchev%2FAnnotationServiceBuilderExamples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/genryianchev%2FAnnotationServiceBuilderExamples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/genryianchev","download_url":"https://codeload.github.com/genryianchev/AnnotationServiceBuilderExamples/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/genryianchev%2FAnnotationServiceBuilderExamples/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31961348,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T00:39:45.007Z","status":"online","status_checked_at":"2026-04-18T02:00:07.018Z","response_time":103,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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","refit","singleton","transient"],"created_at":"2024-11-16T13:14:07.903Z","updated_at":"2026-04-18T08:02:30.305Z","avatar_url":"https://github.com/genryianchev.png","language":"CSS","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ![AnnotationServiceBuilder Icon](https://github.com/genryianchev/AnnotationServiceBuilder/raw/main/AnnotationServiceBuilder/icon.png) AnnotationServiceBuilderExamples\n\n**AnnotationServiceBuilderExamples** is a repository containing example projects that demonstrate how to use the AnnotationServiceBuilder library. These examples cover various scenarios such as using Scoped, Singleton, and Transient services, as well as using Refit clients.\n\n## Prerequisites\n\n### Web Application\n\n1. **.NET 6.0 or later**\n2. **Visual Studio 2022** (or any other IDE with .NET support)\n\n### Important Note\n\nEnsure that your .NET SDK is up-to-date. This project requires .NET 6.0 or later.\n\n## Project Structure\n\n- **Data**: Contains data models and the `WeatherForecastService` for sample data generation.\n- **Helpers**: Includes helper classes such as `SessionHelper` to manage user sessions.\n- **Network**: Contains repositories and services for API interaction, including implementations of Refit clients.\n- **Pages**: Blazor pages demonstrating different usage scenarios for the services.\n- **Shared**: Shared components and layouts used across the Blazor pages.\n- **wwwroot**: Static files like CSS, JavaScript, and images.\n\n## Examples\n\nHere are examples of how to use each annotation in your project:\n\n### 1. Using Scoped Services\n\n```csharp\nusing AnnotationServiceBuilder.Annotations.Scoped;\nusing AnnotationServiceBuilderExamples.Network.Repositories;\n\n[ScopedService(typeof(IPostsRepository))]\npublic class PostsRepository : IPostsRepository\n{\n    private readonly IPostsApi _postsApi;\n\n    public PostsRepository(IPostsApi postsApi)\n    {\n        _postsApi = postsApi;\n    }\n\n    public async Task\u003cList\u003cPost\u003e\u003e GetPostsAsync()\n    {\n        return await _postsApi.GetPostsAsync();\n    }\n\n    public async Task\u003cPost\u003e GetPostByIdAsync(int id)\n    {\n        return await _postsApi.GetPostByIdAsync(id);\n    }\n}\n```\n\n### 2. Using Singleton Services\n\n```csharp\nusing AnnotationServiceBuilder.Annotations.Singleton;\nusing AnnotationServiceBuilderExamples.Data;\n\n[SingletonService]\npublic class WeatherForecastService\n{\n    private static readonly string[] Summaries = new[]\n    {\n        \"Freezing\", \"Bracing\", \"Chilly\", \"Cool\", \"Mild\", \"Warm\", \"Balmy\", \"Hot\", \"Sweltering\", \"Scorching\"\n    };\n\n    public Task\u003cWeatherForecast[]\u003e GetForecastAsync(DateTime startDate)\n    {\n        return Task.FromResult(Enumerable.Range(1, 5).Select(index =\u003e new WeatherForecast\n        {\n            Date = startDate.AddDays(index),\n            TemperatureC = Random.Shared.Next(-20, 55),\n            Summary = Summaries[Random.Shared.Next(Summaries.Length)]\n        }).ToArray());\n    }\n}\n```\n\n### 3. Using Transient Services\n\n```csharp\nusing AnnotationServiceBuilder.Annotations.Transient_Services;\nusing AnnotationServiceBuilderExamples.Helpers;\n\n[TransientService]\npublic class SessionHelper\n{\n    public string? UserId { get; set; }\n\n    public void SetUserId(string userId)\n    {\n        UserId = userId;\n    }\n}\n```\n\n### 4. Example of a Refit Client\n\n```csharp\nusing AnnotationServiceBuilder.Annotations.Refit;\nusing AnnotationServiceBuilder.Data.Models;\nusing Refit;\n\nnamespace AnnotationServiceBuilderExamples.Network.Repositories\n{\n    [RefitClient]\n    public interface IPostsApi\n    {\n        [Get(\"/posts\")]\n        Task\u003cList\u003cPost\u003e\u003e GetPostsAsync();\n\n        [Get(\"/posts/{id}\")]\n        Task\u003cPost\u003e GetPostByIdAsync(int id);\n    }\n}\n```\n\n### 5. Example of Using the Factory Pattern\n\n**PostFactory.cs:**\n\n```csharp\nusing AnnotationServiceBuilder.Annotations.Patterns.CreationalDesignPatterns.Factory;\nusing AnnotationServiceBuilderExamples.Data.Models;\n\nnamespace AnnotationServiceBuilderExamples.Data\n{\n    [FactoryPattern(typeof(IFactory\u003cPost\u003e))]\n    public class PostFactory : IFactory\u003cPost\u003e\n    {\n        public Post Create()\n        {\n            return new Post();\n        }\n    }\n}\n```\n\n**PostFactoryService.cs:**\n\n```csharp\nusing AnnotationServiceBuilder.Annotations.Patterns.CreationalDesignPatterns.Factory;\nusing AnnotationServiceBuilder.Annotations.Transient;\nusing AnnotationServiceBuilderExamples.Data.Models;\n\nnamespace AnnotationServiceBuilderExamples.Data\n{\n    [TransientService]\n    public class PostFactoryService\n    {\n        private readonly IFactory\u003cPost\u003e _postFactory;\n\n        public PostFactoryService(IFactory\u003cPost\u003e postFactory)\n        {\n            _postFactory = postFactory;\n        }\n\n        public Post CreateNewPost(int id, string title, string body)\n        {\n            var post = _postFactory.Create();\n            post.Id = id;\n            post.Title = title;\n            post.Body = body;\n            return post;\n        }\n    }\n}\n```\n## Video Guides\n\nFor video guides on how to use AnnotationServiceBuilder, you can watch these YouTube videos:\n- [AnnotationServiceBuilder Guide 1](https://www.youtube.com/watch?v=kofPf606OBE)\n- [AnnotationServiceBuilder Guide 2](https://www.youtube.com/watch?v=tspUekM_UHg\u0026t=3s)\n\n## Additional Resources\n\n- [AnnotationServiceBuilder Examples](https://github.com/genryianchev/AnnotationServiceBuilderExamples)\n- [NuGet Package: AnnotationServiceBuilder](https://www.nuget.org/packages/AnnotationServiceBuilder)\n\n## Running the Examples\n\n1. Clone this repository:\n   ```bash\n   git clone https://github.com/genryianchev/AnnotationServiceBuilderExamples.git\n   ```\n\n2. Open the solution in Visual Studio 2022.\n\n3. Set the startup project to `AnnotationServiceBuilderExamples`.\n\n4. Run the application.\n\n5. Navigate through the different pages to see the examples in action.\n\n## Contributing\n\nWe welcome contributions! Please submit a pull request or open an issue to discuss your ideas or report bugs.\n\n## License\n\nThis project is licensed under the MIT License.\n\n```markdown\nMIT License\n\nCopyright (c) 2024 Gennadii Ianchev\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgenryianchev%2Fannotationservicebuilderexamples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgenryianchev%2Fannotationservicebuilderexamples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgenryianchev%2Fannotationservicebuilderexamples/lists"}