/// <summary> /// 获取数据读写器中指定键的值的类型。 /// </summary> /// <typeparam name="TKey">键类型</typeparam> /// <param name="dataRW">数据读写器</param> /// <param name="key">指定键</param> /// <returns>返回一个类型</returns> public static Type GetItemType <TKey>(IDataRW <TKey> dataRW, TKey key) { var auxiliary = new AuxiliaryValueRW(); dataRW.OnReadValue(key, auxiliary); return(auxiliary.GetValueType()); }
/// <summary> /// 获取数据读写器中指定键的值的类型。 /// </summary> /// <typeparam name="TKey">键类型</typeparam> /// <param name="dataRW">数据读写器</param> /// <param name="key">指定键</param> /// <returns>返回一个类型</returns> public static Type GetItemType <TKey>(IDataRW <TKey> dataRW, TKey key) { var auxiliary = new AuxiliaryValueRW(); if (typeof(TKey) == typeof(long) && ((dataRW as IAsDataReader)?.Content ?? dataRW) is IId64DataRW id64DataRW) { id64DataRW.OnReadValue(Unsafe.As <TKey, long>(ref key), auxiliary); } else { dataRW.OnReadValue(key, auxiliary); } return(auxiliary.GetType()); }
/// <summary> /// 转换键,并将该键对应的值写入到值写入器中。 /// </summary> /// <param name="key">指定键</param> /// <param name="valueWriter">值写入器</param> public void OnReadValue(TOut key, IValueWriter valueWriter) { dataRW.OnReadValue(XConvert <TOut, TIn> .Convert(key), valueWriter); }