问题列表 - 第34104页

为什么"someString + = AnotherString = someString;" 在C#中有效

我今天正在编写一些代码,当我在另一台显示器上的屏幕上进行alt-tabbed以检查某些内容时处于中间位置.当我回头看时,ReSharper将灰色下面的第3行着色,并注明"分配的值未在任何执行路径中使用".

var ltlName = (Literal) e.Item.FindControl("ltlName");
string name = item.FirstName;
name += 

ltlName.Text = name;
Run Code Online (Sandbox Code Playgroud)

我很困惑; 肯定这段代码无法编译.但确实如此,它也运行了."name + ="行对字符串没有影响(我可以告诉).这里发生了什么?

(Visual Studio 2008,.NET 3.5)

c# .net-3.5

16
推荐指数
3
解决办法
539
查看次数

错误:未捕获TypeError:对象#<对象>没有方法'pan'

出于某种原因,我收到此错误消息:

Uncaught TypeError: Object #<an Object> has no method 'pan'
Run Code Online (Sandbox Code Playgroud)

对于这行代码:

$('#bg_1').pan({fps: 3, speed: 2, dir: 'right'});
Run Code Online (Sandbox Code Playgroud)

我在这行代码之前连接了spritely插件,如下所示:http: //www.marioplanet.com/index.asp

有任何想法吗?

jquery

2
推荐指数
1
解决办法
2352
查看次数

如何从Windows上的SBT获取彩色编码控制台输出?

我正在使用SBT(简单构建工具)在Windows上构建我的Scala项目.我已经看到我的一个运行OSX的朋友在运行SBT时在他的终端窗口中获​​得了彩色编码输出,但我的颜色到处都是相同的颜色.有没有办法为Windows启用此功能?

windows scala sbt

11
推荐指数
1
解决办法
1822
查看次数

Java本地化最佳实践

我有一个带有服务器和Swing客户端的Java应用程序.现在我需要本地化用户界面,并且可能还需要一些特定于区域设置的数据.我想听听您的意见,具体情况很少.

  1. 我应该如何将UI的本地化字符串分发到属性文件中?在我的应用程序中有几个视图,每个视图都有几个面板.我应该为每个面板或视图的每种语言设置一个本地化文件,还是应该将一种语言的所有翻译保留在同一个文件中?我目前倾向于每个视图和语言一个文件,但我不确定如何处理出现在许多地方的某些特定于域的术语.在几个文件上进行相同的翻译听起来不太好.
  2. 服务器抛出一些异常,其中包含应向用户显示的消息.我可以从会话中获取所选的区域设置并在服务器上处理本地化,但我觉得将所有本地化文件保留在客户端会更优雅.我一直在考虑只从服务器发送一个本地化密钥,其中包含某种占位符以获取特定于错误的信息,这些信息将与异常一起发送.然后,客户端可以基于本地化密钥构造消息,并用错误特定信息替换占位符.这听起来像是处理它的好方法,还是有其他选择?通常,我的异常消息包含一些针对每种情况而更改的附加信息.例如," 用户名为Khilon的用户已经存在",在这种情况下,属性文件中的字符串将类似于" 用户名为{0}的用户已存在 ".
  3. The localization of the data is the area that is the most unclear to me. As I'm not sure if it will be ever required, I have so far not planned it very much. The database part sounds straightforward enough, you basically just need an additional table for the strings and a column to tell for which locale the string is. Though I'm not sure if it would be best to have a …

java swing localization

18
推荐指数
1
解决办法
6669
查看次数

C# label AutoSize adds padding

I have a Label on a Windows.Form. I set the AutoSize property on the label to True and I noticed that when I do that, it pads the right hand side with ~5px of white background. I have the Padding property set to [0, 0, 0, 0]. Is there a way to get rid of this?

I would like to get the bounds of the label as close as possible to the text within the label.

c# text label winforms

7
推荐指数
1
解决办法
4737
查看次数

在PHP中使用Xpath解析XML

请考虑以下代码:

$dom = new DOMDocument();
$dom->loadXML($file);

$xmlPath = new DOMXPath($dom);
$arrNodes = $xmlPath->query('*/item');
foreach($arrNodes as $item){
//missing code
}
Run Code Online (Sandbox Code Playgroud)

$ file是一个xml,每个项目都有一个标题和一个描述.如何显示它们(标题和说明)?

$file = "<item>
   <title>test_title</title>
   <desc>test</desc>
</item>";
Run Code Online (Sandbox Code Playgroud)

php xml xpath parsing

