我正在开启旧项目的代码分析.大多数评论结果我都能理解,但 CA2000:在丢失范围之前处理对象很难做到.
例如,来自ASP.Net页面的此代码:
private void BuildTable()
{
HtmlTableRow tr = new HtmlTableRow();
HtmlTableCell td = new HtmlTableCell();
tr.Cells.Add(td);
// add some controls to 'td'
theTable.Rows.Insert(0, tr);
// 'theTable' is an HtmlTable control on the page
}
Run Code Online (Sandbox Code Playgroud)
提供CA消息:
CA2000:Microsoft.Reliability:在方法'BuildTable()'中,在对所有引用超出范围之前,在对象'tr'上调用System.IDisposable.Dispose.
CA2000:Microsoft.Reliability:在方法'BuildTable()'中,对象'td'未沿所有异常路径放置.在对对象'td'的所有引用都超出范围之前调用System.IDisposable.Dispose.(以及关于添加到'td'的控件的类似消息.)
我可以解决第二个问题:
private void BuildTable()
{
HtmlTableRow tr = new HtmlTableRow();
HtmlTableCell td = new HtmlTableCell();
try
{
tr.Cells.Add(td);
// add some controls to 'td'
td = null; // this line is only reached when there were no exceptions
}
finally …Run Code Online (Sandbox Code Playgroud) 可能重复:
将视图转换为位图而不在Android中显示它?
我正在尝试将视图从以下引用链接转换为位图
现在的问题是如何才能获得仅从视图转换的位图.在示例作者中使用了relativelayout.dispatchDraw(c),但这一行给出了编译时错误,即
来自ViewGroup类型的方法dispatchDraw(Canvas)不可见
这是我的代码,我在onCreate函数中编写了以下代码
Canvas c=null;
//Create Layout
RelativeLayout relativeView ;
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT
);
relativeView = new RelativeLayout(this);
relativeView.setLayoutParams(lp);
//Background of Layout
Bitmap viewBgrnd = BitmapFactory.decodeResource(getResources(),R.drawable.bgblack);
relativeView.setBackgroundDrawable(new BitmapDrawable(viewBgrnd));
//associated with canvas
Bitmap returnedBitmap = Bitmap.createBitmap(320,480,Bitmap.Config.ARGB_8888);
c = new Canvas(returnedBitmap);
Paint paint = new Paint();
//Create Imageview that holds image
ImageView newImage = new ImageView(this);
Bitmap srcBitmap = BitmapFactory.decodeResource(getResources(),R.drawable.bgpink);
newImage.setImageBitmap(srcBitmap);
TextView newText = new TextView(this);
newText.setText("This is the text that its going to …Run Code Online (Sandbox Code Playgroud) 我有一个带有电视信号实时视图的表格(来自dvb-t棒).我是来自http://directshownet.sourceforge.net/about.html的sampleproject"DTViewer" .现在我尝试通过单击按钮将流捕获到电影文件,但是如何?我使用C#和DirectShow.NET.
我尝试在许多sampleprojcets中搜索,但这些是针对视频输入而不是使用BDA(广播驱动程序架构)接口的dvb-t棒.
救命!
我尝试在texture2d上使用dispose函数,但这会导致问题,我很确定这不是我想要使用的.
我应该用什么来基本上卸载内容?内容管理员是否跟踪自己或者我必须做些什么?
struct ethernet_header
{
u_char ether_dhost[ ETHER_ADDR_LEN];
u_char ether_shost[ETHER_ADDR_LEN];
u_short ether_type;
};
for(i = 0;i <6; i++)
printf("dest ether:%x",ethernet->ether_dhost);
Run Code Online (Sandbox Code Playgroud)
如何在每个字节后以适当的可读形式打印以太网地址?我得到的o/p是十六进制的.这里以太网是指向结构的指针ethernet_header.
有人知道如何禁止emacs在模板子句后缩进函数或类的名称吗?
目前的结果是:
template <typename T>
class A {
/* ... */
};
Run Code Online (Sandbox Code Playgroud)
我想要的地方:
template <typename T>
class A {
/* ... */
};
Run Code Online (Sandbox Code Playgroud)
非常感谢您的帮助.
编辑1 我正在使用c ++ - 模式,java作为c ++的缩进样式.我用这种方式定制了c-offset-alist:
(custom-set-variables
;;
'(c-offsets-alist (quote ((case-label . +) (innamespace . 0))))
Run Code Online (Sandbox Code Playgroud) 我试图在JavaScript中运行以下总和
(a + b) - c
但不幸的是我一直得到以下结果(例如太阳):
(25 + 25) - 1
= 2524
这是我目前正在使用的代码
<script>
$(document).ready(function(){
$('#previousRent').change(function(){
calcResult();
});
$('#rentPaid').change(function(){
calcResult();
});
$('#wRun').change(function(){
calcResult();
});
});
function calcResult() {
$('#result').val( parseFloat($('#previousRent').val() + parseFloat($('#wRun').val()) - $('#rentPaid').val()) );
}
</script>
Run Code Online (Sandbox Code Playgroud)
有没有人知道如何摆脱所有字段未填充时出现的NaN?
我有一个表单输出一行简单的HTML <a href="link">A LINK</a>
我可以使用附加到网址的数据直接访问该流程,例如http://site.com/form.asp?sample=100
因为这是跨域(到子域),我试图使用JSONP.我首先尝试使用数据类型json,但我仍然得到403禁止.这是我正在尝试使用JSONP,但这是各种混乱,并返回错误与此%5Bobject%20Object%5D"附加到它.我想这是一个问题我如何尝试将数据附加到网址?
$j.getJSON({
type: 'POST',
url: 'http://site.com/form.asp',
data: 'order=' + ordervalue,
contentType: "application/json; charset=utf-8",
dataType: "jsonp",
success: function(response) {
alert(response);
}
});
Run Code Online (Sandbox Code Playgroud) 我有一个小的Python实用程序,它应该只作为管道运行.我希望它在单独运行时打印出帮助消息.一个过程如何知道它是否被用作管道.比较sys.stdin和sys.__stdin__不起作用.
我正在尝试在我的网站上使用嵌入式Google字体,并且每次有人访问网站时都包含从Google fonts API下载字体的链接,但我遇到了Firefox的问题,因为它似乎试图下载每次刷新或单击新链接时的字体.
在所有其他浏览器上,它只下载一次并将字体缓存到整个网站,就像任何其他缓存的东西一样.
Google字体API样式表的链接如下:
<link href='http://fonts.googleapis.com/css?family=Droid+Sans&subset=latin' rel='stylesheet' type='text/css'>
Run Code Online (Sandbox Code Playgroud)