using System; using System.Collections.Generic; namespace FlowScope.Container { public static class GeneratedFactories { private static readonly Dictionary> Factories = new Dictionary>(); public static void Register(Func factory) { if (factory == null) { throw new ArgumentNullException(nameof(factory)); } Factories[typeof(TImplementation)] = c => factory(c); } public static bool TryGetFactory(Type implementationType, out Func factory) { if (implementationType == null) { throw new ArgumentNullException(nameof(implementationType)); } return Factories.TryGetValue(implementationType, out factory); } public static void RegisterAssembly(Container container) { if (container == null) { throw new ArgumentNullException(nameof(container)); } foreach (var pair in Factories) { container.RegisterFactory(pair.Key, pair.Value); } } } }