AssemblyExtendedVersion.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Jellyfin.Versioning/AssemblyExtendedVersion.cs
  2. // Part of the Jellyfin project (https://jellyfin.media)
  3. //
  4. // All copyright belongs to the Jellyfin contributors; a full list can
  5. // be found in the file CONTRIBUTORS.md
  6. //
  7. // This program is free software: you can redistribute it and/or modify
  8. // it under the terms of the GNU General Public License as published by
  9. // the Free Software Foundation, either version 2 of the License, or
  10. // (at your option) any later version.
  11. //
  12. // This program is distributed in the hope that it will be useful,
  13. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. // GNU General Public License for more details.
  16. //
  17. // You should have received a copy of the GNU General Public License
  18. // along with this program. If not, see <https://www.gnu.org/licenses/>.
  19. using System;
  20. using System.Collections.Generic;
  21. using System.IO;
  22. using System.Reflection;
  23. namespace Jellyfin.Versioning
  24. {
  25. [AttributeUsage(AttributeTargets.Assembly)]
  26. public sealed class AssemblyExtendedVersion : Attribute
  27. {
  28. public ExtendedVersion ExtendedVersion { get; }
  29. public AssemblyExtendedVersion(ExtendedVersion ExtendedVersion)
  30. {
  31. this.ExtendedVersion = ExtendedVersion;
  32. }
  33. public AssemblyExtendedVersion(string apiVersion, bool readResource = true)
  34. {
  35. var assembly = Assembly.GetExecutingAssembly();
  36. var resourceName = "Jellyfin.Versioning.jellyfin_version.ini";
  37. using (var stream = assembly.GetManifestResourceStream(resourceName))
  38. {
  39. ExtendedVersion = new ExtendedVersion(new Version(apiVersion), stream);
  40. }
  41. }
  42. }
  43. }