예제 #1
0
 public override System.Type ReturnType()
 {
     System.Type rType = null;
     if (returnType.isAssigned)
     {
         rType = returnType.Get <System.Type>();
     }
     if (rType != null && parameterTypes.All(item => item.isAssigned && item.Get <System.Type>() != null))
     {
         if (rType == typeof(void))
         {
             return(CustomDelegate.GetActionDelegateType(parameterTypes.Select((item) => item.Get <System.Type>()).ToArray()));
         }
         else
         {
             System.Type[] types = new System.Type[parameterTypes.Count + 1];
             for (int x = 0; x < parameterTypes.Count; x++)
             {
                 types[x] = parameterTypes[x].Get <System.Type>();
             }
             types[types.Length - 1] = rType;
             return(CustomDelegate.GetFuncDelegateType(types));
         }
     }
     return(typeof(object));
 }
예제 #2
0
        public override System.Type ReturnType()
        {
            if (!delegateType.isAssigned)
            {
                return(typeof(object));
            }
            var type = delegateType.Get <System.Type>();

            methodInfo = type.GetMethod("Invoke");
            if (methodInfo != null)
            {
                if (methodInfo.ReturnType == typeof(void))
                {
                    return(CustomDelegate.GetActionDelegateType(methodInfo.GetParameters().Select(p => p.ParameterType).ToArray()));
                }
                else
                {
                    var types = methodInfo.GetParameters().Select(i => i.ParameterType).ToList();
                    types.Add(methodInfo.ReturnType);
                    return(CustomDelegate.GetFuncDelegateType(types.ToArray()));
                }
            }
            return(typeof(object));
        }