Skip to content

Commit 6292f7c

Browse files
committed
Renamed WinGetAdminOption to WinGetAdminSetting; Changed the builder name and xml docs to fit the new name
1 parent dc8f13c commit 6292f7c

8 files changed

Lines changed: 116 additions & 93 deletions

File tree

src/WGet.NET/Builder/AdminOptionBuilder.cs renamed to src/WGet.NET/Builder/AdminSettingBuilder.cs

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
namespace WGetNET.Builder
88
{
99
/// <summary>
10-
/// Builder to create a new <see cref="WGetNET.WinGetAdminOption"/> instance.
10+
/// Builder to create a new <see cref="WGetNET.WinGetAdminSetting"/> instance.
1111
/// </summary>
12-
internal class AdminOptionBuilder : WinGetObjectBuilder<WinGetAdminOption?>
12+
internal class AdminSettingBuilder : WinGetObjectBuilder<WinGetAdminSetting?>
1313
{
1414
private string _entryName = string.Empty;
1515
private string _rawContent = string.Empty;
@@ -19,9 +19,9 @@ internal class AdminOptionBuilder : WinGetObjectBuilder<WinGetAdminOption?>
1919
private bool _parsed = false;
2020

2121
/// <summary>
22-
/// Initializes a new instance of the <see cref="WGetNET.Builder.AdminOptionBuilder"/> class.
22+
/// Initializes a new instance of the <see cref="WGetNET.Builder.AdminSettingBuilder"/> class.
2323
/// </summary>
24-
public AdminOptionBuilder()
24+
public AdminSettingBuilder()
2525
{
2626
// Provide empty constructor
2727
}
@@ -65,19 +65,19 @@ public void AddRawContent(string rawContent)
6565
}
6666

6767
/// <summary>
68-
/// Returns a <see cref="WGetNET.WinGetAdminOption"/> instance from data provided to the builder.
68+
/// Returns a <see cref="WGetNET.WinGetAdminSetting"/> instance from data provided to the builder.
6969
/// </summary>
7070
/// <returns>
71-
/// The created <see cref="WGetNET.WinGetAdminOption"/> instance, or <see langword="null"/> if the provided data failed to be parsed.
71+
/// The created <see cref="WGetNET.WinGetAdminSetting"/> instance, or <see langword="null"/> if the provided data failed to be parsed.
7272
/// </returns>
73-
public override WinGetAdminOption? GetInstance()
73+
public override WinGetAdminSetting? GetInstance()
7474
{
7575
if (!_parsed)
7676
{
7777
return null;
7878
}
7979

80-
return new WinGetAdminOption(_entryName, _rawContent, _hasShortenedContent, _isEnabled);
80+
return new WinGetAdminSetting(_entryName, _rawContent, _hasShortenedContent, _isEnabled);
8181
}
8282

8383
/// <inheritdoc/>
@@ -89,6 +89,18 @@ public override void Clear()
8989
_isEnabled = false;
9090
}
9191

92+
/// <summary>
93+
/// Parses the raw content to a <see cref="System.Boolean"/> value.
94+
/// </summary>
95+
/// <param name="rawContent">
96+
/// A <see cref="System.String"/> containing the raw content.
97+
/// </param>
98+
/// <param name="hasShortenedContent">
99+
/// Indicates if the content is shortened or not.
100+
/// </param>
101+
/// <returns>
102+
/// The paresed <see cref="System.Boolean"/> value or <see langword="null"/> if parsing failed.
103+
/// </returns>
92104
private bool? ParseToBool(string rawContent, bool hasShortenedContent)
93105
{
94106
bool isEnabled = false;

src/WGet.NET/Builder/InfoSetBuilder.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ internal class InfoSetBuilder : WinGetObjectBuilder<WinGetInfo>
1818
private Version? _version = null;
1919
private List<WinGetDirectory> _directories = new();
2020
private List<WinGetLink> _links = new();
21-
private List<WinGetAdminOption> _adminSettings = new();
21+
private List<WinGetAdminSetting> _adminSettings = new();
2222

2323
/// <summary>
2424
/// Initializes a new instance of the <see cref="WGetNET.Builder.InfoSetBuilder"/> class.
@@ -103,23 +103,23 @@ public void AddLink(WinGetLink? link)
103103
}
104104

