有没有办法可以使用新IHttpActionResult界面返回HttpStatusCode.NoContent响应消息?
我目前正在使用return new HttpResponseMessage( HttpStatusCode.NoContent );
并希望将其转换为return NoContent();.
IHttpActionResult已经得到了Ok(),Conflict()并且NotFound()但是我找不到任何的Forbidden()和NoContent()我需要在我的项目中使用.
添加其他结果类型有多容易?
我目前正在用C#开发一个国际象棋引擎,我在开发代码时遇到了一些障碍,以确定任何给定棋子在1,2和3次移动中的未来移动性.基本的想法是奖励可以提高行动能力的奖励,并惩罚行动不便的作品.
棋盘表示为64个正方形的阵列,从0(a8)到63(h1)开始,例如
Piece[] _chessboard = new Piece[64];
我以这个棋盘位置为例:
Black Rooks on squares 3 & 19 (d8 & d6) Black King on square 5 (f8) Black Knight on squares 11 & 12 (d7 & e7) Black Queen on square 16 (a6) Black Pawns on squares 13, 14, 17, 18, 19 (f7, g7, b6 & c6) White Rook on squares 58 & 42 (c1 & c3) White King on square 53 (f2) White Knight on square 40 (a3) White Bishop on square …
我已将AngularJS SPA应用程序升级ng-grid v2.0.7到,ui-grid v3并且我的列标题不再包含在内.我的列标题现在是单行...标题,并在列标题不适合时显示省略号.
此功能是否已被删除或是否已被其他方法取代?
我试图通过调用任务中的CancellationTokenSource.Cancel()方法来取消Task <>,但我无法让它工作.
这是我正在使用的代码:
TaskScheduler ts = TaskScheduler.Current;
CancellationTokenSource cts = new CancellationTokenSource();
Task t = new Task( () =>
{
Console.WriteLine( "In Task" );
cts.Cancel();
}, cts.Token );
Task c1 = t.ContinueWith( antecedent =>
{
Console.WriteLine( "In ContinueWith 1" );
}, CancellationToken.None, TaskContinuationOptions.OnlyOnRanToCompletion, ts );
Task c2 = c1.ContinueWith( antecedent =>
{
Console.WriteLine( "In ContinueWith 2" );
}, TaskContinuationOptions.NotOnCanceled );
t.Start();
Console.ReadKey();
Environment.Exit( 1 );
Run Code Online (Sandbox Code Playgroud)
打印输出:
In Task
In ContinueWith 1
In ContinueWith 2
Run Code Online (Sandbox Code Playgroud)
我的期望是这样的:
In Task
Run Code Online (Sandbox Code Playgroud)
我在这里错过了什么吗?任务只能在任务之外取消吗?
Microsoft.Data.Schema.ScriptDom是否附带Visual Studio 2012 Ultimate?
我正在尝试加载引用此程序集的Visual Studio 2010项目,并且自从移动到VS2012(在另一台PC上)后,它无法再找到此程序集.
我以为VS2012 Ultimate拥有一切,所以这个装配在哪里消失了?
我试图使用MSBuild命名空间以编程方式生成.csproj文件,但缺少代码示例使得这个过程变得繁琐且容易出错.
到目前为止,我有以下代码,但我不知道如何将类,引用等添加到项目中.
public void Build()
{
string projectFile = string.Format(@"{0}\{1}.csproj", Common.GetApplicationDataFolder(), _project.Target.AssemblyName);
Microsoft.Build.Evaluation.Project p = new Microsoft.Build.Evaluation.Project();
ProjectCollection pc = new ProjectCollection();
Dictionary<string, string> globalProperty = new Dictionary<string, string>();
globalProperty.Add("Configuration", "Debug");
globalProperty.Add("Platform", "x64");
BuildRequestData buildRequest = new BuildRequestData(projectFile, globalProperty, null, new string[] { "Build" }, null);
p.Save(projectFile);
BuildResult buildResult = BuildManager.DefaultBuildManager.Build(new BuildParameters(pc), buildRequest);
}
Run Code Online (Sandbox Code Playgroud)
谢谢.
我正在编写一个正则表达式,它将从EDIFACT UN代码列表中提取各种信息.因为有成千上万的代码我不想全部输入,所以我决定使用正则表达式解析文本文件并提取出我需要的位.文本文件的结构使我能够轻松识别出我想要的位.
我使用Regex Hero创建了以下Regex 来测试它,但是我无法让它匹配codeComment组的双重换行符.我已经尝试使用字符类[^ \n \n],但这仍然不匹配双换行符.
注意:我在Regex Hero上选择了Multiline选项.
(?<element>\d+)\s\s(?<elementName>.*)\[[B|C|I]\]\s+Desc: (?<desc>[^\n]*\s*[^\n]*)
^\s*Repr: (?<type>a(?:n)?)..(?<length>\d+)
^\s*(?<code>\d+)\s*(?<codeName>[^\n]*)
^\s{14}(?<codeComment>[^\n]*)
Run Code Online (Sandbox Code Playgroud)
这是我用来匹配的示例文本.
-------------------------------------------------- --------------------
1073文档行代码[B]
描述:指示与
文档行关联的操作的代码
.
Repr:an..3
1包含在凭证/交易中
凭证行包含在
凭证/交易中.
也应该抓住这个.
2从文档/事务
中排除文档行不包括在
文档/事务中.
我想要的是codeComment包含以下内容:
The document line is included in the
document/transaction.
should capture this as well.
Run Code Online (Sandbox Code Playgroud)
但它只提取第一行:
The document line is included in the
Run Code Online (Sandbox Code Playgroud)