我有一个接口方法
public void Execute(ICommand command);
Run Code Online (Sandbox Code Playgroud)
需要将已知的子类型传递ICommand给适当的Handle(SpecificCommand command)方法实现,并对未知类型进行一些通用处理.我正在寻找一种通用(即不需要巨大的开关)方法,类似于
Handle(command as command.GetType()); // this obviously does not compile
Run Code Online (Sandbox Code Playgroud)
我知道我可以以某种方式注册处理程序,例如将它们作为Handle(...)代理存储在字典中,但这仍然需要复制处理逻辑(一次在特定方法签名中,一次在委托重新注册中).如果我通过用反射检查我的类来填充字典(寻找Handle(XXX command)方法),我会受到性能影响.
总结一下:我如何向下转换一个对象(通过调用来升级Execute(ICommand command))来调用一个需要具体类型的方法,而不知道它在编译时是哪种类型.
我在Miguel de Icaza的一些写作中提到了使用mono制作iphone应用程序的提前编辑(aot).这听起来像是本机代码的结果.是这样还是有什么区别?
我刚刚加入了一个团队,无论出于什么原因,他们都不会将.sln文件签入源控件(VSS).他们创建本地解决方案文件,并从源代码管理中将Web应用程序项目添加到其中.
我试图向他们展示CruiseControl.Net的美丽但是在ccnet.config文件中,我习惯将构建工具(DEVENV)指向.sln文件.
有没有人知道我在CruiseControl中解决这个问题的最佳方法?
PS.不要滥用使用VSS,我们很快就会转移到SVN.
- 李
我使用的是0.85版本.我已经在文件中定义了一个属性,并且没有指定像'read only = true'.但是在我尝试更改属性的值时,我得到警告说,属性不能被覆盖.
我试过设置readonly="false" overwrite="true".但似乎没什么用.任何帮助将不胜感激 .
我正在尝试使用zend框架开发网站,所以我创建了一个index.php文件,我的所有请求都去了,c.reated两个控制器一个是IndexController,另一个是TestController
Class IndexController extends Zend_Controller_Action{
public function indexAction(){
echo "Index Index Jamla";
}
public function displayAction(){
echo "Index Display Jamla";
}
}
Run Code Online (Sandbox Code Playgroud)
现在,当我访问url http:// test / 它正确调用IndexController及其IndexAction函数但是当我访问url http:// test/index/index时, 它显示在此服务器上找不到消息url/index/index与我访问http:// test/test/index时相同
嗨,我正在尝试制作一个将条纹效果添加到无序列表的函数,到目前为止,我已经获得了以下内容,但无法确定选择器的工作方式。
(function($) {
$.fn.stripe = function(){
this.$("li:even").css("background-color","#f00");
};
})(jQuery);
$("list_id").stripe();
Run Code Online (Sandbox Code Playgroud) 如何通过小型内存数据库更新大型永久数据库?我有一个应用程序,它有一个很大的永久数据库(在硬盘上)和小的内存数据库(在 RAM 中)。在我的应用程序运行时内存数据库被填满,并在运行结束时更新永久数据库。
有谁知道我怎么能做到这一点?
我一直在教自己C++,有人告诉我C++没有垃圾收集器.现在我不确定这意味着什么程度.
让我说我有这个代码:
double multiply (double a, double b) {
double result = a * b;
return result;
};
int main (char* args[]) {
double num1 = 3;
double num2 = 12;
double result = multiply(num1, num2);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
乘法方法包含内部变量"result".现在是仍然分配和/或锁定变量"result"的内存地址?参数"a"和"b"怎么样?
我正在尝试创建一个twitter类并创建一个调用该类的方法和属性的对象.基本上我正在做的是为twitter用户名调用数据库并使用结果生成simplexml请求.(我省略了代码的那部分,因为它工作正常).
一切似乎都工作正常,除了我无法弄清楚为什么当我return $this->posts只返回数组的第一个项目时.当我删除return整个数组时返回.我正在使用print_r底部的对象进行测试.
<?php
class twitter {
public $xml;
public $count;
public $query;
public $result;
public $city;
public $subcategory;
public $screen_name;
public $posts;
public function arrayTimeline(){
$this->callDb($this->city, $this->subcategory);
while($row = mysql_fetch_row($this->result)){
foreach($row as $screen_name){
$this->getUserTimeline($screen_name, $count=2);
}
foreach($this->xml as $this->status){
return $this->posts[] = array("image"=>(string)$this->status->user->profile_image_url,"name"=>(string)$this->status->name, "username"=>(string)$this->status->user->name, "text"=>(string)$this->status->text, "time"=>strtotime($this->status->created_at));
}
}
}
$test = new twitter;
$test->city="phoenix";
$test->subcategory="computers";
$test->arrayTimeline();
print_r($test->posts);
?>
Run Code Online (Sandbox Code Playgroud)