added validation to the appconfig (remove code duplication)
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
namespace Tv7Playlist
|
namespace Tv7Playlist
|
||||||
{
|
{
|
||||||
public class AppConfig
|
public class AppConfig
|
||||||
@@ -5,12 +7,36 @@ namespace Tv7Playlist
|
|||||||
public enum SourceTypeEnum
|
public enum SourceTypeEnum
|
||||||
{
|
{
|
||||||
M3U,
|
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 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; }
|
public string DownloadFileName { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -79,7 +79,7 @@ namespace Tv7Playlist
|
|||||||
case AppConfig.SourceTypeEnum.M3U:
|
case AppConfig.SourceTypeEnum.M3U:
|
||||||
services.AddTransient<IPlaylistParser, M3UParser>();
|
services.AddTransient<IPlaylistParser, M3UParser>();
|
||||||
break;
|
break;
|
||||||
case AppConfig.SourceTypeEnum.XSPF:
|
case AppConfig.SourceTypeEnum.Xspf:
|
||||||
services.AddTransient<IPlaylistParser, XspfParser>();
|
services.AddTransient<IPlaylistParser, XspfParser>();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
Reference in New Issue
Block a user