105105
/// <summary>
106-
/// Adds a <see cref="System.Collections.Generic.List{T}"/> of <see cref="WinGetAdminOption"/> objects.
106+
/// Adds a <see cref="System.Collections.Generic.List{T}"/> of <see cref="WinGetAdminSetting"/> objects.
107107
/// </summary>
108108
/// <param name="adminOptions">
109-
/// The <see cref="System.Collections.Generic.List{T}"/> of <see cref="WinGetAdminOption"/> objects.
109+
/// The <see cref="System.Collections.Generic.List{T}"/> of <see cref="WinGetAdminSetting"/> objects.
110110
/// </param>
111-
public void AddAdminOptions(List<WinGetAdminOption> adminOptions)
111+
public void AddAdminOptions(List<WinGetAdminSetting> adminOptions)
112112
{
113113
_adminSettings.AddRange(adminOptions);
114114
}
115115

116116
/// <summary>
117-
/// Adds a <see cref="WinGetAdminOption"/> object.
117+
/// Adds a <see cref="WinGetAdminSetting"/> object.
118118
/// </summary>
119119
/// <param name="adminOption">
120-
/// The <see cref="WinGetAdminOption"/> object.
120+
/// The <see cref="WinGetAdminSetting"/> object.
121121
/// </param>
122-
public void AddAdminOption(WinGetAdminOption? adminOption)
122+
public void AddAdminOption(WinGetAdminSetting? adminOption)
123123
{
124124
if (adminOption != null)
125125
{
@@ -150,7 +150,7 @@ public override void Clear()
150150
_version = null;
151151
_directories = new List<WinGetDirectory>();
152152
_links = new List<WinGetLink>();
153-
_adminSettings = new List<WinGetAdminOption>();
153+
_adminSettings = new List<WinGetAdminSetting>();
154154
}
155155
}
156156
}