1
推荐指数
1
解决办法
1万
查看次数

C#中的房产表

我正在使用VS2005,我有一个属性表(vsprops文件),我正在添加到所有的C++项目,但我似乎无法找到如何将它们添加到C#项目.我该怎么做呢?

c# visual-studio-2005 visual-studio

8
推荐指数
2
解决办法
4301
查看次数

如何循环SVG动画序列?

我有序列animationTransform:

<animateTransform attributeName="transform" attributeType="XML" type="rotate" from="0" to="30" begin="0s" dur="0.4s" fill="freeze"/>
<animateTransform attributeName="transform" attributeType="XML" type="rotate" from="30" to="0" begin="0.4s" dur="0.4s" fill="freeze"/>
Run Code Online (Sandbox Code Playgroud)

如果可以在不使用脚本的情况下循环此序列?

我可以通过使用repeatCount="indefinite"我想循环整个序列的顺序设置单个动画循环.

animation svg smil

27
推荐指数
3
解决办法
3万
查看次数

错误:未捕获的SyntaxError:意外的令牌<

出于某种原因,我收到此错误消息:

Uncaught SyntaxError: Unexpected token <
Run Code Online (Sandbox Code Playgroud)

对于这行代码:

title: '<img src="/images/text/text_mario_planet_jukebox.png" id="text_mario_planet_jukebox"/>',
Run Code Online (Sandbox Code Playgroud)

在这方面:

$(document).ready(function() {
    $('#infobutton').click(function() {
        $('#music_descrip').dialog('open');
    });
        $('#music_descrip').dialog({
            title: '<img src="/images/text/text_mario_planet_jukebox.png" id="text_mario_planet_jukebox"/>',
            autoOpen: false,
            height: 375,
            width: 500,
            modal: true,
            resizable: false,
            buttons: {
                'Without Music': function() {
                    $(this).dialog('close');
                    $.cookie('autoPlay', 'no', { expires: 365 * 10 });
                },
                'With Music': function() {
                    $(this).dialog('close');
                    $.cookie('autoPlay', 'yes', { expires: 365 * 10 });
                }
            }
        });
    });
Run Code Online (Sandbox Code Playgroud)

我认为一切都应该很好,但我不明白为什么<会以某种方式抛弃它.

哎呀,忘了展示这是怎么回事!我的错,

http://www.marioplanet.com/index.asp

有任何想法吗?

jquery token

45
推荐指数
4
解决办法
22万
查看次数

什么不在Rails中测试?

我已经写了一段时间的测试,我开始掌握一切.但是我有一些关于测试覆盖率真正需要的问题.共识似乎很清楚:更多的报道总是更好.但是,至少从初学者的角度来看,我想知道这是否真的如此.

以这个完全香草控制器动作为例:

def create
  @event = Event.new(params[:event])
  if @event.save
    flash[:notice] = "Event successfully created."
    redirect_to events_path
  else
    render :action => 'new'
  end
end
Run Code Online (Sandbox Code Playgroud)

只是生成的脚手架.我们这里没有做任何不寻常的事情.为什么为此操作编写控制器测试很重要?毕竟,我们甚至没有编写代码 - 生成器为我们完成了工作.除非rails中存在错误,否则此代码应该没问题.看起来测试这个动作与测试,例如collection_select并没有太大的不同 - 我们不会这样做.此外,假设我们使用黄瓜,我们应该已经涵盖了基础知识(例如重定向的地方).

对于简单的模型方法,甚至可以说同样的情况.例如:

def full_name
  "#{first_name} #{last_name}"
end
Run Code Online (Sandbox Code Playgroud)

我们真的需要为这些简单的方法编写测试吗?如果出现语法错误,您将在页面刷新时捕获它.同样,只要你的功能点击任何调用full_name方法的页面,黄瓜就会捕获这个.显然,我们不应该依赖黄瓜来做任何过于复杂的事情.但是full_name真的需要单元测试吗?

您可能会说,因为代码很简单,测试也很简单.所以你不妨写一个测试,因为它只需要一分钟.但似乎写作基本上毫无价值的测试可能弊大于利.例如,它们使您的规格变得混乱,使得更难以专注于实际上重要的复杂测试.此外,他们需要时间来运行(虽然可能不多).

但是,就像我说的那样,我几乎不是专家测试员.我不一定主张减少测试覆盖率.相反,我正在寻找一些专家建议.是否真的有理由写这么简单的测试?

testing rspec ruby-on-rails

13
推荐指数
4
解决办法
1629
查看次数