In a personal application i work on at the moment i have global application settings which should affect how certain objects behave, in terms of architecture i figured it would create an unnecessary dependency to directly reference them, e.g.
public void Update()
{
if (App.Settings.AutoCacheImages) CacheImages();
...
]
So i would prefer to create an interface like this:
public interface IFeedSettings
{
bool AutoCacheImages { get; set; }
...
}
And make sure that my object gets a reference during construction:
private IFeedSettings _settings;
public Feed(IFeedSettings settings)
{
_settings = settings;
}
Now the problem is that Xml-Serialization requires a parameterless constructor, so what would the best way to approach this so that after deserialization all instances of Feed
will have a reference to my global settings?
(I have a hierarchical folder/file-like data-structure using the composite pattern)