Skip to content

Commit 1a19354

Browse files
committed
InstallationOptions will also have the new OverrideNextLevelPrefs
1 parent 90b5e2a commit 1a19354

3 files changed

Lines changed: 18 additions & 23 deletions

File tree

src/UniGetUI.PackageEngine.PackageManagerClasses/Packages/Classes/InstallationOptions.cs

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ public class InstallationOptions : IInstallationOptions
3030
public bool RemoveDataOnUninstall { get; set; }
3131
public bool PreRelease { get; set; }
3232
public string CustomInstallLocation { get; set; } = "";
33+
public bool OverridesNextLevelOpts { get; set; }
3334

3435
public IPackage Package { get; }
35-
3636
private readonly string __save_filename;
3737

3838
private InstallationOptions(IPackage package)
@@ -122,24 +122,21 @@ public void FromSerializable(SerializableInstallationOptions options)
122122
Version = options.Version;
123123
SkipMinorUpdates = options.SkipMinorUpdates;
124124
PreRelease = options.PreRelease;
125+
OverridesNextLevelOpts = options.OverridesNextLevelOpts;
125126

126-
if (options.Architecture != "" && CommonTranslations.InvertedArchNames.TryGetValue(options.Architecture, out var name))
127+
Architecture = null;
128+
if (options.Architecture.Any() &&
129+
CommonTranslations.InvertedArchNames.TryGetValue(options.Architecture, out var name))
127130
{
128131
Architecture = name;
129132
}
130-
else
131-
{
132-
Architecture = null;
133-
}
134133

135-
if (options.InstallationScope != "" && CommonTranslations.InvertedScopeNames_NonLang.TryGetValue(options.InstallationScope, out var value))
134+
InstallationScope = null;
135+
if (options.InstallationScope.Any() &&
136+
CommonTranslations.InvertedScopeNames_NonLang.TryGetValue(options.InstallationScope, out var value))
136137
{
137138
InstallationScope = value;
138139
}
139-
else
140-
{
141-
InstallationScope = null;
142-
}
143140

144141
CustomParameters = options.CustomParameters;
145142
}
@@ -157,17 +154,15 @@ public SerializableInstallationOptions AsSerializable()
157154
CustomInstallLocation = CustomInstallLocation,
158155
PreRelease = PreRelease,
159156
Version = Version,
160-
SkipMinorUpdates = SkipMinorUpdates
157+
SkipMinorUpdates = SkipMinorUpdates,
158+
OverridesNextLevelOpts = OverridesNextLevelOpts
161159
};
160+
162161
if (Architecture is not null)
163-
{
164162
options.Architecture = CommonTranslations.ArchNames[Architecture.Value];
165-
}
166163

167164
if (InstallationScope is not null)
168-
{
169165
options.InstallationScope = CommonTranslations.ScopeNames_NonLang[InstallationScope.Value];
170-
}
171166

172167
options.CustomParameters = CustomParameters;
173168
return options;

src/UniGetUI.PackageEngine.Serializable.Tests/TestSerializableInstallationOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public void FromJson(string JSON, bool hash, bool inter, string installLoc, stri
8181

8282
var list = new List<string>() { arg1, arg2, arg3 }.Where(x => x.Any());
8383

84-
Assert.Equal(mod, o2.OverrideNextLevelPrefs);
84+
Assert.Equal(mod, o2.OverridesNextLevelOpts);
8585
Assert.Equal(mod, o2.DiffersFromDefault());
8686
Assert.Equal(hash, o2.SkipHashCheck);
8787
Assert.Equal(arch, o2.Architecture);

src/UniGetUI.PackageEngine.Serializable/SerializableInstallationOptions.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class SerializableInstallationOptions: SerializableComponent<Serializable
1515
public string CustomInstallLocation { get; set; } = "";
1616
public string Version { get; set; } = "";
1717
public bool SkipMinorUpdates { get; set; }
18-
public bool OverrideNextLevelPrefs { get; set; }
18+
public bool OverridesNextLevelOpts { get; set; }
1919

2020
public override SerializableInstallationOptions Copy()
2121
{
@@ -31,7 +31,7 @@ public override SerializableInstallationOptions Copy()
3131
RunAsAdministrator = RunAsAdministrator,
3232
Version = Version,
3333
SkipMinorUpdates = SkipMinorUpdates,
34-
OverrideNextLevelPrefs = OverrideNextLevelPrefs,
34+
OverridesNextLevelOpts = OverridesNextLevelOpts,
3535
};
3636
}
3737

@@ -52,11 +52,11 @@ public override void LoadFromJson(JsonNode data)
5252
this.Version = data[nameof(Version)]?.GetVal<string>() ?? "";
5353
this.SkipMinorUpdates = data[nameof(SkipMinorUpdates)]?.GetVal<bool>() ?? false;
5454

55-
// if OverrideNextLevelPrefs is not found on the JSON, set it to true or false depending
55+
// if OverridesNextLevelOpts is not found on the JSON, set it to true or false depending
5656
// on whether the current settings instances are different from the default values.
5757
// This entry shall be checked the last one, to ensure all other properties are set
58-
this.OverrideNextLevelPrefs =
59-
data[nameof(OverrideNextLevelPrefs)]?.GetValue<bool>() ?? DiffersFromDefault();
58+
this.OverridesNextLevelOpts =
59+
data[nameof(OverridesNextLevelOpts)]?.GetValue<bool>() ?? DiffersFromDefault();
6060
}
6161

6262
public bool DiffersFromDefault()
@@ -71,7 +71,7 @@ SkipMinorUpdates is not false ||
7171
CustomParameters.Where(x => x != "").Any() ||
7272
CustomInstallLocation.Any() ||
7373
Version.Any();
74-
// OverrideNextLevelPrefs does not need to be checked here, since
74+
// OverridesNextLevelOpts does not need to be checked here, since
7575
// this method is invoked before this property has been set
7676
}
7777

0 commit comments

Comments
 (0)