{"id":19113905,"url":"https://github.com/ffernandolima/extensions-hosting","last_synced_at":"2025-07-18T04:34:56.585Z","repository":{"id":116249354,"uuid":"277161297","full_name":"ffernandolima/extensions-hosting","owner":"ffernandolima","description":"Exposes Startup extensions to be used with generic host. Also, it exposes task scheduling utilities based on cron expressions.","archived":false,"fork":false,"pushed_at":"2021-08-26T18:06:23.000Z","size":1814,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-02T13:19:50.438Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ffernandolima.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2020-07-04T18:03:38.000Z","updated_at":"2024-10-11T03:42:15.000Z","dependencies_parsed_at":"2023-03-11T23:15:24.717Z","dependency_job_id":null,"html_url":"https://github.com/ffernandolima/extensions-hosting","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ffernandolima/extensions-hosting","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ffernandolima%2Fextensions-hosting","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ffernandolima%2Fextensions-hosting/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ffernandolima%2Fextensions-hosting/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ffernandolima%2Fextensions-hosting/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ffernandolima","download_url":"https://codeload.github.com/ffernandolima/extensions-hosting/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ffernandolima%2Fextensions-hosting/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265701066,"owners_count":23813747,"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-11-09T04:39:31.313Z","updated_at":"2025-07-18T04:34:56.551Z","avatar_url":"https://github.com/ffernandolima.png","language":"C#","funding_links":["https://www.buymeacoffee.com/fernandolima"],"categories":[],"sub_categories":[],"readme":"# extensions-hosting\n\nExposes Startup extensions to be used with generic host.\n\nAlso, it exposes task scheduling utilities based on cron expressions.\n\n[![build-and-publish Workflow Status](https://github.com/ffernandolima/extensions-hosting/actions/workflows/build-and-publish.yml/badge.svg?branch=master)](https://github.com/ffernandolima/extensions-hosting/actions/workflows/build-and-publish.yml?branch=master)\n\n | Package | NuGet |\n | ------- | ----- |\n | Extensions.Hosting | [![Nuget](https://img.shields.io/badge/nuget-v2.3.0-blue) ![Nuget](https://img.shields.io/nuget/dt/Extensions.Hosting)](https://www.nuget.org/packages/Extensions.Hosting/2.3.0) |\n | Extensions.Hosting.Scheduling | [![Nuget](https://img.shields.io/badge/nuget-v2.3.0-blue) ![Nuget](https://img.shields.io/nuget/dt/Extensions.Hosting.Scheduling)](https://www.nuget.org/packages/Extensions.Hosting.Scheduling/2.3.0) |\n\n## Installation\n\nIt is available on Nuget.\n\n```\nInstall-Package Extensions.Hosting -Version 2.3.0\nInstall-Package Extensions.Hosting.Scheduling -Version 2.3.0\n```\n\nP.S.: There's no dependency between the packages. Which one has its own features.\n\n## Usage\n\nThe following code demonstrates basic usage of Startup extensions.\n\n```C#\npublic class Program\n{\n   public static void Main(string[] args) =\u003e CreateHostBuilder(args).Build().Run();\n\n   public static IHostBuilder CreateHostBuilder(string[] args) =\u003e\n       Host.CreateDefaultBuilder(args)\n           .ConfigureServices((hostContext, services) =\u003e\n           {\n               services.UseStartup\u003cStartup\u003e(); // Extension used here\n           });\n}\n\n// Startup class should inherit IStartup interface\npublic class Startup : IStartup\n{\n   public Startup(IConfiguration configuration) =\u003e Configuration = configuration;\n\n   public IConfiguration Configuration { get; }\n\n   public void ConfigureServices(IServiceCollection services)\n   {\n       if (services == null)\n       {\n           throw new ArgumentNullException(nameof(services));\n       }\n       \n       // Register your services here\n   }\n}\n```\n\nThe following code demonstrates basic usage of task scheduling.\n\n```C#\n// Define a task which inherits from IScheduledTask interface\npublic class FooTask : IScheduledTask\n{\n   public string Schedule { get; private set; }\n\n   public FooTask(IConfiguration configuration)\n   {\n       if (configuration == null)\n       {\n           throw new ArgumentNullException(nameof(configuration));\n       }\n\n       var schedule = configuration[\"Scheduling:Tasks:FooTask:Schedule\"];\n\n       if (string.IsNullOrWhiteSpace(schedule))\n       {\n           throw new ArgumentException(nameof(schedule));\n       }\n\n       Schedule = schedule; // Set the cron expression\n   }\n   \n   public async Task ExecuteAsync(CancellationToken cancellationToken)\n   {\n       // Write your logic here\n   }\n}\n \npublic class Startup : IStartup\n{\n   public Startup(IConfiguration configuration) =\u003e Configuration = configuration;\n\n   public IConfiguration Configuration { get; }\n\n   public void ConfigureServices(IServiceCollection services)\n   {\n       if (services == null)\n       {\n           throw new ArgumentNullException(nameof(services));\n       }\n       \n       var delay = configuration?.GetValue\u003cTimeSpan\u003e(\"Scheduling:Delay\");\n       \n       services.AddSingleton\u003cIScheduledTask, FooTask\u003e();\n       services.AddScheduler((sender, args) =\u003e args.SetObserved(), delay);\n   }\n}\n```\n\nappsettings.json:\n```JSON\n\"Scheduling\": {\n    \"Delay\": \"00:00:30\",\n    \"Tasks\": {\n      \"FooTask\": {\n        \"Schedule\": \"* * * * *\"\n      }\n    }\n  }\n```\n\n## Support / Contributing\nIf you want to help with the project, feel free to open pull requests and submit issues. \n\n## Donate\n\nIf you would like to show your support for this project, then please feel free to buy me a coffee.\n\n\u003ca href=\"https://www.buymeacoffee.com/fernandolima\" target=\"_blank\"\u003e\u003cimg src=\"https://www.buymeacoffee.com/assets/img/custom_images/white_img.png\" alt=\"Buy Me A Coffee\" style=\"height: auto !important;width: auto !important;\" \u003e\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fffernandolima%2Fextensions-hosting","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fffernandolima%2Fextensions-hosting","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fffernandolima%2Fextensions-hosting/lists"}