在处理通用依赖注入处理程序(基本服务定位器)时,我遇到了泛型问题.
编辑1(为清晰起见)
好的,所以我实际上使用SimpleInjector作为DI解析器,它对它的GetInstance方法有类约束,所以这里有一些更完整的代码:
public T GetInstance<T>() where T : class
{
try
{
// works
return _container.GetInstance<T>();
}
catch( ActivationException aEx )
{
return default( T );
}
}
public T GetInstance<T>()
{
try
{
if( typeof( T ).IsClass )
{
// does not work, T is not a reference type
return _container.GetInstance<T>();
}
}
catch( ActivationException aEx )
{
return default( T );
}
}
Run Code Online (Sandbox Code Playgroud)
编辑2 - 最终代码,因为它在评论中看起来很奇怪:
public T GetInstance<T>()
{
try
{
if( typeof( T ).IsClass ) …Run Code Online (Sandbox Code Playgroud) 我在使用远程存储库hotfix创建的分支上推送提交时遇到了问题git-flow.
这是错误:
$ git push origin hotfix/MyHotfix
Counting objects:
... etc
To {my remote repo}
! [remote rejected] hotfix/MyHotfix -> hotfix/MyHotfix (no such ref)
error: failed to push some refs to {my remote repo}
Run Code Online (Sandbox Code Playgroud)
我hotfix用标准语法创建了:
git flow hotfix start MyHotfix
Run Code Online (Sandbox Code Playgroud)
这个分支已经存在origin,我可以看到git branch -a.我还检查了分支仍然存在于远程服务器上,因为它在我运行时出现git remote show origin.
有没有人遇到过这个git或者git-flow找到了解决方案?
注意 - 我尝试过的事情:
git remote prune origin),我的同事本地仓库会收到相同的错误 …