Quantcast
Channel: West Wind Message Board Messages
Viewing all articles
Browse latest Browse all 10393

Re: Settings injection to service classes

$
0
0
Re: Settings injection to service classes
West Wind Application Configuration
Re: Settings injection to service classes
Mar. 22, 2013
03:16 pm
3QS0WQEI4Show this entire thread in new window
Gratar Image based on email address
From:Rick Strahl
To:Richard
Hi Richard,

I would think you could use any IOC container you like - you just have to make sure you create a constructor that passes in all the dependencies you might need.

I'm not sure how using IOC would really help much in the typical usage scenario because you're basically dealing with a static property somewhere (ie. App.Configuration) rather than something that's repeatedly instantiated so it's declared in one place typically (the static constructor).

+++ Rick ---



Hi Rick,

I've been looking for a solution to inject configuration settings into controllers and service classes, much like the one detailed in the LosTechies article:

http://lostechies.com/joshuaflanagan/2009/07/13/how-we-handle-application-configuration/

I think your solution may do the trick, but I wanted to know how suitable you think it is for use in a case like the following and using structuremap. In this example AvatarSettings inherits from Westwind.Utilities.Configuration.AppConfiguration

public AvatarService(AvatarSettings settings, IFileSystem fileSystem, IImageService imageService)
{
_settings = settings;
_fileSystem = fileSystem;
_imageService = imageService;
}

I'm just struggling a little to know how to set it up using structuremap and the initialize method, etc. Any help would be appreciated.

Thanks,

Richard.



Rick Strahl
West Wind Technologies


from Maui, Hawaii

Making waves on the Web


Viewing all articles
Browse latest Browse all 10393

Trending Articles