src/WGet.NET/Components/Internal/ProcessOutputReader.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -757,13 +757,13 @@ private List<WinGetLink> ReadLinks(string[] output)
757757
/// </remarks>
758758
/// <param name="output">The <see langword="array"/> containing the winget output lines.</param>
759759
/// <returns>
760-
/// A <see cref="System.Collections.Generic.List{T}"/> of <see cref="WGetNET.WinGetAdminOption"/> objects.
760+
/// A <see cref="System.Collections.Generic.List{T}"/> of <see cref="WGetNET.WinGetAdminSetting"/> objects.
761761
/// </returns>
762-
private List<WinGetAdminOption> ReadAdminSettings(string[] output)
762+
private List<WinGetAdminSetting> ReadAdminSettings(string[] output)
763763
{
764-
List<WinGetAdminOption> adminSetting = new();
764+
List<WinGetAdminSetting> adminSetting = new();
765765

766-
AdminOptionBuilder adminOptionBuilder = new();
766+
AdminSettingBuilder adminOptionBuilder = new();
767767

768768
for (int i = 0; i < output.Length; i++)
769769
{
@@ -781,7 +781,7 @@ private List<WinGetAdminOption> ReadAdminSettings(string[] output)
781781
adminOptionBuilder.AddEntryName(settingsEntry[0].Trim());
782782
adminOptionBuilder.AddRawContent(settingsEntry[1].Trim());
783783

784-
WinGetAdminOption? adminOption = adminOptionBuilder.GetInstance();
784+
WinGetAdminSetting? adminOption = adminOptionBuilder.GetInstance();
785785
if (adminOption != null)
786786
{
787787
adminSetting.Add(adminOption);

src/WGet.NET/Components/WinGet.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ public bool EnableAdminSetting(string settingName)
300300
/// Enables the provided admin setting (Needs administrator rights).
301301
/// </summary>
302302
/// <param name="setting">
303-
/// The <see cref="WGetNET.WinGetAdminOption"/> to enable.
303+
/// The <see cref="WGetNET.WinGetAdminSetting"/> to enable.
304304
/// </param>
305305
/// <returns>
306306
/// <see langword="true"/> if the action was succesfull and <see langword="false"/> if it failed.
@@ -317,7 +317,7 @@ public bool EnableAdminSetting(string settingName)
317317
/// <exception cref="System.Security.SecurityException">
318318
/// The current user is missing administrator privileges for this call.
319319
/// </exception>
320-
public bool EnableAdminSetting(WinGetAdminOption setting)
320+
public bool EnableAdminSetting(WinGetAdminSetting setting)
321321
{
322322
ArgsHelper.ThrowIfObjectIsNull(setting, "setting");
323323

@@ -361,7 +361,7 @@ public async Task<bool> EnableAdminSettingAsync(string settingName)
361361
/// Asynchronously enables the provided admin setting (Needs administrator rights).
362362
/// </summary>
363363
/// <param name="setting">
364-
/// The <see cref="WGetNET.WinGetAdminOption"/> to enable.
364+
/// The <see cref="WGetNET.WinGetAdminSetting"/> to enable.
365365
/// </param>
366366
/// <returns>
367367
/// A <see cref="System.Threading.Tasks.Task"/>, containing the result.
@@ -379,7 +379,7 @@ public async Task<bool> EnableAdminSettingAsync(string settingName)
379379
/// <exception cref="System.Security.SecurityException">
380380
/// The current user is missing administrator privileges for this call.
381381
/// </exception>
382-
public async Task<bool> EnableAdminSettingAsynv(WinGetAdminOption setting)
382+
public async Task<bool> EnableAdminSettingAsynv(WinGetAdminSetting setting)
383383
{
384384
ArgsHelper.ThrowIfObjectIsNull(setting, "setting");
385385

@@ -422,7 +422,7 @@ public bool DisableAdminSetting(string settingName)
422422
/// Disables the provided admin setting (Needs administrator rights).
423423
/// </summary>
424424
/// <param name="setting">
425-
/// The <see cref="WGetNET.WinGetAdminOption"/> to disable.
425+
/// The <see cref="WGetNET.WinGetAdminSetting"/> to disable.
426426
/// </param>
427427
/// <returns>
428428
/// <see langword="true"/> if the action was succesfull and <see langword="false"/> if it failed.
@@ -439,7 +439,7 @@ public bool DisableAdminSetting(string settingName)
439439
/// <exception cref="System.Security.SecurityException">
440440
/// The current user is missing administrator privileges for this call.
441441
/// </exception>
442-
public bool DisableAdminSetting(WinGetAdminOption setting)
442+
public bool DisableAdminSetting(WinGetAdminSetting setting)
443443
{
444444
ArgsHelper.ThrowIfObjectIsNull(setting, "setting");
445445

@@ -483,7 +483,7 @@ public async Task<bool> DisableAdminSettingAsync(string settingName)
483483
/// Asynchronously disables the provided admin setting (Needs administrator rights).
484484
/// </summary>
485485
/// <param name="setting">
486-
/// The <see cref="WGetNET.WinGetAdminOption"/> to disable.
486+
/// The <see cref="WGetNET.WinGetAdminSetting"/> to disable.
487487
/// </param>
488488
/// <returns>
489489
/// A <see cref="System.Threading.Tasks.Task"/>, containing the result.
@@ -501,7 +501,7 @@ public async Task<bool> DisableAdminSettingAsync(string settingName)
501501
/// <exception cref="System.Security.SecurityException">
502502
/// The current user is missing administrator privileges for this call.
503503
/// </exception>
504-
public async Task<bool> DisableAdminSettingAsync(WinGetAdminOption setting)
504+
public async Task<bool> DisableAdminSettingAsync(WinGetAdminSetting setting)
505505
{
506506
ArgsHelper.ThrowIfObjectIsNull(setting, "setting");
507507

src/WGet.NET/Components/WinGetSourceManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1037,7 +1037,7 @@ public string SourcesToJson(IEnumerable<WinGetSource> sources)
10371037
ArgsHelper.ThrowIfObjectIsNull(sources, "sources");
10381038

10391039
// Create source models for json parsing
1040-
List<SourceModel> models = new List<SourceModel>();
1040+
List<SourceModel> models = new();
10411041
foreach (WinGetSource source in sources)
10421042
{
10431043
models.Add(SourceModel.FromWinGetSource(source));
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace WGetNET
99
/// <summary>
1010
/// Represents a winget admin settings entry.
1111
/// </summary>
12-
public sealed class WinGetAdminOption : WinGetInfoEntry<WinGetAdminOption>
12+
public sealed class WinGetAdminSetting : WinGetInfoEntry<WinGetAdminSetting>
1313
{
1414
/// <summary>
1515
/// Gets if the admin option is enabled.
@@ -25,19 +25,19 @@ public bool IsEnabled
2525
private readonly bool _isEnabled;
2626

2727
/// <summary>
28-
/// Initializes a new instance of the <see cref="WGetNET.WinGetAdminOption"/> class.
28+
/// Initializes a new instance of the <see cref="WGetNET.WinGetAdminSetting"/> class.
2929
/// </summary>
3030
/// <param name="entryName">The name of the settings entry.</param>
3131
/// <param name="rawContent">The content of the settings entry.</param>
3232
/// <param name="hasShortenedContent">Sets if the content is shortened or not.</param>
3333
/// <param name="isEnabled">Idicator for the setting state.</param>
34-
internal WinGetAdminOption(string entryName, string rawContent, bool hasShortenedContent, bool isEnabled) : base(entryName, rawContent, hasShortenedContent)
34+
internal WinGetAdminSetting(string entryName, string rawContent, bool hasShortenedContent, bool isEnabled) : base(entryName, rawContent, hasShortenedContent)
3535
{
3636
_isEnabled = isEnabled;
3737
}
3838

3939
/// <inheritdoc/>
40-
public override bool Equals(WinGetAdminOption? other)
40+
public override bool Equals(WinGetAdminSetting? other)
4141
{
4242
if (other == null)
4343
{
@@ -62,7 +62,7 @@ public override bool Equals(WinGetAdminOption? other)
6262
/// <inheritdoc/>
6363
public override object Clone()
6464
{
65-
return new WinGetAdminOption(
65+
return new WinGetAdminSetting(
6666
_entryName,
6767
_rawContent,
6868
_hasShortenedContent,

src/WGet.NET/Data/WinGetInfo.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public ReadOnlyCollection<WinGetLink> Links
6060
/// <summary>
6161
/// Gets a collection of the winget admin settings.
6262
/// </summary>
63-
public ReadOnlyCollection<WinGetAdminOption> AdminSettings
63+
public ReadOnlyCollection<WinGetAdminSetting> AdminSettings
6464
{
6565
get
6666
{
@@ -93,15 +93,15 @@ internal static WinGetInfo Empty
9393
{
9494
get
9595
{
96-
return new WinGetInfo("", new Version(0, 0), new List<WinGetDirectory>(), new List<WinGetLink>(), new List<WinGetAdminOption>());
96+
return new WinGetInfo("", new Version(0, 0), new List<WinGetDirectory>(), new List<WinGetLink>(), new List<WinGetAdminSetting>());
9797
}
9898
}
9999

100100
private readonly string _versionString;
101101
private readonly Version _version;
102102
private readonly ReadOnlyCollection<WinGetDirectory> _directories;
103103
private readonly ReadOnlyCollection<WinGetLink> _links;
104-
private readonly ReadOnlyCollection<WinGetAdminOption> _adminSettings;
104+
private readonly ReadOnlyCollection<WinGetAdminSetting> _adminSettings;
105105

106106
/// <summary>
107107
/// Initializes a new instance of the <see cref="WGetNET.WinGetInfo"/> class.
@@ -117,13 +117,13 @@ internal static WinGetInfo Empty
117117
/// <param name="adminSettings">
118118
/// <see cref="System.Collections.Generic.List{T}"/> of info entries containing the WinGet admin setting states.
119119
/// </param>
120-
internal WinGetInfo(string versionString, Version version, List<WinGetDirectory> directories, List<WinGetLink> links, List<WinGetAdminOption> adminSettings)
120+
internal WinGetInfo(string versionString, Version version, List<WinGetDirectory> directories, List<WinGetLink> links, List<WinGetAdminSetting> adminSettings)
121121
{
122122
_versionString = versionString;
123123
_version = version;
124124
_directories = new ReadOnlyCollection<WinGetDirectory>(directories);
125125
_links = new ReadOnlyCollection<WinGetLink>(links);
126-
_adminSettings = new ReadOnlyCollection<WinGetAdminOption>(adminSettings);
126+
_adminSettings = new ReadOnlyCollection<WinGetAdminSetting>(adminSettings);
127127
}
128128
}
129129
}

0 commit comments

Comments
 (0)