我正在测试我的Zend Framework应用程序,并希望测试在注册表中未设置特定键时发生的事情.这是我正在测试的功能:
protected function getDomainFromConfig() {
$config = Zend_Registry::get('config');
if (!isset($config->domain)) {
throw new Exception('Please make sure you have "domain" set in your config file and your config file is being set in the Zend_Registry.');
}
return $config->domain;
}
Run Code Online (Sandbox Code Playgroud)
如何取消注册表中的密钥?我试过这个,但它不起作用:
$config = Zend_Registry::get('config');
$config->__unset('domain');
Run Code Online (Sandbox Code Playgroud)
更新:我真正想知道的是,如果未设置配置文件中的"domain"键,我应该如何测试我的方法抛出异常.
什么Subversion(SVN)服务器会推荐新手入门Windows Server操作系统?
我想我将在客户端上使用TortoiseSVN,并且主要进行.NET开发.
更新:
很好的建议.我根据投票选择答案.我将尝试VisualSVN和CollabNet.请阅读我认为非常好的chyne答案(+1).我也会尝试这种方法.
我将在一两个星期内回复这个问题,并在评论中提出我的想法.
Dictionary<string, string> optionDictionary = new Dictionary<string, string>();
optionDictionary = ....;
SortedDictionary<string, string> optionsSorted;
if(sorting)
{
optionsSorted = new SortedDictionary<string, string>(optionDictionary );
// Convert SortedDictionary into Dictionary
}
return optionDictionary ;
Run Code Online (Sandbox Code Playgroud) 我有一个XML文档,我想更改其中一个属性的值.
首先,我使用以下方法复制从输入到输出的所
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
Run Code Online (Sandbox Code Playgroud)
现在我想"type"在任何名为的元素中更改属性的值"property".
我问了一个关于回调的问题并得出了另一个问题(见评论).闭包与回调有什么不同?
我正在写一个jQuery插件,处理一个简单的调用插件功能(像一堆图像动画$("#image1").anims()这里#image1是一个图像),但是由于该插件的部分功能,我用$(this).width()在获取图像正确的宽度启动函数调用.
但是,由于调用插件函数$(document).ready,它试图在图像加载之前获取图像的宽度,因此它总是返回0.是否有解决方法?
可能重复:
如何找到调用当前方法的方法?
我在对象中有一个方法,从对象中的许多地方调用.是否有一种快速简便的方法来获取调用此流行方法的方法的名称.
伪代码示例:
public Main()
{
PopularMethod();
}
public ButtonClick(object sender, EventArgs e)
{
PopularMethod();
}
public Button2Click(object sender, EventArgs e)
{
PopularMethod();
}
public void PopularMethod()
{
//Get calling method name
}
Run Code Online (Sandbox Code Playgroud)
在内部,PopularMethod()我希望看到Main它是否被调用的价值Main......我想看看" ButtonClick"是否PopularMethod()被调用ButtonClick
我在看,System.Reflection.MethodBase.GetCurrentMethod()但这不会让我得到调用方法.我看过这个StackTrace类,但是每次调用该方法时我都不喜欢运行整个堆栈跟踪.
在我的Java应用程序中,我想运行一个调用" scons -Q implicit-deps-changed build\file_load_type export\file_load_type" 的批处理文件
似乎我甚至无法执行我的批处理文件.我没有想法.
这就是我在Java中所拥有的:
Runtime.
getRuntime().
exec("build.bat", null, new File("."));
Run Code Online (Sandbox Code Playgroud)
以前,我有一个我想运行的Python Sconscript文件,但由于这不起作用,我决定通过批处理文件调用脚本,但该方法尚未成功.
c# ×2
java ×2
javascript ×2
.net ×1
batch-file ×1
callback ×1
closures ×1
config ×1
generics ×1
interface ×1
jogl ×1
jquery ×1
methods ×1
opengl ×1
php ×1
reflection ×1
registry ×1
runtime.exec ×1
svn ×1
tortoisesvn ×1
web ×1
xslt ×1
xslt-1.0 ×1
xslt-2.0 ×1