public T ReadValue(IValueReader valueReader) { if (valueReader is ISingleThreadOptimize) { var current_cache = thread_cache; if (current_cache == null) { current_cache = new InternalInstance <ArrayRW <T> > { Instance = ArrayRW <T> .Create() }; thread_cache = current_cache; } if (current_cache.IsUsed) { goto Default; } current_cache.IsUsed = true; current_cache.Instance.count = -1; valueReader.ReadArray(current_cache.Instance); current_cache.IsUsed = false; if (current_cache.Instance.count == -1) { return(default);
public T ReadValue(IValueReader valueReader) { var arrayWriter = ArrayRW <T> .Create(); valueReader.ReadArray(arrayWriter); return(arrayWriter.Content); }
/// <summary> /// 从值读取器中读取一个数组。 /// </summary> /// <typeparam name="T">元素类型</typeparam> /// <param name="valueReader">值读取器</param> /// <returns>返回一个数组</returns> public static T[] ReadArray <T>(this IValueReader valueReader) { var rw = new ArrayRW <T>(); valueReader.ReadArray(rw); return(rw.GetContent()); }
public void WriteValue(IValueWriter valueWriter, T value) { if (value == null) { valueWriter.DirectWrite(null); } else { valueWriter.WriteArray(ArrayRW <T> .Create(value)); } }
public void WriteValue(IValueWriter valueWriter, T value) { if (value == null) { valueWriter.DirectWrite(null); return; } var arrayWriter = ArrayRW <T> .Create(); arrayWriter.Initialize(value); valueWriter.WriteArray(arrayWriter); }
protected override ArrayRW <T> CreateInstance() { return(ArrayRW <T> .CreateAppend()); }