Exemplo n.º 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);
Exemplo n.º 2
0
        public T ReadValue(IValueReader valueReader)
        {
            var arrayWriter = ArrayRW <T> .Create();

            valueReader.ReadArray(arrayWriter);

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