Created
January 7, 2014 16:45
-
-
Save feanz/3320c93ca3bbff63a61e to your computer and use it in GitHub Desktop.
Application Management
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ApplicationManagement : IApplicationManagement | |
{ | |
private readonly IEnumerable<IApplicationSetting> _settings; | |
public ApplicationManagement(IEnumerable<IApplicationSetting> settings) | |
{ | |
_settings = settings; | |
try | |
{ | |
_settings.ForEach(setting => setting.Initialise()); | |
} | |
catch (Exception exception) | |
{ | |
this.Log().Error("Error initialising application settings", exception); | |
throw; | |
} | |
} | |
public T Get<T>() where T : IApplicationSetting | |
{ | |
var setting = _settings.FirstOrDefault(s => s.GetType() == typeof(T)); | |
return setting != null ? (T)setting : default(T); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment