public static Coroutine StartCoroutine(this MonoBehaviour behaviour, System.Delegate method, params object[] args)
        {
            if (behaviour == null)
            {
                throw new System.ArgumentNullException("behaviour");
            }
            if (method == null)
            {
                throw new System.ArgumentNullException("method");
            }

            System.Collections.IEnumerator e;
            if (com.spacepuppy.Utils.TypeUtil.IsType(method.Method.ReturnType, typeof(System.Collections.IEnumerable)))
            {
                e = (method.DynamicInvoke(args) as System.Collections.IEnumerable).GetEnumerator();
            }
            else if (com.spacepuppy.Utils.TypeUtil.IsType(method.Method.ReturnType, typeof(System.Collections.IEnumerator)))
            {
                e = (method.DynamicInvoke(args) as System.Collections.IEnumerator);
            }
            else
            {
                throw new System.ArgumentException("Delegate must have a return type of IEnumerable or IEnumerator.", "method");
            }

            return(behaviour.StartCoroutine(e));
        }
        public static RadicalCoroutine StartRadicalCoroutineAsync(this MonoBehaviour behaviour, System.Delegate method, object[] args = null, RadicalCoroutineDisableMode disableMode = RadicalCoroutineDisableMode.Default)
        {
            if (behaviour == null)
            {
                throw new System.ArgumentNullException("behaviour");
            }
            if (method == null)
            {
                throw new System.ArgumentNullException("method");
            }

            System.Collections.IEnumerator e;
            if (com.spacepuppy.Utils.TypeUtil.IsType(method.Method.ReturnType, typeof(System.Collections.IEnumerable)))
            {
                e = (method.DynamicInvoke(args) as System.Collections.IEnumerable).GetEnumerator();
            }
            else if (com.spacepuppy.Utils.TypeUtil.IsType(method.Method.ReturnType, typeof(System.Collections.IEnumerator)))
            {
                e = (method.DynamicInvoke(args) as System.Collections.IEnumerator);
            }
            else
            {
                throw new System.ArgumentException("Delegate must have a return type of IEnumerable or IEnumerator.", "method");
            }

            var co = new RadicalCoroutine(e);

            co.StartAsync(behaviour, disableMode);
            return(co);
        }
Example #3
0
 public void ForEach(System.Delegate iterate)
 {
     for (int i = 0; i < _size; i++)
     {
         iterate.DynamicInvoke(_items[i]);
     }
 }
Example #4
0
 public void TrggerCommand(BaseEventData data)
 {
     if (_bindCommand == null)
     {
         return;
     }
     _bindCommand.DynamicInvoke(data);
 }
Example #5
0
 public bool MoveNext()
 {
     if (!done_)
     {
         func_.DynamicInvoke(args_);
         done_ = true;
     }
     return(false);
 }
Example #6
0
        internal virtual int Invoke(int b1, int b2)
        {
            object[] args = new object[] {
                b1,
                b2
            };
            int ret = ((int)(d.DynamicInvoke(args)));

            return(ret);
        }
Example #7
0
 protected bool CallDelegateFunction()
 {
     try
     {
         System.Delegate v_tempFunctionPointer = DelegatePointer;
         object[]        v_params = Params.ToArray();
         if (v_tempFunctionPointer != null)
         {
             if (Params.Count == 0)
             {
                 v_tempFunctionPointer.DynamicInvoke(null);
             }
             else
             {
                 v_tempFunctionPointer.DynamicInvoke(v_params);
             }
             return(true);
         }
     }
     catch { }
     return(false);
 }
Example #8
0
 /// <summary>
 /// Only use the Dispatcher if we are not already on the UI Thread.
 /// This avoid WPF exceptions saying the dispatcher is unavailable.
 /// </summary>
 /// <param name="d">The delegate to invoke</param>
 /// <param name="args">Optional parameters</param>
 public static object Invoke(System.Delegate d, params object[] args)
 {
     if (dispatcher != null && System.Threading.Thread.CurrentThread.ManagedThreadId != uiThreadId)
     {
         // Note: must be careful using this method, it could deadlock the UI, so make sure
         // it cannot be interleaved with similar calls.
         return(dispatcher.Invoke(d, args));
     }
     else
     {
         // we are already on the UI thread so call the delegate directly.
         return(d.DynamicInvoke(args));
     }
 }
    // protected delegate string getName_t();
    public MyAttribute(System.Type classType, string delegateName)
        : base()
    {
        System.Reflection.MethodInfo mi = classType.GetMethod(delegateName,
                                                              System.Reflection.BindingFlags.Static
                                                              | System.Reflection.BindingFlags.Public
                                                              | System.Reflection.BindingFlags.NonPublic
                                                              );
        System.Type delegateType = CreateDelegateType(mi);
        // getName_t getName = (getName_t)System.Delegate.CreateDelegate(delegateType, mi));
        System.Delegate getName = System.Delegate.CreateDelegate(delegateType, mi);
        object          name    = getName.DynamicInvoke(null);

        this.m_name = System.Convert.ToString(name);
    }
