我正在开发一个本地git存储库.有两个分支,master和feature_x.
我想推feature_x送到远程仓库,但我不想在master分支上推送更改.
会git push origin feature_x从我的feature_x分支(feature_x分支已经存在远程的)工作?
我不想在我的盒子上测试这个,因为我现在无法推动掌握.
我有一个十进制属性,就像
[XmlElementAttribute(DataType = "decimal")] decimal Price
问题是我想强制它始终以2的精度序列化,但如果价格是10.50,它将被序列化为XML <Price>10.5</Price>.
有什么方法可以强制它(没有创建新属性或更改此属性的获取?我正在寻找一些方法来执行此操作只将模式发送到XmlSerializer(或XmlElementAttribute)或任何智能方法来执行此操作?
谢谢
我正在开发一个项目,每隔30~80秒创建20~50个新任务.每项任务都会持续10~20秒.
所以我使用Timer来创建这些新任务,但每次我总是重新创建相同的任务时,代码是这样的:
public class TaskRunner : IDisposable
{
private readonly Timer timer;
public IService service;
public ThreadRunner(IService service) {
this.service = service;
timer = new Timer(10000);
timer.Elapsed += Execute;
timer.Enabled = true;
}
}
private void Execute(object sender, ElapsedEventArgs e)
{
try
{
Task.Factory.StartNew(service.Execute);
}
catch (Exception ex)
{
logger.ErrorFormat("Erro running thread {0}. {1}", service, ex);
}
}
public void Dispose()
{
timer.Dispose();
}
}
Run Code Online (Sandbox Code Playgroud)
我的问题是,无论如何创建一个任务并保持重新启动它,所以我不需要启动一个新任务Task.Factory.StartNew(service.Execute); 每次?
或者那是我不必担心的事情,可以继续创建新任务吗?
有关这种情况的任何指导/最佳实践,我应该如何处理这种情况?
我在使用WEB Api时遇到了一些性能问题.在我的真实/生产代码上,我将做一个SOAP WS调用,在这个示例中,我只是睡觉.我有400多个客户端向Web API发送请求.
我想这是web api的一个问题,因为如果我打开5个进程,我可以处理更多的请求,而不是只有一个进程.
我的控制器的测试异步版本看起来像这样
[HttpPost]
public Task<HttpResponseMessage> SampleRequest()
{
return Request.Content.ReadAsStringAsync()
.ContinueWith(content =>
{
Thread.Sleep(Timeout);
return new HttpResponseMessage(HttpStatusCode.OK)
{
Content = new StringContent(content.Result, Encoding.UTF8, "text/plain")
};
});
}
Run Code Online (Sandbox Code Playgroud)
同步版本看起来像这样
[HttpPost]
public HttpResponseMessage SampleRequest()
{
var content = Request.Content.ReadAsStringAsync().Result;
Thread.Sleep(Timeout);
return new HttpResponseMessage(HttpStatusCode.OK)
{
Content = new StringContent(content, Encoding.UTF8, "text/plain")
};
}
Run Code Online (Sandbox Code Playgroud)
我对此测试的客户端代码看起来像这样(它被配置为在30秒后超时)
for (int i = 0; i < numberOfRequests; i++)
{
tasks.Add(new Task(() =>
{
MakeHttpPostRequest();
}));
}
foreach (var task in tasks)
{
task.Start();
} …Run Code Online (Sandbox Code Playgroud) 我正在使用带有shoulda的Test :: Unit来测试控制器.
因为我只是测试控制器,所以我不希望渲染视图.
我正在对某些对象进行存根,在渲染视图时会抛出一些错误,但测试不会失败,因为控制器是正确的.
那么,从我的测试中,是否有任何方法可以禁用模板/视图的渲染?
我听说rSpec就是这样的.