问题列表 - 第10854页

什么时候在javascript OO中使用它?

在Javascript OO中,我何时应该使用this关键字?

另外,如果我想从同一个类的另一个方法调用类的方法,我应该使用this还是只使用函数的名称?这是对的吗?

function Foo()
{
   this.bar= function()
   {
      alert('bar');
   }

   this.baz= function()
   {
     this.bar(); //should I use this.bar() or just bar()?
   }
}
Run Code Online (Sandbox Code Playgroud)

javascript oop scope

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

如何在每个WPF窗口中处理快捷键?

我想基于一些自定义逻辑打开帮助文件到页面.如何处理用户在我的所有窗口(主窗口和模态对话框)上按F1键?

我知道如何在一个窗口中处理F1,但这可以全局完成,所以我不必在所有窗口中添加相同的代码吗?

下面是我尝试过的测试,F1在子窗口上不起作用.

Window1.xaml:

<Window x:Class="WpfApplication2.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Window.CommandBindings>
        <CommandBinding Command="ApplicationCommands.Help"
                        Executed="CommandBinding_Executed"/>
    </Window.CommandBindings>
    <Grid>
        <Button Content="Open a new window"
                Click="Button_Click"/>
    </Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)

Window1.xaml.cs:

using System.Windows;
using System.Windows.Input;

