示例#1
0
        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);
示例#2
0
        public T ReadValue(IValueReader valueReader)
        {
            var arrayWriter = ArrayRW <T> .Create();

            valueReader.ReadArray(arrayWriter);

            return(arrayWriter.Content);
        }
示例#3
0
        /// <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());
        }
示例#4
0
 public void WriteValue(IValueWriter valueWriter, T value)
 {
     if (value == null)
     {
         valueWriter.DirectWrite(null);
     }
     else
     {
         valueWriter.WriteArray(ArrayRW <T> .Create(value));
     }
 }
示例#5
0
        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);
        }
示例#6
0
 protected override ArrayRW <T> CreateInstance()
 {
     return(ArrayRW <T> .CreateAppend());
 }