6using System.Collections.Generic;
114 if (
string.IsNullOrWhiteSpace(_name) &&
115 string.IsNullOrWhiteSpace(_arg) &&
116 string.IsNullOrWhiteSpace(_type) &&
117 string.IsNullOrWhiteSpace(_data) &&
118 string.IsNullOrWhiteSpace(_identifier))
126 private readonly
string _name;
127 private readonly
string _arg;
128 private readonly
Uri? _uri;
129 private readonly
string _type;
130 private readonly
string _data;
131 private readonly
string _identifier;
132 private readonly
bool _explicit;
133 private readonly List<string> _trustLevel;
146 internal WinGetSource(
string name,
string arg,
Uri? uri,
string type,
string identifier,
bool explicitSource =
false, List<string>? trustLevel =
null,
string? data =
null)
152 _identifier = identifier;
153 _explicit = explicitSource;
155 if (trustLevel !=
null)
157 _trustLevel = trustLevel;
161 _trustLevel =
new List<string>();
170 _data =
string.Empty;
192 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(name,
"name");
193 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(identifier,
"identifier");
194 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(arg,
"arg");
195 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(type,
"type");
197 Uri.TryCreate(arg, UriKind.Absolute, out
Uri? uri);
199 return new WinGetSource(name, arg, uri, type, identifier);
219 public static WinGetSource Create(
string name,
string identifier,
string arg,
string type,
string data)
221 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(name,
"name");
222 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(identifier,
"identifier");
223 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(arg,
"url");
224 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(type,
"type");
225 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(data,
"data");
227 Uri.TryCreate(arg, UriKind.Absolute, out
Uri? uri);
229 return new WinGetSource(name, arg, uri, type, identifier, data: data);
239 internal static WinGetSource FromSourceModel(SourceModel model)
241 Uri.TryCreate(model.Arg, UriKind.Absolute, out
Uri? uri);
243 return new WinGetSource(model.Name, model.Arg, uri, model.Type, model.Identifier, model.Explicit, model.TrustLevel, model.Data);
Represents a winget source.
string Name
Gets the name of the source.
bool IsEmpty
Gets if the object is empty.
string Type
Gets the type of the source.
List< string > TrustLevel
Gets the trust level of the source.
bool Explicit
Gets whether the source was explicitly added.
Uri? Uri
Gets the uri of the source.
static WinGetSource Create(string name, string identifier, string arg, string type, string data)
Creates a new instance of the WGetNET.WinGetSource class and returns it.
string Identifier
Gets the identifier of the source.
static WinGetSource Create(string name, string identifier, string arg, string type)
Creates a new instance of the WGetNET.WinGetSource class and returns it.
override string ToString()
string Arg
Gets the URL/UNC of the source.
string Data
Gets the data of the source.
Interface for all winget related objects.