我有這些類:如何用靜態方法來調用靜態類(UnitOfWork case)?
public static class UnitOfWorkSS
{
public static IUnitOfWork Begin()
{
return IoC.Resolve<IUnitOfWork>();
}
}
public class PostService
{
using (IUnitOfWork unitOfWork = UnitOfWorkSS.Begin())
{
//don't forget to sanitize html content
htmlContent = _htmlSanitizer.Sanitize(htmlContent);
IPost post = _factory.CreatePost(byUser, title, htmlContent);
_postRepository.Add(post);
unitOfWork.Commit();
}
}
我怎麼能嘲笑類UnitOfWorkSS
和unitOfWork
?
是的,我意識到這一點。但事情是,我需要僞造該功能,有沒有辦法做到這一點? – Attilah 2010-11-26 03:58:17
就我所知,你必須重寫你的工作單元的東西是非靜態的。 – Chris 2010-11-26 04:00:04