Skip to content

Instantly share code, notes, and snippets.

View NDiiong's full-sized avatar
😀
Hi there!

duong.nb NDiiong

😀
Hi there!
View GitHub Profile
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
namespace DomainServices
{
public class DataBuilder<TIn, TOut> where TIn : class where TOut : class, new()
{
public static void AddAny(this IServiceCollection collection, Assembly assembly, Func<Type, bool> implementFactory, ServiceLifetime serviceLifetime)
{
var serviceTypes = assembly.GetTypes()
.Where(x => !x.IsAbstract && x.GetInterfaces().Any(IsAnyServiceInterface))
.ToList();
serviceTypes.ForEach(x => AddService(collection, x));
bool IsAnyServiceInterface(Type type)
{