现在我真的非常喜欢使用Visual Studio 2013的新Application Insights,我不想删除它.但是,它确实垃圾邮件我的调试输出很多.
我在输出行上得到了行
Application Insights Telemetry: {"ver":1,"name":"Microsoft.ApplicationInsights.PerformanceCounter","time":"2015-04-23T11:38:03.1252550+01:00","iKey":"758c18d5-055e-48a8-bbcf-9c3301402b2c","tags":{"ai.internal.sdkVersion":"0.13.2.132","ai.application.ver":"Unknown","ai.device.type":"PC","ai.device.id":"Pat-PC","ai.device.oemName":"Dell Inc.","ai.device.model":"Dell XPS430 ","ai.device.network":"6","ai.device.language":"en-GB","ai.device.machineName":"Pat-PC","ai.device.os":"Windows NT 6.1.7601.65536"},"data":{"type":"Microsoft.ApplicationInsights.PerformanceCounterData","item":{"categoryName":"Processor","counterName":"% Processor Time","instanceName":"_Total","value":35.9710731506348,"ver":1}}}
Run Code Online (Sandbox Code Playgroud)
这种情况使我无法将调试输出实际用于调试语句.如何使Application Insights静音,或将Visual Studio配置为不显示这些语句?
在我的带有Web界面的MVC项目中,我习惯在Web.Config文件中设置连接字符串.
但是,现在我正在制作一个bog标准控制台应用程序 - 也使用数据库挂钩,但如何为应用程序全局设置连接字符串?
目前,我正在设定
var dbIndex = new DBContext();
dbIndex.Database.Connection.ConnectionString =
"Data Source=USER-PC;Initial Catalog=TextProject.DBContext;" +
"Integrated Security=True;MultipleActiveResultSets=True";
Run Code Online (Sandbox Code Playgroud)
但是我必须在所有函数调用中每次都设置这个connectionstring属性.当我没有web.config时,有没有办法设置全局连接字符串?
我遇到的情况与这里问题的答案非常相似:
具有嵌套层次结构的 AngularJS ng-include
我有一些格式的数据
$scope.data = {
text: "blah",
comments:
[
{
text: ["blahL11", "blahL12", "blahL13"],
comments: [
{
text: ["blahL111", "blahL112", "blahL113"]
},
{
text: ["blahR111", "blahR112", "blahR113"]
}
]
},
{
text: ["blahR11", "blahR12", "blahR13"]
}
]
Run Code Online (Sandbox Code Playgroud)
};
我用递归 ng-include 显示它,如下所示:
<ul>
<li>{{data.text}}</li>
<li ng-repeat="item in data.comments" ng-include="'tree'"></li>
</ul>
<script type="text/ng-template" id="tree">
<ul>
<li ng-repeat="text in item.text">{{text}}</li>
<li ng-repeat="item in item.comments" ng-include="'tree'"></li>
</ul>
</script>
Run Code Online (Sandbox Code Playgroud)
http://plnkr.co/edit/8swLos2V6QRz6ct6GDGb?p=info
然而,我也想以某种方式跟踪递归的深度。这样就不是简单地显示:
-blah
-blahL11
-blahL12
-blahL13
-blahL111
Run Code Online (Sandbox Code Playgroud)
它可以显示
-1. blah
-2. blahL11
-2. …Run Code Online (Sandbox Code Playgroud) 这可能是一个非常简单的问题,但是try-catch块上的返回类型的最佳实践是什么?目前,我正在做这样的事情:
public List<SomeAttribute> FindAttributes(int id)
{
try
{
//Some query and some logic
}
catch (Exception ex)
{
Logger.Error(ex);
return new List<SomeAttribute>();
}
}
Run Code Online (Sandbox Code Playgroud)
这有什么特别可怕的吗?异常将被记录,该方法将返回一个空列表 - 调用函数可以处理.返回null更好吗?如果是这样的话?
我正在使用Ghostscript.NET将PDF页面转换为jpg.当我在本地运行它时,一切正常,但当我将它发布到Azure网站时,我得到错误:
" 此托管库在32位进程下运行,需要在此计算机上安装32位Ghostscript本机库!要下载正确的Ghostscript本机库,请访问:http://www.ghostscript.com/download/gsdnld.html "
显然,我不能只在运行Azure网站的服务器上安装Ghostscript,我无权访问.有没有办法在发布配置文件中包含Ghostscript库,并从中读取Ghostscript.NET?
或者,是否有任何软件包允许我在不使用Ghostscript的情况下将PDF页面转换为ASP.NET服务器上的jpg缩略图?我也尝试过GhostScriptSharp并且没有运气.
我正在执行一些测试,并且我有一个包含表单错误的值列表:
12.7 ± 0.3
14.2 ± 0.1
70.8 ± 0.5
Run Code Online (Sandbox Code Playgroud)
我需要将标准偏差与值保持一致,因为我稍后需要将其用于各种计算.
目前我正在使用
List<KeyValuePair<double, double>>
Run Code Online (Sandbox Code Playgroud)
但有更好的解决方案吗?
我有两种结构非常相似的方法:
public static List<List<NodeAttribute>> chunkList(List<NodeAttribute> list, int nSize = 30)
{
List<List<NodeAttribute>> chunkedList = new List<List<NodeAttribute>>();
for (var i = 0; i < list.Count; i += nSize)
{
chunkedList.Add(list.GetRange(i, Math.Min(nSize, list.Count - i)));
}
return chunkedList;
}
Run Code Online (Sandbox Code Playgroud)
和
public static List<List<int>> chunkList(List<int> list, int nSize = 30)
{
List<List<int>> chunkedList = new List<List<int>>();
for (var i = 0; i < list.Count; i += nSize)
{
chunkedList.Add(list.GetRange(i, Math.Min(nSize, list.Count - i)));
}
return chunkedList;
}
Run Code Online (Sandbox Code Playgroud)
理想情况下,我希望有一个通用方法,可以获取任何类型的List并返回该类型的列表列表 - 而不是仅仅为我可能需要的每个对象类型添加方法.我知道我可以使用泛型来执行此操作,但是如何使返回类型与输入相同的泛型类型?
c# ×5
.net ×1
angularjs ×1
asp.net ×1
azure ×1
generics ×1
ghostscript ×1
javascript ×1
recursion ×1