added validation to the appconfig (remove code duplication)
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
using System;
|
||||
|
||||
namespace Tv7Playlist
|
||||
{
|
||||
public class AppConfig
|
||||
@@ -5,12 +7,36 @@ namespace Tv7Playlist
|
||||
public enum SourceTypeEnum
|
||||
{
|
||||
M3U,
|
||||
XSPF
|
||||
Xspf
|
||||
}
|
||||
|
||||
public string TV7Url { get; set; }
|
||||
|
||||
private string _tv7Url;
|
||||
private string _udpxyUrl;
|
||||
|
||||
public string TV7Url
|
||||
{
|
||||
get => _tv7Url;
|
||||
set
|
||||
{
|
||||
if (!Uri.IsWellFormedUriString(value, UriKind.Absolute))
|
||||
throw new ApplicationException($"The TV7Url is set to {value}. This is not a well formed uri!");
|
||||
_tv7Url = value;
|
||||
}
|
||||
}
|
||||
|
||||
public SourceTypeEnum SourceType { get; set; }
|
||||
public string UdpxyUrl { get; set; }
|
||||
|
||||
public string UdpxyUrl
|
||||
{
|
||||
get => _udpxyUrl;
|
||||
set
|
||||
{
|
||||
if (!Uri.IsWellFormedUriString(value, UriKind.Absolute))
|
||||
throw new ApplicationException($"The proxyUrl is set to {value}. This is not a well formed uri!");
|
||||
_udpxyUrl = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string DownloadFileName { get; set; }
|
||||
}
|
||||
}
|
@@ -79,7 +79,7 @@ namespace Tv7Playlist
|
||||
case AppConfig.SourceTypeEnum.M3U:
|
||||
services.AddTransient<IPlaylistParser, M3UParser>();
|
||||
break;
|
||||
case AppConfig.SourceTypeEnum.XSPF:
|
||||
case AppConfig.SourceTypeEnum.Xspf:
|
||||
services.AddTransient<IPlaylistParser, XspfParser>();
|
||||
break;
|
||||
default:
|
||||
|
Reference in New Issue
Block a user