25 lines
875 B
C#
25 lines
875 B
C#
using HackerNet.Application;
|
|
using HackerNet.Domain;
|
|
using HackerNet.Infrastructure.Repositories.Memory;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
namespace HackerNet.Infrastructure.AspNet;
|
|
|
|
public static class ServiceCollectionExtensions
|
|
{
|
|
public static IServiceCollection AddHackerNetServices(this IServiceCollection services)
|
|
{
|
|
var link = new Link("https://localhost:7050/", "Youhouuu");
|
|
var comment = new Comment(link.Id, "Wow!");
|
|
var linksRepository = new MemoryLinkRepository(link);
|
|
var commentsRepository = new MemoryCommentRepository(comment);
|
|
|
|
services.AddSingleton<ILinkRepository>(linksRepository);
|
|
services.AddSingleton<ICommentRepository>(commentsRepository);
|
|
services.AddSingleton<IReadStore>(new MemoryReadStore(linksRepository, commentsRepository));
|
|
|
|
services.AddSingleton<LinkService>();
|
|
|
|
return services;
|
|
}
|
|
} |