Skip to content

Commit d937aef

Browse files
committed
Moved the CheckShortenedValue(...) method from the ProcessOutputReader class to the WinGetObjectBuilder class (Builder base class)
1 parent fc85754 commit d937aef

8 files changed

Lines changed: 37 additions & 40 deletions

File tree

‎src/WGet.NET/Abstractions/WinGetObjectBuilder.cs‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,29 @@ internal abstract class WinGetObjectBuilder<T> where T : IWinGetObject?
2525
/// Cleares all added data from the builder.
2626
/// </summary>
2727
public abstract void Clear();
28+
29+
/// <summary>
30+
/// Checks if the given value is possibly shortened.
31+
/// </summary>
32+
/// <returns>
33+
/// <see langword="true"/> if the value is shortened or <see langword="false"/> if not.
34+
/// </returns>
35+
public static bool CheckShortenedValue(string value)
36+
{
37+
// Char 8230 is at the end of the shortened id if UTF-8 encoding is used.
38+
#if NETCOREAPP3_1_OR_GREATER
39+
if (value.EndsWith((char)8230))
40+
{
41+
return true;
42+
}
43+
#elif NETSTANDARD2_0
44+
if (value.EndsWith(((char)8230).ToString()))
45+
{
46+
return true;
47+
}
48+
#endif
49+
50+
return false;
51+
}
2852
}
2953
}

‎src/WGet.NET/Builder/AdminOptionBuilder.cs‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// https://github.com/basicx-StrgV/ //
44
//--------------------------------------------------//
55
using WGetNET.Abstractions;
6-
using WGetNET.HelperClasses;
76

87
namespace WGetNET.Builder
98
{
@@ -45,7 +44,7 @@ public void AddEntryName(string entryName)
4544
/// <param name="rawContent">The raw data of the info entry as a <see cref="System.String"/></param>
4645
public void AddRawContent(string rawContent)
4746
{
48-
_hasShortenedContent = ProcessOutputReader.CheckShortenedValue(rawContent);
47+
_hasShortenedContent = CheckShortenedValue(rawContent);
4948

5049
if (_hasShortenedContent)
5150
{

‎src/WGet.NET/Builder/DirectoryBuilder.cs‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using System;
66
using System.IO;
77
using WGetNET.Abstractions;
8-
using WGetNET.HelperClasses;
98

109
namespace WGetNET.Builder
1110
{
@@ -45,7 +44,7 @@ public void AddEntryName(string entryName)
4544
/// <param name="rawContent">The raw data of the info entry as a <see cref="System.String"/></param>
4645
public void AddRawContent(string rawContent)
4746
{
48-
_hasShortenedContent = ProcessOutputReader.CheckShortenedValue(rawContent);
47+
_hasShortenedContent = CheckShortenedValue(rawContent);
4948

5049
if (_hasShortenedContent)
5150
{

‎src/WGet.NET/Builder/LinkBuilder.cs‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
//--------------------------------------------------//
55
using System;
66
using WGetNET.Abstractions;
7-
using WGetNET.HelperClasses;
87

98
namespace WGetNET.Builder
109
{
@@ -44,7 +43,7 @@ public void AddEntryName(string entryName)
4443
/// <param name="rawContent">The raw data of the info entry as a <see cref="System.String"/></param>
4544
public void AddRawContent(string rawContent)
4645
{
47-
_hasShortenedContent = ProcessOutputReader.CheckShortenedValue(rawContent);
46+
_hasShortenedContent = CheckShortenedValue(rawContent);
4847

4948
if (_hasShortenedContent)
5049
{

‎src/WGet.NET/Builder/PackageBuilder.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public void AddName(string name)
5252
/// </param>
5353
public void AddId(string id)
5454
{
55-
_hasShortenedId = ProcessOutputReader.CheckShortenedValue(id);
55+
_hasShortenedId = CheckShortenedValue(id);
5656
if (_hasShortenedId)
5757
{
5858
// Remove the char at the end of the shortened id.

‎src/WGet.NET/Builder/PinnedPackageBuilder.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public void AddName(string name)
8585
/// </param>
8686
public void AddId(string id)
8787
{
88-
_hasShortenedId = ProcessOutputReader.CheckShortenedValue(id);
88+
_hasShortenedId = CheckShortenedValue(id);
8989
if (_hasShortenedId)
9090
{
9191
// Remove the char at the end of the shortened id.

‎src/WGet.NET/HelperClasses/ProcessOutputReader.cs‎

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -812,30 +812,6 @@ public static string ExportOutputToString(ProcessResult result)
812812
return string.Empty;
813813
}
814814
}
815-
816-
/// <summary>
817-
/// Checks if the given value is possibly shortened.
818-
/// </summary>
819-
/// <returns>
820-
/// <see langword="true"/> if the value is shortened or <see langword="false"/> if not.
821-
/// </returns>
822-
public static bool CheckShortenedValue(string value)
823-
{
824-
// Char 8230 is at the end of the shortened id if UTF-8 encoding is used.
825-
#if NETCOREAPP3_1_OR_GREATER
826-
if (value.EndsWith((char)8230))
827-
{
828-
return true;
829-
}
830-
#elif NETSTANDARD2_0
831-
if (value.EndsWith(((char)8230).ToString()))
832-
{
833-
return true;
834-
}
835-
#endif
836-
837-
return false;
838-
}
839815
//------------------------------------------------------------------------------------------------------------
840816

841817
//---Helper---------------------------------------------------------------------------------------------------

‎src/WGet.NET/XmlDocumentation/WGet.NET.xml‎

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)