问题列表 - 第50002页

添加参数,还是创建新方法?

假设我有一个长期建立的存储库,如下所示:

interface IDonutRepository
{
    public IEnumerable<Donut> GetDonuts();
}
Run Code Online (Sandbox Code Playgroud)

它已经存在了很长时间,并且该GetDonuts方法实现了它所说的.然后有一天我需要添加一个新的屏幕,显示数据库中的所有甜甜圈,结果证明该方法有一个隐藏的功能 - 它过滤掉所有的甜甜圈stale = true.但是在我的新屏幕上,我想展示所有这些,甚至是陈旧的!这里最好的方法是什么?

假设这个方法在所有地方使用,并且默认行为需要保持不变,最好是添加一个名为GetAllDonuts不进行过滤的新方法,还是应该只onlyFreshGetDonuts方法中添加一个参数?

我猜它只是判断力,但我想知道那里是否有更明智的答案?

c# oop design-patterns

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

如何覆盖javascript函数

我试图在js中覆盖内置的parseFloat函数.我该怎么做呢?

javascript

90
推荐指数
5
解决办法
16万
查看次数

如何将NSTableView的选择绑定到NSArrayController

我只是想能够使用名为remove的nsarraycontroller的方法:并添加:

cocoa binding nstableview nsarraycontroller

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

我可以在Python中将两个装饰器组合成一个装饰器吗?

有没有办法在python中将两个装饰器组合成一个新的装饰器?

我意识到我可以将多个装饰器应用于一个函数,但我很好奇是否有一些简单的方法将两个组合成一个新的.

python decorator

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

在Explorer 7中将所有<li> s显示为数字1的有序列表

我已经注意到IE7中的一个奇怪的问题,我无法找到解决方案.我有一个正确格式化的标准有序列表,所有打开和关闭标签都完好无损.

<ol>
   <li>Item 1</li>
   <li>Item 2</li>
   <li>Item 3</li>
   <li>Item 4</li>
</ol>
Run Code Online (Sandbox Code Playgroud)

所有浏览器都会正确显示列表,但Explorer 7除外,它会将列表呈现如下:

1. Item 1
1. Item 2
1. Item 3
1. Item 4
Run Code Online (Sandbox Code Playgroud)

以前有没有人遇到过这个问题?这是列表的链接.谢谢你的任何建议.

html html-lists internet-explorer-7

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

CodeIgniter POST变量

有人知道原因:

class Booking extends Controller {

    function booking()
    {
        parent::Controller();
    }

    function send_instant_to_paypal()
    {
        print_r($_POST);
        echo '&lt;hr />';
        print_r($this->input->post());
        echo '&lt;hr />';
        $id_booking = $this->input->post('id_booking');
        $title = $this->input->post('basket_description');
        $cost = ($this->input->post('fee_per_min') * $this->input->post('amount'));
        echo $id_booking;
        echo $title
        echo $cost
    }
}
Run Code Online (Sandbox Code Playgroud)

将回显CI中的变量用于$ _POST但不用于$ this-> input-> post();?

我已经使用了$ this-> input-> post()并在网站的其他地方搜索了一个搜索页...但是在这个页面上,它不起作用..这是我的表格......

<form id="add_funds" action="' . site_url('booking/send_instant_to_paypal') . '" method="post">
<input type="text" name="amount" id="amount" value="" />
<input type="hidden" name="id_booking" id="id_booking" value="0" />
<input type="hidden" name="basket_description" id="basket_description" value="Adding Credit" />
<input type="hidden" name="fee_per_min" …

post codeigniter

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

flex中actionscript 3 for循环的基础知识

早安stackoverflow ...我遇到了问题....这是我的示例代码

var i:Number = new Number();

trace("showarray length" + showArray.length);

for(i=0;i<showArray.length;i++){

    trace("equal daw" + showArray.getItemAt(i).id + "==" + num);

    if(showArray.getItemAt(i).id == num){
        showArray.removeItemAt(i);

    }
}
trace('alerts');
Run Code Online (Sandbox Code Playgroud)

myproblem这里是......无论if何时满足它都会停止循环,它会立即退出循环

这是一个示例输出,因为showArray的长度是2而num = 0

showarray length2

等于daw0 == 0

警报

请帮我

apache-flex actionscript-3

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

CakePHP日历

我是CakePHP的新手,并希望使用此框架创建日历.我有一段困难时期,我想知道是否有关于如何使用CakePHP创建简单日历的教程或指南?

calendar cakephp

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

可达性最佳实践

我的应用程序提取了一个json数据源,我刚刚将可访问性检查添加到app delegate中的applicationDidBecomeActive.如果网络是可联系的,则加载视图控制器.从视图控制器中调用解析器类,该类填充UITableview.如果网络不可联系,则会显示警报.如果用户按下主页按钮,则激活无线或蜂窝数据,然后返回应用程序,视图控制器将被加载.虽然这有效但解决方案并不是特别优雅,因为每次用户在放入后台后返回应用程序时,视图控制器调用都会再次运行.我想知道是否有更好的选择?

AppDelegate.m

  - (void)applicationDidBecomeActive:(UIApplication *)application {

// Check for network connectivity

reachability = [Reachability reachabilityForInternetConnection];
[reachability startNotifier];

NetworkStatus remoteHostStatus = [reachability currentReachabilityStatus];

if(remoteHostStatus == NotReachable) {
    UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Connection Error" message:@"App cannot connect to the internet" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [alert show];
    [alert release];
    self.internetActive = NO;
}


else {

    NSLog(@"internet available");
    self.internetActive = YES;

}


// if internet available call viewcontroller;

if (self.internetActive) {
    navController.viewControllers = [NSArray arrayWithObject:viewController];
    [window addSubview:navController.view];
    [window makeKeyAndVisible];
}
else {
    //error pic …
Run Code Online (Sandbox Code Playgroud)

c iphone cocoa objective-c

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

如何解决Ninject模块中的依赖关系?

我正在使用Ninject 2和Asp.Net MVC 3.我有以下模块.

public class ServiceModule : NinjectModule
{
    public override void Load()
    {
        //I need to get the 'configHelper' from Ninject Container. 
        IConfigHelper configHelper = ResolveConfigHelperHere();

        Bind<IMyService>().To<MyServiceImpl>().WithConstructorArgument("myArg", configHelper.MyProperty);

    }
}
Run Code Online (Sandbox Code Playgroud)

我们如何获得已经在Ninject模块中绑定的'IConfigHelper'实例?

c# ninject asp.net-mvc-3

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