1234567891011121314151617181920212223242526272829303132333435363738 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace InABox.Core
- {
-
- public interface IAutoEntityUnionGenerator : IAutoEntityGenerator
- {
- Type[] Entities { get; }
- IFilter? Filter(Type type);
- }
-
- public abstract class AutoEntityUnionGenerator<TInterface> : IAutoEntityUnionGenerator
- {
- public AutoEntityUnionGenerator()
- {
- Configure();
- }
- private Dictionary<Type,IFilter> _entities = new Dictionary<Type, IFilter>();
-
- public Type[] Entities => _entities.Keys.ToArray();
- public IFilter? Filter(Type type) => _entities.ContainsKey(type) ? _entities[type] : null;
- public void Add<TType>(Filter<TType> filter = null) where TType : TInterface
- {
- _entities[typeof(TType)] = filter;
- }
- protected abstract void Configure();
-
- public Type Definition => typeof(TInterface);
-
- public abstract bool Distinct { get; }
- }
- }
|