@@ -35,6 +35,20 @@ public string Arg
3535 }
3636 }
3737
38+ /// <summary>
39+ /// Gets the uri of the source.
40+ /// </summary>
41+ /// <remarks>
42+ /// <see langword="null"/> if <see cref="WGetNET.WinGetSource.Arg"/> can't be parsed to a <see cref="System.Uri"/> instance.
43+ /// </remarks>
44+ public Uri ? Uri
45+ {
46+ get
47+ {
48+ return _uri ;
49+ }
50+ }
51+
3852 /// <summary>
3953 /// Gets the type of the source.
4054 /// </summary>
@@ -87,6 +101,7 @@ public bool IsEmpty
87101
88102 private readonly string _name ;
89103 private readonly string _arg ;
104+ private readonly Uri ? _uri ;
90105 private readonly string _type ;
91106 private readonly string _data ;
92107 private readonly string _identifier ;
@@ -96,13 +111,15 @@ public bool IsEmpty
96111 /// </summary>
97112 /// <param name="name">The name of the source.</param>
98113 /// <param name="arg">The URL or UNC of the source.</param>
114+ /// <param name="uri">The URI of the source.</param>
99115 /// <param name="type">Type identifier of the source.</param>
100116 /// <param name="data">Data of the source source. This field is only used by some sources.</param>
101117 /// <param name="identifier">The identifier of the package</param>
102- internal WinGetSource ( string name , string arg , string type , string identifier , string ? data = null )
118+ internal WinGetSource ( string name , string arg , Uri ? uri , string type , string identifier , string ? data = null )
103119 {
104120 _name = name ;
105121 _arg = arg ;
122+ _uri = uri ;
106123 _type = type ;
107124 _identifier = identifier ;
108125
@@ -139,7 +156,9 @@ public WinGetSource Create(string name, string identifier, string arg, string ty
139156 ArgsHelper . ThrowIfStringIsNullOrWhiteSpace ( arg , "arg" ) ;
140157 ArgsHelper . ThrowIfStringIsNullOrWhiteSpace ( type , "type" ) ;
141158
142- return new WinGetSource ( name , arg , type , identifier ) ;
159+ Uri . TryCreate ( arg , UriKind . Absolute , out Uri ? uri ) ;
160+
161+ return new WinGetSource ( name , arg , uri , type , identifier ) ;
143162 }
144163
145164 /// <summary>
@@ -167,7 +186,9 @@ public WinGetSource Create(string name, string identifier, string arg, string ty
167186 ArgsHelper . ThrowIfStringIsNullOrWhiteSpace ( type , "type" ) ;
168187 ArgsHelper . ThrowIfStringIsNullOrWhiteSpace ( data , "data" ) ;
169188
170- return new WinGetSource ( name , arg , type , identifier , data ) ;
189+ Uri . TryCreate ( arg , UriKind . Absolute , out Uri ? uri ) ;
190+
191+ return new WinGetSource ( name , arg , uri , type , identifier , data ) ;
171192 }
172193
173194 /// <summary>
@@ -179,7 +200,9 @@ public WinGetSource Create(string name, string identifier, string arg, string ty
179200 /// </returns>
180201 internal static WinGetSource FromSourceModel ( SourceModel model )
181202 {
182- return new WinGetSource ( model . Name , model . Arg , model . Type , model . Identifier , model . Data ) ;
203+ Uri . TryCreate ( model . Arg , UriKind . Absolute , out Uri ? uri ) ;
204+
205+ return new WinGetSource ( model . Name , model . Arg , uri , model . Type , model . Identifier , model . Data ) ;
183206 }
184207
185208 /// <inheritdoc/>
@@ -188,6 +211,7 @@ public object Clone()
188211 return new WinGetSource (
189212 _name ,
190213 _arg ,
214+ _uri ,
191215 _type ,
192216 _identifier ,
193217 _data
0 commit comments