/// <summary> /// Matches the given type to an equivalent enumerated repository type /// </summary> /// <param name="objectType"></param> /// <returns></returns> private static RepositoryTypes ObjectTypeToRepositoryType(Type objectType) { foreach (var repoType in EnumerationFunctions.GetAllEnumValues <RepositoryTypes>()) { var attrib = EnumerationExtensions.GetAttribute <TypeMapAttribute>(repoType); if (attrib?.Object == null) { continue; } if (attrib.Object == objectType) { return(repoType); } } throw new ArgumentException($"{objectType} is not a valid Repository Type", nameof(objectType)); }
public RepositoryManager(IKernel kernel, ILogManager logManager) { LogManager = logManager; Kernel = kernel; _repositories = new Dictionary <RepositoryTypes, object>(); foreach (var repoType in EnumerationFunctions.GetAllEnumValues <RepositoryTypes>()) { var attrib = EnumerationExtensions.GetAttribute <TypeMapAttribute>(repoType); if (attrib?.Repository == null) { continue; } _repositories.Add(repoType, Activator.CreateInstance(attrib.Repository)); } }