mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-21 05:43:19 -07:00
User work
This commit is contained in:
parent
2a6f928902
commit
068f75f514
7 changed files with 118 additions and 18 deletions
|
@ -25,7 +25,9 @@
|
|||
// ************************************************************************/
|
||||
#endregion
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace PlexRequests.Helpers
|
||||
{
|
||||
|
@ -35,5 +37,19 @@ namespace PlexRequests.Helpers
|
|||
{
|
||||
return t.GetProperties().Select(x => x.Name).ToArray();
|
||||
}
|
||||
|
||||
public static IEnumerable<FieldInfo> GetConstants(this Type type)
|
||||
{
|
||||
var fieldInfos = type.GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy);
|
||||
|
||||
return fieldInfos.Where(fi => fi.IsLiteral && !fi.IsInitOnly);
|
||||
}
|
||||
|
||||
public static IEnumerable<T> GetConstantsValues<T>(this Type type) where T : class
|
||||
{
|
||||
var fieldInfos = GetConstants(type);
|
||||
|
||||
return fieldInfos.Select(fi => fi.GetRawConstantValue() as T);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue