Добавил систему плагинов
	
		
			
	
		
	
	
		
	
		
			Some checks failed
		
		
	
	
		
			
				
	
				Create and publish a Docker image / Publish image (push) Failing after 4m3s
				
			
		
		
	
	
				
					
				
			
		
			Some checks failed
		
		
	
	Create and publish a Docker image / Publish image (push) Failing after 4m3s
				
			This commit is contained in:
		
							
								
								
									
										45
									
								
								SfeduSchedule.Plugin.Sample/Plugin.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								SfeduSchedule.Plugin.Sample/Plugin.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,45 @@ | ||||
| using Microsoft.AspNetCore.Mvc; | ||||
| using SfeduSchedule.Plugin.Abstractions; | ||||
|  | ||||
| namespace SfeduSchedule.Plugin.Sample; | ||||
|  | ||||
| // Пример сервиса плагина | ||||
| public interface IGreeter | ||||
| { | ||||
|     string Greet(string name); | ||||
| } | ||||
|  | ||||
| public sealed class Greeter : IGreeter | ||||
| { | ||||
|     public string Greet(string name) => $"Hello, {name} from {nameof(Plugin)}!"; | ||||
| } | ||||
|  | ||||
| public sealed class SamplePlugin : IPlugin | ||||
| { | ||||
|     public string Name => "Sample"; | ||||
|  | ||||
|     public void ConfigureServices(IServiceCollection services) | ||||
|     { | ||||
|         // Регистрируем DI-сервисы плагина | ||||
|         services.AddScoped<IGreeter, Greeter>(); | ||||
|         // Можно регистрировать любые IHostedService, Options и т.д. | ||||
|     } | ||||
|  | ||||
|     public void MapEndpoints(IEndpointRouteBuilder endpoints) | ||||
|     { | ||||
|         // Пример Minimal API эндпоинта | ||||
|         endpoints.MapGet("/plugins/sample/hello", (IGreeter greeter) => | ||||
|         { | ||||
|             return Results.Ok(new { message = greeter.Greet("world") }); | ||||
|         }); | ||||
|     } | ||||
| } | ||||
|  | ||||
| // Пример MVC-контроллера из плагина | ||||
| [ApiController] | ||||
| [Route("plugins/sample/[controller]")] | ||||
| public class EchoController : ControllerBase | ||||
| { | ||||
|     [HttpGet("{text}")] | ||||
|     public IActionResult Get(string text) => Ok(new { echo = text, from = "Plugin.Sample" }); | ||||
| } | ||||
		Reference in New Issue
	
	Block a user