public void WriteValue(IValueWriter valueWriter, T value) { if (value == null) { valueWriter.DirectWrite(null); return; } var dictionaryRW = new DictionaryRW <T, TKey, TValue>(); dictionaryRW.Initialize(value); if (typeof(TKey) == typeof(string)) { valueWriter.WriteObject(Unsafe.As <IDataReader <string> >(dictionaryRW)); } else { if (valueWriter is IMapValueWriter mapWriter) { mapWriter.WriteMap(dictionaryRW); } else { valueWriter.WriteObject(dictionaryRW.As <string>()); } } }
public T ReadValue(IValueReader valueReader) { var dictionaryRW = new DictionaryRW <T>(); valueReader.ReadObject(dictionaryRW.As <string>()); return(dictionaryRW.content); }
/// <summary> /// 从值读取器中读取一个字典。 /// </summary> /// <typeparam name="TKey">键的类型</typeparam> /// <typeparam name="TValue">值的类型</typeparam> /// <param name="valueReader">值读取器</param> /// <returns>返回一个字典</returns> public static Dictionary <TKey, TValue> ReadDictionary <TKey, TValue>(this IValueReader valueReader) { var rw = new DictionaryRW <Dictionary <TKey, TValue>, TKey, TValue>(); valueReader.ReadObject(rw.As <string>()); return(rw.content); }
public T ReadValue(IValueReader valueReader) { var dictionaryRW = new DictionaryRW <T, TKey, TValue>(); if (valueReader is IValueFiller <TKey> tFiller) { tFiller.FillValue(dictionaryRW); } if (IsArray) { valueReader.ReadArray(dictionaryRW.As <int>()); } else { valueReader.ReadObject(dictionaryRW.As <string>()); } return(dictionaryRW.Content); }
public void WriteValue(IValueWriter valueWriter, T value) { if (value == null) { valueWriter.DirectWrite(null); return; } var dictionaryRW = new DictionaryRW <T, TKey, TValue>(); dictionaryRW.Initialize(value); if (IsArray) { valueWriter.WriteArray(dictionaryRW.As <int>()); } else { valueWriter.WriteObject(dictionaryRW.As <string>()); } }
public T ReadValue(IValueReader valueReader) { var dictionaryRW = new DictionaryRW <T>(); if (valueReader is IMapValueReader mapReader) { mapReader.ReadMap(dictionaryRW); } else { valueReader.ReadObject(dictionaryRW.As <string>()); } return(dictionaryRW.Content); }
public void WriteValue(IValueWriter valueWriter, T value) { if (value is null) { valueWriter.DirectWrite(null); return; } var dictionaryRW = new DictionaryRW <T> { content = value }; valueWriter.WriteObject(dictionaryRW.As <string>()); }
public void WriteValue(IValueWriter valueWriter, T value) { if (value == null) { valueWriter.DirectWrite(null); return; } var dictionaryRW = new DictionaryRW <T>(); dictionaryRW.Initialize(value); if (valueWriter is IMapValueWriter mapWriter) { mapWriter.WriteMap(dictionaryRW); } else { valueWriter.WriteObject(dictionaryRW.As <string>()); } }
public T ReadValue(IValueReader valueReader) { var dictionaryRW = new DictionaryRW <T, TKey, TValue>(); if (typeof(TKey) == typeof(string)) { valueReader.ReadObject(Unsafe.As <IDataWriter <string> >(dictionaryRW)); } else { if (valueReader is IMapValueReader mapReader) { mapReader.ReadMap(dictionaryRW); } else { valueReader.ReadObject(dictionaryRW.As <string>()); } } return(dictionaryRW.Content); }