This project is read-only.

Re: HttpHostConfiguration pattern too inflexible

Topics: Web Api
May 16, 2011 at 12:48 AM
It's because of the explicit interface implementation :(.

Casting to the builder interface allows me to pass a resource factory instance, like so:

var configuration = (IHttpHostConfigurationBuilder)new HttpHostConfiguration();
configuration.SetResourceFactory(new AutofacResourceFactory(container));

Moving on...


Daniel Cazzulino | Developer Lead | MS MVP | Clarius Consulting | +1 425.329.3471

On Sun, May 15, 2011 at 20:44, Daniel Cazzulino <> wrote:
The built-in configuration factory follows a pattern where the properties (such as InstanceFactory) are readonly (internal set) and the fluent setters (i.e. SetResourceFactory<T>) require the T to have a public default constructor (new() constraint).

This seems unnecessarily limiting. I cannot provide a ready-built resource factory (i.e. with some external dependencies already built-in) in any way, unless I go and implement the entire IHttpHostConfigurationBuilder interface.

The setter for the properties should be at least protected internal set, so that from a custom configuration I can set the property to an instantiated value.

Concrete case: I'm creating an AutofacResourceFactory, which needs the IContainer to pull instances from.

Maybe I'm just missing something obvious :)


Daniel Cazzulino | Developer Lead | MS MVP | Clarius Consulting | +1 425.329.3471