在Visual Studio 2012/2013中,我想将Alt+ Enter ↵组合重新分配给"Quickfix"(从灯泡触发菜单),因为它不再起作用.我不能.我尝试过以下内容(我知道有些建议是指VS 2010和旧版本的R#):
Tools- Options- Keyboard:前ReSharper_QuickFix条目消失,请参阅ReSharper_QuickFix消失ReSharper- > Options- >中来回切换设置输入不起作用 - 没有Keyboard & MenusReSharper- > Options- > IntelliSense- >中来回切换设置,General如Resharper Alt中所述,输入无效我还没有勇气重新安装R#甚至VS.
如何在Visual Studio中获得一组标准的R#键盘快捷键?我很乐意消除那里的所有东西,只是为了取回我的Alt+ EnterQuickfix ..
resharper visual-studio visual-studio-2012 visual-studio-2013
例如,在从URL读取和处理查询字符串值之后
http://myurl.com/#/?foo=baa
Run Code Online (Sandbox Code Playgroud)
我可以将URL更改为
http://myurl.com/#/?foo=
Run Code Online (Sandbox Code Playgroud)
通过使用
$location.search('myQueryStringParameter', '');
Run Code Online (Sandbox Code Playgroud)
如何完全摆脱查询字符串(没有显式重定向或服务器端操作等),以便只
http://myurl.com/#/
Run Code Online (Sandbox Code Playgroud)
留在浏览器中?它应该相当简单,但我找不到任何参考.
如果我查看Linqpad中为以下两个代码片段创建的IL,我想知道这里发生了什么.
在c#中
int i = 42;
Run Code Online (Sandbox Code Playgroud)
得到以下IL代码
IL_0000: ret
Run Code Online (Sandbox Code Playgroud)
而在VB中
Dim i As Integer = 42
Run Code Online (Sandbox Code Playgroud)
它是
IL_0000: ldc.i4.s 2A
IL_0002: stloc.0
Run Code Online (Sandbox Code Playgroud)
显然,c#编译器理解该值从未使用过,因此根本不返回任何内容.在VB.NET中,实际代码被翻译.
这是由于编译器优化的差异还是还有其他工作原因?
更新:只是为了澄清这一点 - 我只是将这一行输入LinqPad并查看它创建的IL(最明确的是运行相应的编译器).有没有计划.
c# vb.net compiler-construction intermediate-language linqpad
如果像这样循环遍历XmlNodeList
foreach (XmlNode foo in xmlNodeList) {string baa = foo.Attributes["baa"].Value;}
Run Code Online (Sandbox Code Playgroud)
一切都按预期工作 - foo显然是XmlNode类型,VS.NET IDE显示方法和字段.
另一方面
foreach (var foo in xmlNodeList) { string baa = foo.Attributes["baa"].Value; }
Run Code Online (Sandbox Code Playgroud)
没有编译,因为这里foo是object类型.类型推断类型的工作,但推断对象.
显然,XmlNodeList的元素不是一个定义的类型,但是将它们分配给XmlNode而不是var会隐式地执行某些操作(强制转换或取消装箱).
第一个问题:背后的机制是什么?
第二个(相关)问题:如何找到可以在这种循环中使用的类型?VS.NET IDE有帮助吗?
在运行Virtuozzo虚拟机的Windows 2008 R2上,使用Entity Framework的ASP.NET MVC 4 Web引发异常
Method not found: 'Void System.Data.Objects.ObjectContextOptions.set_UseConsistentNullReferenceBehavior(Boolean)'
Run Code Online (Sandbox Code Playgroud)
具有相同web.config 的相同 Web在使用Windows 2012的另一个(根)服务器上运行正常,当然在开发环境中本地运行.
我们使用的是.NET 4.0.堆栈跟踪的顶部如下:
[MissingMethodException:找不到方法:'Void System.Data.Objects.ObjectContextOptions.set_UseConsistentNullReferenceBehavior(Boolean)'.] System.Data.Entity.Internal.LazyInternalContext.InitializeContext()+ 0 System.Data.Entity.Internal.InternalContext.ExecuteSqlQuery (String sql,Object [] parameters)+34 System.Data.Entity.Internal.InternalContext.ExecuteSqlQueryAsIEnumerable(String sql,Object [] parameters)+91 System.Data.Entity.Internal.InternalContext.ExecuteSqlQuery(Type elementType,String sql ,Object []参数)+250 System.Data.Entity.Internal.InternalSqlNonSetQuery.GetEnumerator()+
1.GetEnumerator() +28 System.Collections.Generic.List34 System.Data.Entity.Internal.InternalSqlQuery 1..ctor(IEnumerable1 collection) +382 System.Linq.Enumerable.ToList(IEnumerable1 source)+80 [...]
我做了所有这些建议, 任何人都可以发现为什么我一直在测试EF 5测试版时遇到这个错误.没有旧的EF测试版的痕迹.我重新安装了.NET 4.
这个错误在Google上很少见.
我还能尝试什么?
在.NET中有没有办法替换比较间隔的代码
if (compare < 10)
{
// Do one thing
}
else if (10 <= compare && compare < 20)
{
// Do another thing
}
else if (20 <= compare && compare < 30)
{
// Do yet another thing
}
else
{
// Do nothing
}
Run Code Online (Sandbox Code Playgroud)
通过像switch语句更优雅的东西(我认为在Javascript"case(<10)"中有效,但在c#中)?有没有其他人发现这个代码也很难看?
作为Angularjs的新手,我使用指令在Angularjs中创建文本框标签组合.它工作得很好,但我无法通过验证工作.这是一个精简的例子.
Html:
<form name="form" novalidate ng-app="myapp">
<input type="text" name="myfield" ng-model="myfield" required />{{myfield}}
<span ng-show="form.myfield.$error.required">ERROR MSG WORKING</span>
<br>
<div mydirective FIELD="myfield2" />
</form>
Run Code Online (Sandbox Code Playgroud)
Javascript:
var myapp = angular.module('myapp', []);
myapp.directive('mydirective', function () {
return {
restrict: 'A',
scope: { ngModel: '=' },
template: '<input type="text" name="FIELD" ng-model="FIELD" />{{FIELD}}
<span ng-show="form.FIELD.$error.required">ERROR MSG NOT WORKING</span>'
};
});
Run Code Online (Sandbox Code Playgroud)
硬编码输入 - myfield - 工作,另一个 - myfield2 - 没有(绑定,不是必需的错误消息).
我该如何告诉NG-show属性进行排序"替换"的领域中form.FIELD.$ error.required通过myfield2?
这是一个jsFiddle.
我们花了很多时间试图让一个非常简单的脚本工作(其他人似乎都很成功).最后,我们想要使用JQuery创建一个autosuggest文本框,将所选文本的值写入隐藏字段,但这个问题与此无关,因为即使是第一步也失败了(但是非常欢迎使用示例代码).
出于某些不明原因,不执行formatItem(和其他格式化函数).我们有什么误解?
任何帮助都非常感谢.
这是代码(剥离了示例中不需要的任何内容):
<html>
<head>
<title>Why o why?</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js"></script>
<script type="text/javascript">
$(function() {
var s = ["a", "b", "ab"];
$("#txtSearch").autocomplete({
source: s,
formatItem: function(row, i, n) { return "whatever" },
minLength: 1
});
});
</script>
</head>
<body>
Search <input id="txtSearch" type="text" />
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
这样的autosuggest函数可以在任何浏览器中使用,但是没有浏览器触发formatItem.
尽管尝试了很多东西(见下文),但我无法摆脱"要写入流的字节超过指定的内容长度字节大小".抛出的错误
writer.Close();
Run Code Online (Sandbox Code Playgroud)
这是尝试将数据从ASP.NET发布到php站点的代码.只要代码中没有特殊字符,脚本就可以正常工作 - 请注意'Wörld'中的德语变音符号.
Uri uri = new Uri("http://mydomain/test.php");
string data = @"data=Hello Wörld";
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(uri);
request.Method = WebRequestMethods.Http.Post;
request.ContentLength = data.Length;
request.ContentType = "application/x-www-form-urlencoded";
StreamWriter writer = new StreamWriter(request.GetRequestStream());
writer.Write(data);
writer.Close();
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream());
string tmp = reader.ReadToEnd();
response.Close();
Response.Write(tmp);
Run Code Online (Sandbox Code Playgroud)
我尝试过使用UTF-8编码的不同变体,例如:
request.ContentLength = System.Text.Encoding.UTF8.GetByteCount(data);
Run Code Online (Sandbox Code Playgroud)
和/或
StreamWriter writer = new StreamWriter(request.GetRequestStream(), Encoding.UTF8);
Run Code Online (Sandbox Code Playgroud)
我也尝试在发送之前将数据转换为UTF-8(有点难看):
data = System.Text.Encoding.UTF8.GetString(System.Text.Encoding.Convert(System.Text.Encoding.UTF8, System.Text.Encoding.UTF8, System.Text.Encoding.UTF8.GetBytes(data)));
Run Code Online (Sandbox Code Playgroud)
但错误仍然存在.我的感觉是我没有正确处理UTF-8.非常感谢任何帮助,也有任何提示,我可以找到一个从ASP.NET(服务器端)发布到PHP的完美工作脚本.
这个问题可能归因于我的失明,但我没有找到一种方法如何排除某些测试方法被NCrunch自动执行.必须有一个属性或类似的手段.我用谷歌搜索并搜索了NCrunch网站.
我们正在使用VS.NET 2010,MS Test,R#(测试不应该从运行"解决方案中的所有测试"命令中排除).
排除某些测试的原因是他们吃太多资源或更改数据.我知道我可以使用模拟框架来避免后者,但这不是重点(并且不可能).
在所有具有在线表单的项目中,很多人必须输入他们的数据,令人惊讶的大量输入通过正则表达式验证但看起来像 foo@yaho.com、foo@gnail.com 或 foo@hotmial.com 的电子邮件地址 - 拼写错误在知名电子邮件提供商的域名中。
我们很想显示一个提示,例如“您写的是 foo@yaho.com,但您的意思不是 foo@yahoo.com?” .
当然,我们可以创建大量可能的拼写错误。
有没有更优雅的方式?一个能做到这一点的网络服务?代码片段?一个超酷的正则表达式?
c# ×5
.net ×2
angularjs ×2
asp.net ×2
autocomplete ×1
encoding ×1
jquery ×1
linqpad ×1
mstest ×1
query-string ×1
resharper ×1
unit-testing ×1
utf-8 ×1
vb.net ×1
xml ×1