// Copyright (C) Stichting Deltares 2024. All rights reserved. // // This file is part of the application DAM - UI. // // DAM - UI is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . // // All names, logos, and references to "Deltares" are registered trademarks of // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. using System.Reflection; using System.Xml.Serialization; using Deltares.Standard.Attributes; namespace Deltares.Dam.Data.IO; [XmlNoKey] public class VersionInfo { /// The current file version /// FileVersion 0 is for versions 18.1.3 and earlier. /// FileVersion 1 is for version 19.1.1. /// FileVersion 2 is for version 20.1.1. and up /// FileVersion 2 is for version 25.1.1. and up public const int CurrentFileVersion = 3; //#Bka: added this field to be able to debug the de-serialization of the file version info. // I noticed that when the designresults are added to the serialization/de-serialization, // this version info is not read any more, indicating a problem with the serialization/ // de-serialization of the design results. Set a breakpoint at the setter of the property // and a breakpoint at "if (damProjectData != null)" in method OpenXMLProject in DamProject. // Executing should always hit the line here first as fileversion should be read from the xml // If it stops at the DamProject breakpoint first, you know serialization/de-serialization // of the designresults is wrong. /// /// Gets or sets the file version. /// /// /// The file version. /// public int FileVersion { get; set; } // Default is 0 and indicates the situation that FileVersion was not introduced yet /// Gets or sets the assembly name with which the input file is being created. /// The program version. /// public string AssemblyName { get; set; } /// Gets or sets the assembly version with which the input file is being created. /// The program version. /// public string AssemblyVersion { get; set; } /// Gets or sets the version as read. /// The file version as read. /// /// [XmlIgnore] public int FileVersionAsRead { get; set; } /// Gets or sets the assembly name with which the input file has been created. /// The assembly version as read. [XmlIgnore] public string AssemblyNameAsRead { get; set; } /// Gets or sets the assembly version with which the input file has been created. /// The assembly version as read. [XmlIgnore] public string AssemblyVersionAsRead { get; set; } /// Initializes the version information to the current program version. public void InitVersionInfo() { FileVersion = CurrentFileVersion; var hostAssembly = Assembly.GetEntryAssembly(); if (hostAssembly == null) { hostAssembly = Assembly.GetExecutingAssembly(); } AssemblyName = hostAssembly.GetName().Name; AssemblyVersion = hostAssembly.GetName().Version.ToString(); } /// After the read the current version info should be transferred to the ..AsRead fields /// and after that current version info can be initialized. public void InitVersionInfoAfterRead() { FileVersionAsRead = FileVersion; AssemblyNameAsRead = AssemblyName; AssemblyVersionAsRead = AssemblyVersion; InitVersionInfo(); } }