使用 spring.NET 配置以下类的最佳实践是什么?
using System.Collections.Generic;
using Edu3.DTOModel;
namespace Edu3.Data.SubsonicProvider.RepositoryFramework
{
public static class RepositoryFactory
{
private static readonly Dictionary<string, object> Repositories =
new Dictionary<string, object>();
static RepositoryFactory()
{
Repositories.Add(typeof(ISsoUrlTemplateRepository).Name,
new SsoUrlTemplateRepository());
Repositories.Add(typeof(IPackageSessionNodeRepository).Name,
new PackageSessionNodeRepository());
Repositories.Add(typeof(IPackageSessionNodeFinishedRepository).Name,
new PackageSessionNodeFinishedRepository());
}
public static IRepository<TEntity> GetRepository<TEntity, TRepository>()
where TEntity : IEntity
{
var interfaceShortName = typeof(TRepository).Name;
// The provider was in the cache, so retrieve it
var repository = (IRepository<TEntity>)Repositories[interfaceShortName];
return repository;
}
}
}
我想用 Spring.NET 添加存储库。这可能吗?