using System.Collections.Generic; namespace Wayne.Lib { /// /// Provides a version for the application. /// public class VersionProvider : IVersionProvider { /// /// Constructor /// public VersionProvider() { ReleaseComponentVersion = new VersionNumber("0.0.0"); } /// /// Main component version for the running process. Should be set in code as early as possible in the program. /// public VersionNumber ReleaseComponentVersion { get; set; } private readonly Dictionary internalDictionary = new Dictionary(); private readonly object internalDictionaryLock = new object(); /// /// Gets the version for a sub component. /// /// /// /// public VersionNumber GetVersion(TVersionIdentifier versionIdentifier) { VersionNumber result; lock (internalDictionary) { if (internalDictionary.TryGetValue(versionIdentifier, out result)) return result; return new VersionNumber("0.0.0"); } } /// /// Sets the version for a sub component /// /// /// /// public void SetVersion(TVersionIdentifier versionIdentifier, VersionNumber versionNumber) { lock (internalDictionaryLock) { internalDictionary[versionIdentifier] = versionNumber; } } } }