Example #10
0
 /// <summary>
 /// Only use the Dispatcher if we are not already on the UI Thread.
 /// This avoid WPF exceptions saying the dispatcher is unavailable.
 /// </summary>
 /// <param name="d">The delegate to invoke</param>
 /// <param name="args">Optional parameters</param>
 public static object BeginInvoke(System.Delegate d, params object[] args)
 {
     if (dispatcher != null && System.Threading.Thread.CurrentThread.ManagedThreadId != uiThreadId)
     {
         // Note: we cannot use dispatcher.Invoke because that can lead to deadlocks.
         // For example, if this is a background thread with a lock() on a money data object
         // (like account.rebalance does) then UI thread might be blocked on trying to get
         // that lock and this dispatcher invoke would therefore create a deadlock.
         return(dispatcher.BeginInvoke(d, args));
     }
     else
     {
         // we are already on the UI thread so call the delegate directly.
         return(d.DynamicInvoke(args));
     }
 }
Example #11
0
        public static bool Execute(GameObject gameObject, System.Type handlerType, System.Delegate handlerExecutor, object state)
        {
            var handlers = ListPool <object> .Request();

            try{
                GetHandlers(gameObject, handlerType, handlers);
                if (handlers.Count == 0)
                {
                    return(false);
                }
                foreach (var handler in handlers)
                {
                    handlerExecutor.DynamicInvoke(handler, state);
                }
                return(true);
            }finally{
                ListPool <object> .Release(handlers);
            }
        }
Example #12
0
 public void CallMemberFunctions <T>(T value)
 {
     foreach (ActionEventMethod memberName in methodArray)
     {
         if (memberName.parameterType != null)
         {
             System.Delegate function = viewModelBinding.model.GetFunctionParam1(memberName.methodName, memberName.parameterType);
             function.DynamicInvoke(memberName.parameterValue);
         }
         else
         {
             System.Action <T> function = viewModelBinding.model.GetFunctionParam1 <T>(memberName.methodName);
             if (function != null)
             {
                 function(value);
             }
         }
     }
 }
    public void processRequest(API.Request request)
    {
        String resquestType  = request.GetType().Name;
        String processorName = resquestType.Substring(0, resquestType.Length - 2);

        API.Response response = null;

        string processorName = "Process" + processorName;

        if (ProcessHandlers.ContainsKey(processorName))
        {
            System.Delegate myDelegate = ProcessHandlers[processorName];
            response = (API.Response)myDelegate.DynamicInvoke(request);
        }
        else
        {
            logger.Warn("Failed to find a processor for " + processorName);
            response = new ErrorRs(request.id, "Failed to find a processor for " + processorName);
        }

        sendResponse(response, request);
    }
Example #14
0
            public static void UpdateVariableViaHandle <T> (this Editor editor, ref T var, System.Delegate handleMethod, string undoName, params object[] handleParams)
            {
                EditorGUI.BeginChangeCheck();
                T value = default(T);

                try {
                    value = (T)handleMethod.DynamicInvoke(handleParams);
                }
                catch (System.Exception e) {
                    Debug.LogErrorFormat("JBirdEditor.UpdateListIndexViaHandle: Method '{0}' does not return type '{1}'. Exception message: {2}", handleMethod.Method.Name, typeof(T).ToString(), e.Message);
                    EditorGUI.EndChangeCheck();
                    return;
                }

                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(editor.target, string.Format("{0}Change{1}", editor.target.GetType().ToString(), undoName == "" ? handleMethod.Method.Name : undoName));
                    var = value;
                    EditorUtility.SetDirty(editor.target);
                    SceneView.RepaintAll();
                    editor.Repaint();
                }
            }