Move Split method from BaseJellyfinApiController.cs to RequestHelpers.cs
This commit is contained in:
parent
f3029428cd
commit
7fa374f8a2
|
@ -10,23 +10,5 @@ namespace Jellyfin.Api
|
||||||
[Route("[controller]")]
|
[Route("[controller]")]
|
||||||
public class BaseJellyfinApiController : ControllerBase
|
public class BaseJellyfinApiController : ControllerBase
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Splits a string at a seperating character into an array of substrings.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="value">The string to split.</param>
|
|
||||||
/// <param name="separator">The char that seperates the substrings.</param>
|
|
||||||
/// <param name="removeEmpty">Option to remove empty substrings from the array.</param>
|
|
||||||
/// <returns>An array of the substrings.</returns>
|
|
||||||
internal static string[] Split(string value, char separator, bool removeEmpty)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrWhiteSpace(value))
|
|
||||||
{
|
|
||||||
return Array.Empty<string>();
|
|
||||||
}
|
|
||||||
|
|
||||||
return removeEmpty
|
|
||||||
? value.Split(new[] { separator }, StringSplitOptions.RemoveEmptyEntries)
|
|
||||||
: value.Split(separator);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ using System.ComponentModel;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Jellyfin.Api.Helpers;
|
||||||
using MediaBrowser.Controller.Drawing;
|
using MediaBrowser.Controller.Drawing;
|
||||||
using MediaBrowser.Controller.Dto;
|
using MediaBrowser.Controller.Dto;
|
||||||
using MediaBrowser.Controller.Entities;
|
using MediaBrowser.Controller.Entities;
|
||||||
|
@ -105,9 +106,9 @@ namespace Jellyfin.Api.Controllers
|
||||||
IncludeStudios = includeStudios,
|
IncludeStudios = includeStudios,
|
||||||
StartIndex = startIndex,
|
StartIndex = startIndex,
|
||||||
UserId = userId,
|
UserId = userId,
|
||||||
IncludeItemTypes = Split(includeItemTypes, ',', true),
|
IncludeItemTypes = RequestHelpers.Split(includeItemTypes, ',', true),
|
||||||
ExcludeItemTypes = Split(excludeItemTypes, ',', true),
|
ExcludeItemTypes = RequestHelpers.Split(excludeItemTypes, ',', true),
|
||||||
MediaTypes = Split(mediaTypes, ',', true),
|
MediaTypes = RequestHelpers.Split(mediaTypes, ',', true),
|
||||||
ParentId = parentId,
|
ParentId = parentId,
|
||||||
|
|
||||||
IsKids = isKids,
|
IsKids = isKids,
|
||||||
|
|
29
Jellyfin.Api/Helpers/RequestHelpers.cs
Normal file
29
Jellyfin.Api/Helpers/RequestHelpers.cs
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Jellyfin.Api.Helpers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Request Extensions.
|
||||||
|
/// </summary>
|
||||||
|
public static class RequestHelpers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Splits a string at a seperating character into an array of substrings.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="value">The string to split.</param>
|
||||||
|
/// <param name="separator">The char that seperates the substrings.</param>
|
||||||
|
/// <param name="removeEmpty">Option to remove empty substrings from the array.</param>
|
||||||
|
/// <returns>An array of the substrings.</returns>
|
||||||
|
internal static string[] Split(string value, char separator, bool removeEmpty)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(value))
|
||||||
|
{
|
||||||
|
return Array.Empty<string>();
|
||||||
|
}
|
||||||
|
|
||||||
|
return removeEmpty
|
||||||
|
? value.Split(new[] { separator }, StringSplitOptions.RemoveEmptyEntries)
|
||||||
|
: value.Split(separator);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user