I need some assistance. I am trying to use Autofac to get me a few dependencies that are need for a custom media formatter. I followed the Wiki but it is a little confusing. I am trying to use property injection for the media formatter since it needs to be registered with the global configuration.
Code:
public class UserMediaFormatter : JsonMediaTypeFormatter
{
public UsersRepository repository { get; set; }
}
public class WebApiApplication : System.Web.HttpApplication
{
GlobalConfiguration.Configuration.Formatters.Insert(2, new UserMediaFormatter());
builder.RegisterType(typeof(UserMediaFormatter)).PropertiesAutowired()
.As<MediaTypeFormatter>()
.InstancePerApiControllerType(typeof (UsersController));
}
[AutofacControllerConfiguration]
public class UsersController : ApiController
{
}