14 internal class WinGetLinkBuilder : WinGetObjectBuilder<WinGetLink?>
16 private string _entryName =
string.Empty;
17 private string _rawContent =
string.Empty;
18 private bool _hasShortenedContent =
false;
19 private Uri? _url =
null;
24 public WinGetLinkBuilder()
33 public void AddEntryName(
string entryName)
35 _entryName = entryName;
45 public void AddRawContent(
string rawContent)
47 _hasShortenedContent = CheckShortenedValue(rawContent);
49 if (_hasShortenedContent)
52#if NETCOREAPP3_1_OR_GREATER
53 _rawContent = rawContent[..^1];
55 _rawContent = rawContent.Remove(rawContent.Length - 1);
60 _rawContent = rawContent;
63 SetUri(_rawContent, _hasShortenedContent);
79 return new WinGetLink(_entryName, _rawContent, _hasShortenedContent, _url);
83 public override void Clear()
85 _entryName =
string.Empty;
86 _rawContent =
string.Empty;
87 _hasShortenedContent =
false;
96 private void SetUri(
string rawContent,
bool hasShortenedContent)
98 if (!hasShortenedContent)
100 Uri.TryCreate(rawContent, UriKind.Absolute, out Uri? uri);
105 Uri.TryCreate(PathHelper.TrimLastPathPart(rawContent, PathHelper.PathType.URI), UriKind.Absolute, out Uri? shortenedUri);
Represents a winget link in the info set.