Use ArgumentException.ThrowIfNullOrEmpty

This commit is contained in:
Bond_009
2022-10-13 19:08:00 +02:00
parent 93fd462b58
commit b366dc2e6e
58 changed files with 130 additions and 549 deletions

View File

@@ -1755,10 +1755,7 @@ namespace MediaBrowser.Controller.Entities
/// <exception cref="ArgumentNullException">Throws if name is null.</exception>
public void AddStudio(string name)
{
if (string.IsNullOrEmpty(name))
{
throw new ArgumentNullException(nameof(name));
}
ArgumentException.ThrowIfNullOrEmpty(name);
var current = Studios;
@@ -1791,10 +1788,7 @@ namespace MediaBrowser.Controller.Entities
/// <exception cref="ArgumentNullException">Throwns if name is null.</exception>
public void AddGenre(string name)
{
if (string.IsNullOrEmpty(name))
{
throw new ArgumentNullException(nameof(name));
}
ArgumentException.ThrowIfNullOrEmpty(name);
var genres = Genres;
if (!genres.Contains(name, StringComparison.OrdinalIgnoreCase))

View File

@@ -17,12 +17,7 @@ namespace MediaBrowser.Controller.Entities
/// <param name="url">Trailer URL.</param>
public static void AddTrailerUrl(this BaseItem item, string url)
{
ArgumentNullException.ThrowIfNull(url);
if (url.Length == 0)
{
throw new ArgumentException("String can't be empty", nameof(url));
}
ArgumentException.ThrowIfNullOrEmpty(url);
var current = item.RemoteTrailers.FirstOrDefault(i => string.Equals(i.Url, url, StringComparison.OrdinalIgnoreCase));

View File

@@ -12,11 +12,7 @@ namespace MediaBrowser.Controller.Entities
public static void AddPerson(List<PersonInfo> people, PersonInfo person)
{
ArgumentNullException.ThrowIfNull(person);
if (string.IsNullOrEmpty(person.Name))
{
throw new ArgumentException("The person's name was empty or null.", nameof(person));
}
ArgumentException.ThrowIfNullOrEmpty(person.Name);
// Normalize
if (string.Equals(person.Role, PersonType.GuestStar, StringComparison.OrdinalIgnoreCase))

View File

@@ -35,10 +35,7 @@ namespace MediaBrowser.Controller.IO
int flattenFolderDepth = 0,
bool resolveShortcuts = true)
{
if (string.IsNullOrEmpty(path))
{
throw new ArgumentNullException(nameof(path));
}
ArgumentException.ThrowIfNullOrEmpty(path);
ArgumentNullException.ThrowIfNull(args);

View File

@@ -171,10 +171,7 @@ namespace MediaBrowser.Controller.Library
/// <exception cref="ArgumentNullException"><paramref name="path"/> is <c>null</c> or empty.</exception>
public void AddAdditionalLocation(string path)
{
if (string.IsNullOrEmpty(path))
{
throw new ArgumentException("The path was empty or null.", nameof(path));
}
ArgumentException.ThrowIfNullOrEmpty(path);
AdditionalLocations ??= new List<string>();
AdditionalLocations.Add(path);
@@ -190,10 +187,7 @@ namespace MediaBrowser.Controller.Library
/// <exception cref="ArgumentNullException"><paramref name="name"/> is <c>null</c> or empty.</exception>
public FileSystemMetadata GetFileSystemEntryByName(string name)
{
if (string.IsNullOrEmpty(name))
{
throw new ArgumentException("The name was empty or null.", nameof(name));
}
ArgumentException.ThrowIfNullOrEmpty(name);
return GetFileSystemEntryByPath(System.IO.Path.Combine(Path, name));
}
@@ -206,10 +200,7 @@ namespace MediaBrowser.Controller.Library
/// <exception cref="ArgumentNullException">Throws if path is invalid.</exception>
public FileSystemMetadata GetFileSystemEntryByPath(string path)
{
if (string.IsNullOrEmpty(path))
{
throw new ArgumentException("The path was empty or null.", nameof(path));
}
ArgumentException.ThrowIfNullOrEmpty(path);
foreach (var file in FileSystemChildren)
{