namespace WpfApplication2
{
    partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();
        }

        void CommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            MessageBox.Show("Help");
        }

        void Button_Click(object sender, RoutedEventArgs e)
        {
            new Window().ShowDialog();
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

c# wpf keyboard-shortcuts hotkeys

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

GetCustomAttribute()为AssemblyVersionAttribute返回null

我正在向.NET应用程序添加一个About对话框,我正在查询程序集的属性以显示信息.当我尝试AssemblyVersionAttribute使用GetCustomAttribute()它来检索我的程序集时返回null:

// Works fine
AssemblyTitleAttribute title
    = (AssemblyTitleAttribute)Attribute.GetCustomAttribute(
        someAssembly, typeof(AssemblyTitleAttribute));

// Gets null
AssemblyVersionAttribute version
    = (AssemblyVersionAttribute)Attribute.GetCustomAttribute(
        someAssembly, typeof(AssemblyVersionAttribute));
Run Code Online (Sandbox Code Playgroud)

AssemblyInfo.cs觉得很好.我定义了这些属性:

[assembly: AssemblyTitle("Some Application")]
[assembly: AssemblyVersion("1.0.0.0")]
Run Code Online (Sandbox Code Playgroud)

这是怎么回事?我有一个解决方法,但我想知道为什么上面的代码不起作用.

// Work-around
string version = someAssembly.GetName().Version.ToString();
Run Code Online (Sandbox Code Playgroud)

.net null assemblyversionattribute

21
推荐指数
3
解决办法
5459
查看次数

类库中的HtmlEncode

我有一个类库(在C#中).我需要使用HtmlEncode方法对数据进行编码.这很容易从Web应用程序.我的问题是,如何从从控制台应用程序调用的类库中使用此方法?

c# html-encode

164
推荐指数
5
解决办法
12万
查看次数

如何从正在运行的脚本中删除IRB提示符?

我可以从正在运行的Ruby脚本中转到IRB提示符吗?

我想运行一个脚本,但是然后让它在程序中的一个点上给出一个IRB提示符,其中包含程序的当前状态,但不仅仅是运行rdebug并有一个断点.

ruby irb

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

接口类型构造函数

在"CLR Via C#"的第八章(p189)中,杰弗里里希特说:

"Type构造函数可以应用于接口(尽管C#不允许这样做)"

我做了一些研究,我似乎无法找到为什么接口需要任何语言的类型构造函数.这似乎是你在CLR中明确禁止的东西.

什么时候需要它,为什么可能呢?

.net c# clr

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

使用多个PHP包含了一个坏主意吗?

我正在创建一个PHP站点.它使用多个PHP类,这些类目前都包含在一个PHP中.

但是,我正在使用Aptana IDE,该文件现在开始崩溃(它大约有400行).所以我想知道是否会分别包含所有文件会产生任何负面影响.

当前:

主文件:

include("includes.php");
Run Code Online (Sandbox Code Playgroud)

includes.php:

contains php classes
Run Code Online (Sandbox Code Playgroud)

建议:

mainfile:主文件:

include("includes.php");
Run Code Online (Sandbox Code Playgroud)

includes.php:

include("class1.php");
include("class2.php")
Run Code Online (Sandbox Code Playgroud)

php include

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

在DirectX中显示视频

在使用XAudio2和Direct3D9/10的应用程序中显示视频(有声!)的最佳/最简单方法是什么?

至少它需要能够流式传输更大的视频,并注意窗口宽高比可能与视频不同的事实(例如通过添加信箱),尽管理想情况下我喜欢将视频嵌入到视频中的能力一个3D场景.

我当然可以设法将每个帧加载到纹理中,一旦渲染就丢弃/重复使用纹理,并通过XAudio2单独播放音频,但是除了编写至少一种格式的加载器之外,还必须处理喜欢同步视频和音频组件之类的东西,所以希望有一个更好的解决方案,甚至是现成的免费解决方案(二进制形式的商业发行,动态链接在LGPL的情况下很好).

c++ directx video direct3d xaudio2

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

无法从Sequel gem连接mysql

当我尝试从Sequel连接MySQL时.我收到这些错误:

require 'rubygems'
        require 'sequel'
        DB = Sequel.connect(:adapter => 'mysql', :user => 'root', :host => 'localhost', :database => 'scanty',:password=>'xx')
        DB.tables
    Sequel::DatabaseConnectionError: NameError uninitialized constant Mysql::CLIENT_MULTI_RESULTS
        from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/adapters/mysql.rb:98:in `connect'
        from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/database.rb:92:in `initialize'
        from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/connection_pool.rb:166:in `call'
        from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/connection_pool.rb:166:in `make_new'
        from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/connection_pool.rb:153:in `available'
        from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/connection_pool.rb:144:in `acquire'
        from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/connection_pool.rb:143:in `synchronize'
        from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/connection_pool.rb:143:in `acquire'
        from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/connection_pool.rb:105:in `hold'
        from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/database.rb:471:in `synchronize'
        from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/adapters/mysql.rb:128:in `execute'
        from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/dataset.rb:314:in `execute'
        from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/adapters/mysql.rb:342:in `execute'
        from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/adapters/mysql.rb:298:in `fetch_rows'
        from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/dataset.rb:185:in `each'
        from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/dataset/convenience.rb:156:in `map'
        from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/dataset/convenience.rb:156:in `map'
        from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/adapters/shared/mysql.rb:60:in `tables'
        from …
Run Code Online (Sandbox Code Playgroud)

ruby mysql sequel

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

Web应用程序项目程序集引用存储在哪里?

为Web应用程序存储的程序集引用位置在哪里?

在网站中,当您添加引用时,我会看到在web.config中写入程序集节点的程序集标记.我只是好奇Web应用程序项目如何建立连接以获得正确的本地DLL?

我手动添加引用和应用程序构建,但dll不会导入到BIN文件夹中,并且组装节点不会在Web配置中创建,因为它们位于Web站点中.我做一个解决方案搜索文本'assembly ="SomeAssembly ..."并没有找到结果.

我只是很好奇,因为我试图集中更新程序集引用,因为第三方控件供应商定期发布修补程序,我们最终必须运行并更新所有单个页面引用程序集.我能够在Web站点项目中有效地完成这项工作,但我对Web应用程序项目还是比较陌生的.任何建议或链接将不胜感激.我想我正在寻找有关ASP.NET Web应用程序项目的汇编和控件参考管理的技巧.

asp.net assemblies web-config

11
推荐指数
2
解决办法
9606
查看次数