我目前有以下HTML结构:
<div class="article-preview">
<h1><a href="">Title</a></h1>
<a class="pic-link" title="" href=""><img src="" /></a>
<div/>
Run Code Online (Sandbox Code Playgroud)
当图像链接或标题链接悬停时,我想要更改两者的颜色/边框颜色.
我试着使用next()过滤器:
$('.article-preview h1 a').mouseover(function(){
$(this).animate({
color: "#94c4c1"
}, 10);
$(this).next('img').animate({
borderTopColor: '#94c4c1',
borderRightColor: '#94c4c1',
borderBottomColor: '#94c4c1',
borderLeftColor: '#94c4c1'
}, 200);
});
$('.article-preview h1 a').mouseout(function(){
$(this).animate({
color: "#000000"
}, 200);
$(this).next('img').animate({
borderTopColor: 'white',
borderRightColor: 'white',
borderBottomColor: 'white',
borderLeftColor: 'white'
}, 200);
});
$('.article-preview a img').mouseover(function(){
$(this).animate({
color: "#94c4c1"
}, 10);
$(this).parent().find('a:first').animate({
borderTopColor: '#94c4c1',
borderRightColor: '#94c4c1',
borderBottomColor: '#94c4c1',
borderLeftColor: '#94c4c1'
}, 200);
});
$('.article-preview h1 a').mouseout(function(){
$(this).animate({ …Run Code Online (Sandbox Code Playgroud) 我正在实施Ioc,我想确保一些正确的事情.
RegisterInstance,在解析它时将始终返回单例对象?但我想知道如何
1.每个解析创建一个单独的实例,PerResolve不能使用RegisterInstance,它只适用于RegisterType.
2.如果我将依赖对象作为静态属性,它将以相同的方式工作,如果我能够为每个解析创建单独的实例?
请帮忙?
public class ClientUser : UserServiceBase, IClientUser
{
private IDataServiceManager _dataServiceManager;
public ClientUser()
{
}
private IDataServiceManager DataServiceMgr
{
get
{
if (_dataServiceManager == null)
_dataServiceManager = ProjectContainer.Instance.Resolve<IDataServiceManager>();
return _dataServiceManager;
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个关于转换为可以为空的枚举的问题.这是一个代码:
enum Digits
{
One = 1,
Two = 2
}
void Main()
{
int one = 1;
object obj = one;
var en = (Digits?) obj;
Console.WriteLine(en);
}
Run Code Online (Sandbox Code Playgroud)
它让我排InvalidCastException在第11行.
但如果我省略'?' 在该行中的符号,它给出了正确的结果"一",但我不想失去"可空性".
作为我现在使用的解决方法var en = (Digits?) (int?) obj;,虽然我不确定这种解决方案的完全正确性,但它仍然有效.
但我想知道为什么在第一种情况下,铸造到可以为空的枚举失败了?
我期望对可空类型的转换如下:
- 转换为非可空类型,如果成功则转换为可空类型
- 如果null传递则结果null也是如此
但它似乎不是真的.