예제 #1
0
 public static Type GetDelegateType(FluentActionHandlerDefinition handler)
 {
     if (handler.Type == FluentActionHandlerType.Action && !handler.Async)
     {
         return(GetActionType(handler));
     }
     else
     {
         return(GetFuncType(handler));
     }
 }
예제 #2
0
        public static Type GetFuncType(FluentActionHandlerDefinition handler)
        {
            var argumentTypes = handler.Usings.Select(@using => @using.Type).ToList();

            var resultType = GetReturnTypeOrTaskType(handler);

            argumentTypes.Add(resultType);

            var unspecifiedGenericFuncType = GetUnspecifiedGenericFuncType(argumentTypes.Count);
            var specifiedGenericFuncType   = unspecifiedGenericFuncType.MakeGenericType(argumentTypes.ToArray());

            return(specifiedGenericFuncType);
        }
예제 #3
0
 public static Type GetReturnTypeOrTaskType(FluentActionHandlerDefinition handler)
 {
     if (handler.Async && handler.ReturnType == null)
     {
         return(typeof(Task));
     }
     else if (handler.Async && handler.ReturnType != null)
     {
         return(typeof(Task <>).MakeGenericType(handler.ReturnType));
     }
     else
     {
         return(handler.ReturnType);
     }
 }
예제 #4
0
        public static Type GetActionType(FluentActionHandlerDefinition handler)
        {
            var argumentTypes = handler.Usings.Select(@using => @using.Type).ToList();

            if (argumentTypes.Count == 0)
            {
                return(typeof(Action));
            }
            else
            {
                var unspecifiedGenericActionType = GetUnspecifiedGenericActionType(argumentTypes.Count);
                var specifiedGenericActionType   = unspecifiedGenericActionType.MakeGenericType(argumentTypes.ToArray());

                return(specifiedGenericActionType);
            }
        }