views:

30

answers:

1

I currently have a class of this form:

class Abc {
    private readonly IDisposable disposable;

    public Abc(IDisposable disposable) {
        this.disposable = disposable;
    }

    ...
}

Now, I'd like to know how can I make a binding of IDisposable to Bitmap using the

Bitmap(int widht, int height)

constructor.

I've tried with the following piece of code, but it doesn't seem to do it:

class TestModule : NinjectModule {

    public override void Load()
    {
        Bind<IDisposable>().To<Bitmap>()
            .WithConstructorArgument("width", 10)
            .WithConstructorArgument("height", 22)
            ;
    }
}
A: 

Doh, this was an easy one:

Bind<IDisposable>().ToConstant(new Bitmap(10, 22));

will work, for example. There are a couple of other ways of doing it, though. They are all in the Bind() return object.

devoured elysium