Exemple #1
0
 public Result(params object[] args)
 {
     if (args != null)
     {
         Arguments = new List <byte[]>();
         foreach (var arg in args)
         {
             Arguments.Add(SerializationPacker.PackSingleObject(arg));
         }
     }
 }
Exemple #2
0
        /// <summary>
        /// 将默认索引为0的数据转换成指定类型的对象
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public T As <T>()
        {
            if (IsError)
            {
                throw new NetxException(ErrorMsg, ErrorId);
            }

            if (Length <= 0 || Arguments is null)
            {
                throw new NetxException("null value", ErrorType.NotValue);
            }

            return((T)SerializationPacker.UnpackSingleObject(typeof(T), Arguments[0]));
        }
Exemple #3
0
        /// <summary>
        /// 将指定索引转换成指定类型的对象
        /// </summary>
        /// <param name="type">类型</param>
        /// <param name="index">索引</param>
        /// <returns></returns>
        public object As(Type type, int index)
        {
            if (IsError)
            {
                throw new NetxException(ErrorMsg, ErrorId);
            }

            if (Length <= 0 || Arguments is null)
            {
                throw new NetxException("null value", ErrorType.NotValue);
            }

            if (index > Length)
            {
                throw new NetxException("not find value index error", ErrorType.IndexError);
            }

            return(SerializationPacker.UnpackSingleObject(type, Arguments[index]));
        }
Exemple #4
0
 public T Value <T>()
 {
     return((T)SerializationPacker.UnpackSingleObject(typeof(T), Data));
 }