Beispiel #1
0
 /// <summary>
 /// Invoke this function.
 /// </summary>
 /// <param name="parameter"></param>
 /// <param name="genericType"></param>
 /// <returns></returns>
 public object Invoke(object[] parameter, System.Type[] genericType)
 {
     if (startNode == null)
     {
         if (returnType.Get <System.Type>() != typeof(void))
         {
             throw new System.Exception("Unassigned start node in function:" + this.Name);
         }
         return(null);
     }
     if (parameter != null)
     {
         for (int i = 0; i < parameter.Length; i++)
         {
             parameters[i].value = parameter[i];
         }
     }
     if (genericParameters.Length != 0 && genericType != null &&
         genericParameters.Length != genericType.Length)
     {
         throw new System.Exception("Invalid Generic Length");
     }
     if (genericType != null)
     {
         for (int i = 0; i < genericType.Length; i++)
         {
             genericParameters[i].value = genericType[i];
         }
     }
     InitLocalVariable();            //Init local variable to initial value
     System.Type rType = null;
     if (returnType != null && returnType.isAssigned)
     {
         rType = returnType.Get() as System.Type;
         if (rType != null && rType != typeof(void) && (rType.IsCastableTo(typeof(IEnumerable)) || rType.IsCastableTo(typeof(IEnumerator))))
         {
             return(WaitUntilFinish(startNode));
         }
     }
     startNode.Activate();
     if (rType != null && rType != typeof(void))
     {
         JumpStatement js = startNode.GetJumpState();
         if (js == null || js.jumpType != JumpStatementType.Return)
         {
             throw new System.Exception("No return value in function:" + Name);
         }
         else if (js.from is NodeReturn)
         {
             return((js.from as NodeReturn).GetReturnValue());
         }
     }
     return(null);
 }
Beispiel #2
0
 public override void OnExecute()
 {
     jumpState = new JumpStatement(JumpStatementType.Return, this);
     Finish();
 }