我需要以最快的方式获得一周的第一天.例如:今天是11月11日,星期四; 我想要本周的第一天,也就是11月8日和星期一.我需要MongoDB地图功能最快的方法,任何想法?
由于客户端代码中的错误,mongodb创建了许多"mr.mapreduce ...."集合,如何将它们全部删除(可能通过掩码).
如何使用一个实现实例注册两个服务?我用了:
_container.Register(Component.For(new [] { typeof(IHomeViewModel), typeof(IPageViewModel) }).
ImplementedBy(typeof(HomeViewModel)).Named("IHomeViewModel").LifeStyle.Singleton)
Run Code Online (Sandbox Code Playgroud)
但是上层代码注册了HomeViewModel的两个实例.
我读了关于GCD的文章,有一个例子:
dispatch_queue_t bgQueue = myQueue;
dispatch_async(dispatch_get_main_queue(), ^{
NSString *stringValue = [[[textField stringValue] copy] autorelease];
dispatch_async(bgQueue, ^{
// use stringValue in the background now
});
});
Run Code Online (Sandbox Code Playgroud)
如果我将该方法放在click处理程序中(将在autoreleasepool中调用),我将丢失stringValue,因为autoreleasepool将在点击事件后被销毁吗?
我没有意识到URI http://services.odata.org/OData/OData.svc/Categories(1)/Products和http://services.odata.org/OData/OData.svc/Categories(1)/$links/Products.之间有什么区别.在http://www.odata.org/documentation/uri-conventions/#AddressingLinksBetweenEntries文档说明不够清楚.
我有代码:
internal static class IdCounter
{
[ThreadStatic]
private static int _id = 0;
static IdCounter()
{
}
public static int Id
{
get
{
lock(typeof(IdCounter))
{
return _id++;
}
}
}
}
public abstract class Request
{
protected Request(int requestId)
{
RequestId = IdCounter.Id;
}
}
Run Code Online (Sandbox Code Playgroud)
在第二次调用时,我收到RequestId等于2,而不是1,问题出在哪里?我试图使用Thread.SetData,但结果是一样的.