/// <summary>
        /// 生成ApiReturnDescriptor
        /// </summary>
        /// <param name="method">方法信息</param>
        /// <returns></returns>
        private static ApiReturnDescriptor GetReturnDescriptor(MethodInfo method)
        {
            var returnAttribute = method.FindDeclaringAttribute <IApiReturnAttribute>(true);

            var dataType   = method.ReturnType.GetGenericArguments().FirstOrDefault();
            var descriptor = new ApiReturnDescriptor
            {
                Attribute  = returnAttribute,
                ReturnType = method.ReturnType,
                DataType   = dataType,
                //IsITaskDefinition = method.ReturnType.GetGenericTypeDefinition() == typeof(ITask<>),
                //ITaskCtor = ApiTask.GetITaskConstructor(dataType),
            };

            return(descriptor);
        }
Пример #2
0
        /// <summary>
        /// 生成ApiReturnDescriptor
        /// </summary>
        /// <param name="method">方法信息</param>
        /// <returns></returns>
        private static ApiReturnDescriptor GetReturnDescriptor(MethodInfo method)
        {
            var returnAttribute = method.FindDeclaringAttribute <IApiReturnAttribute>(true);

            if (returnAttribute == null)
            {
                returnAttribute = new AutoReturnAttribute();
            }

            var dataType   = method.ReturnType.GetGenericArguments().FirstOrDefault();
            var descriptor = new ApiReturnDescriptor
            {
                Attribute   = returnAttribute,
                ReturnType  = method.ReturnType,
                GenericType = method.ReturnType.GetGenericTypeDefinition(),
                DataType    = dataType,
                ITaskCtor   = ApiTask.GetConstructor(dataType),
            };

            return(descriptor);
        }
Пример #3
0
        /// <summary>
        /// 生成ApiReturnDescriptor
        /// </summary>
        /// <param name="method">方法信息</param>
        /// <returns></returns>
        private static ApiReturnDescriptor GetReturnDescriptor(this MethodInfo method)
        {
            var returnAttribute = method.FindDeclaringAttribute <IApiReturnAttribute>(true);

            if (returnAttribute == null)
            {
                returnAttribute = new AutoReturnAttribute();
            }

            var dataType   = method.ReturnType.GetGenericArguments().FirstOrDefault() ?? typeof(object);
            var descriptor = new ApiReturnDescriptor
            {
                Attribute         = returnAttribute,
                ReturnType        = method.ReturnType,
                DataType          = dataType,
                IsITaskDefinition = method.ReturnType.IsGenericParameter && method.ReturnType.GetGenericTypeDefinition() == typeof(ITask <>),
                ITaskCtor         = ApiTask.GetITaskConstructor(dataType),
            };

            return(descriptor);
        }
Пример #4
0
        /// <summary>
        /// 生成ApiReturnDescriptor
        /// </summary>
        /// <param name="method">方法信息</param>
        /// <returns></returns>
        private static ApiReturnDescriptor GetReturnDescriptor(this MethodInfo method)
        {
            var returnAttribute = method.FindDeclaringAttribute <IApiReturnAttribute>(true);

            if (returnAttribute == null)
            {
                returnAttribute = new AutoReturnAttribute();
            }

            var dataType           = method.ReturnType.GetGenericArguments().FirstOrDefault();
            var dataTypeDefinition = method.ReturnType.GetGenericTypeDefinition();

            var descriptor = new ApiReturnDescriptor
            {
                Attribute         = returnAttribute,
                ReturnType        = method.ReturnType,
                DataType          = new DataTypeDescriptor(dataType),
                IsTaskDefinition  = dataTypeDefinition == typeof(Task <>),
                IsITaskDefinition = dataTypeDefinition == typeof(ITask <>)
            };

            return(descriptor);
        }