浏览代码

add missing function after merge

crobibero 5 年之前
父节点
当前提交
13c4cb628f
共有 1 个文件被更改,包括 26 次插入0 次删除
  1. 26 0
      Jellyfin.Api/Helpers/RequestHelpers.cs

+ 26 - 0
Jellyfin.Api/Helpers/RequestHelpers.cs

@@ -144,5 +144,31 @@ namespace Jellyfin.Api.Helpers
                 : Split(filters, ',', true)
                 : Split(filters, ',', true)
                     .Select(v => Enum.Parse<ItemFilter>(v, true)).ToArray();
                     .Select(v => Enum.Parse<ItemFilter>(v, true)).ToArray();
         }
         }
+
+        /// <summary>
+        /// Gets the item fields.
+        /// </summary>
+        /// <param name="fields">The fields string.</param>
+        /// <returns>IEnumerable{ItemFields}.</returns>
+        internal static ItemFields[] GetItemFields(string? fields)
+        {
+            if (string.IsNullOrEmpty(fields))
+            {
+                return Array.Empty<ItemFields>();
+            }
+
+            return Split(fields, ',', true)
+                .Select(v =>
+                {
+                    if (Enum.TryParse(v, true, out ItemFields value))
+                    {
+                        return (ItemFields?)value;
+                    }
+
+                    return null;
+                }).Where(i => i.HasValue)
+                .Select(i => i!.Value)
+                .ToArray();
+        }
     }
     }
 }
 }