我有一个包含字符串的列表"Others".我得到这个列表下拉.我按字母顺序排序这个列表.但我"Others"总是需要在列表的末尾.我不想在排序后添加这个元素,这是一个解决方案.有没有其他方法可以像使用.Sort()方法的自定义比较器一样.我试过下面但没有解决方案.
public class EOComparer : IComparer<string>
{
public int Compare(string x, string y)
{
if (x == null)
{
if (y == null)
{
// If x is null and y is null, they're
// equal.
return 0;
}
else
{
// If x is null and y is not null, y
// is greater.
return -1;
}
}
else
{
// If x is not null...
//
if (y == null)
// ...and …Run Code Online (Sandbox Code Playgroud) 我知道这个主题多次出现在主板上,但我无论如何都无法工作......我想保存从预览到jpeg文件的视图帧.它看起来或多或少(代码简化 - 没有额外的逻辑,例外等)像这样......
public void onPreviewFrame(byte[] data, Camera camera) {
int width = camera.getParameters().getPreviewSize().width;
int height = camera.getParameters().getPreviewSize().height;
final int[] rgb = decodeYUV420SP(data, width, height);
Bitmap bmp = Bitmap.createBitmap(rgb, width, height,Bitmap.Config.ARGB_8888);
String filename="/sdcard/file" + (index++)+ ".jpg";
FileOutputStream out;
out = new FileOutputStream(filename);
bmp.compress(Bitmap.CompressFormat.JPEG, 90, out);
out.flush();
out.close();
out=null;
}
Run Code Online (Sandbox Code Playgroud)
这是我尝试转换颜色的方法之一(我相信这个板)
public int[] decodeYUV420SP( byte[] yuv420sp, int width, int height) {
final int frameSize = width * height;
int rgb[]=new int[width*height];
for (int j = 0, yp = 0; j < …Run Code Online (Sandbox Code Playgroud) 我想知道是否有一种方法可以使用PBEKeySpec字节数组参数.
请找到以下文档的链接:
http://docs.oracle.com/javase/1.7/docs/api/javax/crypto/spec/PBEKeySpec.html)
我DefaultHttpClient在我当前的应用程序中使用.
我读过这篇文章,该文章指出DefaultHttpClient已弃用:http://developer.android.com/reference/org/apache/http/impl/client/DefaultHttpClient.html
它指向这个网站:http://android-developers.blogspot.com/2011/09/androids-http-clients.html?m = 1,它太旧了,写于2011年.
我将放弃使用DefaultHttpClient并遵循这篇使用Apache的文章HttpClient:http://loopj.com/android-async-http/
我想知道这是在2015年针对Android API 19及更高版本的编程时采取的正确途径.
在本地托管的TFS上,我在构建定义中使用"npm install"构建步骤.
在代理机器上,我安装了nodejs,可以从命令行运行npm.
当我尝试对构建进行排队时,我会弹出一条消息:
没有具有以下功能的代理:npm,DotNetFramework
所以我尝试添加该功能,首先刷新代理功能,当没有效果时,我添加了一项功能:
npm C:\ Program Files \nodejs
然后构建开始但是npm步骤抛出错误:
无法找到npm
我怀疑我在代理设置上遗漏了一些东西,因为代理没有报告其npm功能?
我已经开始使用这样的定义类:
internal sealed class Defines
{
/// <summary>
/// This constant is set to true iff the define DEBUG is set.
/// </summary>
public const bool Debug =
#if DEBUG
true;
#else
false;
#endif
}
Run Code Online (Sandbox Code Playgroud)
我看到的优点是:
我看到可能的缺点:
如果Defines类在另一个程序集中,则编译器无法优化未使用的代码.这就是我做内部的原因.
我错过了任何其他缺点吗?
[编辑]典型的用法示例:
private readonly Permissions _permissions = Defines.Debug ? Permissions.NewAllTrue()
: Permissions.NewAllFalse();
Run Code Online (Sandbox Code Playgroud)
要么:
var str = string.Format(Defines.Debug ? "{0} {1} ({2})" : "{0} {1}", actual, text, advance);
Run Code Online (Sandbox Code Playgroud) 我有空间模拟,所以很明显我不需要重力或空气阻力.重力是直接关闭,但我找不到空气阻力的等效物.我认为它将是逐个身体而不是像引力这样的世界范围.
事实上,我看到btSoftBody有中等密度的值,air_density但我正在使用btRigidBody.
要链接到Controller/A/<anId>我这样做:
@Html.ActionLink(anId, "Action", "Controller", new {id = anId})
Run Code Online (Sandbox Code Playgroud)
Resharper强调了行动,我可以使用F12导航到它.
但我有一个api控制器的链接:
@Html.ActionLink("API Version", "../api/controller/", new {id = anId})
Run Code Online (Sandbox Code Playgroud)
这没有resharper导航选项,如果重命名控制器,则不会重构.是否有更简洁的方法从剃刀视图链接到APIController?特别是一个Resharper认可.
关注这个问题,请在http://referencesource.microsoft.com/netframework.aspx上查看此列表:
我不确定我需要下载什么.我有VS2010和VS2012.Net 4.5Update1
对于VS2012来说听起来不错,但在下载之后,我读到"与Visual Studio 2008/2010无缝集成",但我认为这只是过时的自述文件.
什么是.NET 8.0?为什么有这么多不同的3.5版本?
我有一个MockHttpListener用于单元测试的回调.我添加了一个锁,如下所示:
public void HandleRequest(HttpListenerContext context)
{
try
{
lock (m_guard)
{
do something short;
}
do the actual handling (longer)
}
catch (HttpListenerException e)
{
...
}
catch (Exception e)
{
...
}
...
}
Run Code Online (Sandbox Code Playgroud)
我遇到了一个问题,即测试失败是由于我们有"太长时间"的标准(在添加锁之前我没有在测试中遇到这个问题.)
我尝试了许多方法来确定问题,解决问题的唯一方法就是在try块之外进行锁定:
public void HandleRequest(HttpListenerContext context)
{
lock (m_guard)
{
do something short;
}
try
{
do the actual handling (longer)
}
catch (HttpListenerException e)
{
...
}
catch (Exception e)
{
...
}
...
}
Run Code Online (Sandbox Code Playgroud)
在相对于try块的锁定位置影响测试完成所花费的持续时间方面,行为改变是一致的.
任何人都知道原因吗?