Move Split method from BaseJellyfinApiController.cs to RequestHelpers.cs

pull/3226/head
David 4 years ago
parent f3029428cd
commit 7fa374f8a2

@ -10,23 +10,5 @@ namespace Jellyfin.Api
[Route("[controller]")]
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.Globalization;
using System.Linq;
using Jellyfin.Api.Helpers;
using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
@ -105,9 +106,9 @@ namespace Jellyfin.Api.Controllers
IncludeStudios = includeStudios,
StartIndex = startIndex,
UserId = userId,
IncludeItemTypes = Split(includeItemTypes, ',', true),
ExcludeItemTypes = Split(excludeItemTypes, ',', true),
MediaTypes = Split(mediaTypes, ',', true),
IncludeItemTypes = RequestHelpers.Split(includeItemTypes, ',', true),
ExcludeItemTypes = RequestHelpers.Split(excludeItemTypes, ',', true),
MediaTypes = RequestHelpers.Split(mediaTypes, ',', true),
ParentId = parentId,
IsKids = isKids,

@ -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…
Cancel
Save