/// <summary> /// 获取支持 <see cref="RedisValue"/>包装的运行时属性 /// 支持 <see cref="Type.IsValueType"/> 和 <see cref="T:string"/> /// </summary> /// <remarks> /// 支持类型: /// - string /// - DateTime /// - int /// - uint /// - double /// - byte[] /// - bool /// - long /// - ulong /// - float /// - ReadOnlyMemory>byte< /// - Memory>byte< /// - RedisValue /// </remarks> /// <typeparam name="T"></typeparam> /// <returns></returns> private static PropertyInfo[] GetProperties <T> () { return(PropertiesCache <T> .GetProperties()); }
public static IDictionary <string, object> ToDictionary(this object item) { return(PropertiesCache.GetProperties(item).ToDictionary(prop => prop.Name, prop => prop.GetValue(item, null))); }