Click or drag to resize
ISharedConfiguration Interface
Exposes the current configuration.

Namespace: VirtualRadar.Interface.Settings
Assembly: VirtualRadar.Interface (in VirtualRadar.Interface.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
public interface ISharedConfiguration : ISingleton<ISharedConfiguration>

The ISharedConfiguration type exposes the following members.

Properties
  NameDescription
Public propertySingleton
Gets the single instance of the class that should be used throughout the application.
(Inherited from ISingletonT.)
Top
Methods
  NameDescription
Public methodGet
Gets the current configuration.
Top
Events
  NameDescription
Public eventConfigurationChanged
Raised when the configuration returned by Get has changed.
Top
Remarks

For a long time if you wanted to get the current configuration you had to hook the ConfigurationChanged event on IConfigurationStorage and call Load when the configuration changed. This was fine, it worked, but there were two problems with it:

  1. Hooking the event was awkward for objects with a limited lifetime. It meant that they had to be disposable so that there was a point where the unhook could take place.
  2. When the configuration changes dozens of objects jump in and call Load. Load reads the configuration off disk, so you had dozens of redundant reads.

This class aims to get around these problems. When a configuration value is required a class can call Get. The configuration returned is guaranteed to be current and consistent - if the configuration is changed after Get is called it won't affect the configuration returned by the method.

The drawback is that the configuration is shared. Any changes that you make to the configuration will affect everything using this object. To protect against bugs introduced by this kind of behaviour the object listens for changes to the configuration and throws an exception when they're detected.

See Also