0
0
mirror of https://github.com/sp-tarkov/launcher.git synced 2025-02-13 09:50:43 -05:00
loyvsc 441fb128fe Implement NotifyPropertyChangedBase, optimization (!66)
- NotifyPropertyChangedBase created and implemented in classes that inherit INotifyPropertyChangedBase
- Some optimization fixes in models (one of this - `Where(predicate).Count() == 0` to `All(invertedPredicate)`

Co-authored-by: Valery Varaksa <varaksav62@gmail.com>
Reviewed-on: SPT/Launcher#66
Co-authored-by: loyvsc <loyvsc@noreply.dev.sp-tarkov.com>
Co-committed-by: loyvsc <loyvsc@noreply.dev.sp-tarkov.com>
2024-09-02 07:53:58 +00:00

54 lines
1.3 KiB
C#

using SPT.Launcher.Utilities;
namespace SPT.Launcher.Models.SPT
{
public class SPTVersion : NotifyPropertyChangedBase
{
public int Major;
public int Minor;
public int Build;
public bool HasTag => Tag != string.Empty;
private string _tag = string.Empty;
public string Tag
{
get => _tag;
set => SetProperty(ref _tag, value, () => RaisePropertyChanged(nameof(HasTag)));
}
public void ParseVersionInfo(string sptVersion)
{
if (sptVersion.Contains('-'))
{
string[] versionInfo = sptVersion.Split('-');
sptVersion = versionInfo[0];
Tag = versionInfo[1];
}
string[] splitVersion = sptVersion.Split('.');
if (splitVersion.Length >= 3)
{
int.TryParse(splitVersion[0], out Major);
int.TryParse(splitVersion[1], out Minor);
int.TryParse(splitVersion[2], out Build);
}
}
public SPTVersion() { }
public SPTVersion(string sptVersion)
{
ParseVersionInfo(sptVersion);
}
public override string ToString()
{
return HasTag ? $"{Major}.{Minor}.{Build}-{Tag}" : $"{Major}.{Minor}.{Build}";
}
}
}