private IQueryRepositoryCommand <T> ResolveCommand <T>(IQueryData commandData) { Contract.Assert(commandData != null); var type = typeof(IQueryRepositoryCommand <,>).MakeGenericType(commandData.GetType(), typeof(T)); var command = (IQueryRepositoryCommand <T>) this.ServiceLocator.GetInstance(type); return(command); }
public static T LoadOne <T>(this IRepository repository, IQueryData <T> queryData) where T : class { Contract.Assert(repository != null); Contract.Assert(queryData != null); var instance = repository.FindOne(queryData); if (instance == null) { var message = string.Format( CultureInfo.InvariantCulture, "Cannot load [{0}] using criteria [{1}].", typeof(T), queryData.GetType()); throw new ObjectNotFoundException(message); } return(instance); }