User work

This commit is contained in:
tidusjar 2016-08-19 11:22:17 +01:00
commit 068f75f514
7 changed files with 118 additions and 18 deletions

View file

@ -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);
}
}
}