I'm trying to create a MVC html helper extension that have to be declared as a static class, something like this:
public static class PhotoExtension
{
public static IPhotoService PhotoService { get; set; }
public static IGalleryService GalleryService { get; set; }
public static MvcHtmlString Photo(this HtmlHelper helper, int photoId, string typeName)
{
//[LOGIC GOES HERE]
return new MvcHtmlString(..some resulting Html...);
}
}
Now, I want to use IPhotoService and IGalleryService inside that Photo()
method. So far the only way I found how to inject these services, within AppHost.Configure():
PhotoExtension.PhotoService = container.Resolve<IPhotoService>();
PhotoExtension.GalleryService = container.Resolve<IGalleryService>();
This works, though I curious whether there is some better way to achieve this.
Both IPhotoService
and IGalleryService
are registered the standard way in AppHost.Configure()
.
Thanks, Antonin