private Func <JToken, bool> ByToken <T> (EntityTokenProperties prop, T val) where T : IEquatable <T> { if (!Enum.IsDefined(typeof(EntityTokenProperties), prop)) { throw new Exception($"Enum property {prop} is not defined."); } return(t => { JToken token = t.SelectToken(Enum.GetName(typeof(EntityTokenProperties), prop)); if (token == null) { return false; } return EqualityComparer <T> .Default.Equals(token.Value <T>(), val); }); }
public static T GetUserEntityProperty <T>(this JToken token, EntityTokenProperties property) { return(token.SelectToken(Enum.GetName(typeof(Enum), property)).Value <T>()); }