/// <summary> /// Generate the necessary parameters /// </summary> public List <KeyValuePair <string, string> > GetParams() { var p = new List <KeyValuePair <string, string> >(); if (Sim != null) { p.Add(new KeyValuePair <string, string>("Sim", Sim.ToString())); } if (Command != null) { p.Add(new KeyValuePair <string, string>("Command", Command)); } if (CallbackMethod != null) { p.Add(new KeyValuePair <string, string>("CallbackMethod", CallbackMethod.ToString())); } if (CallbackUrl != null) { p.Add(new KeyValuePair <string, string>("CallbackUrl", Serializers.Url(CallbackUrl))); } return(p); }
// fired by BackgroundWorker.RunWorkerAsync() private void BackgroundWorkerDoWork(object sender, DoWorkEventArgs e) { e.Result = CallbackMethod.DynamicInvoke(new[] { sender, e }); // if background work completes before cancel handled, background worker will not have set CancellationPending; if (BackgroundWorker.CancellationPending && !e.Cancel) { e.Cancel = true; } }
public virtual void SetObject(Control control, object data) { if (control == null) { throw new ArgumentNullException("control"); } CallbackMethod.Invoke(control, new object[] { data }); }
public virtual object GetObject(Control control) { if (control == null) { throw new ArgumentNullException("control"); } return(CallbackMethod.Invoke(control, null)); }
public static void InvokeServiceMethod(ServiceTypes type, string method, CallbackMethod callback, params string[] args) { if (callback != null) { string url = string.Format("{0}{1}/{2}.cshtml", Singleton.ServicesURL, convertType(type), method); Debug.Log("Invoking URL: " + url); Singleton.StartCoroutine(Singleton.invokeWebMethod(convertAPI_Key(type), url, callback, args)); } }
/// <summary> /// Returns a hash code for this instance. /// </summary> /// <returns> /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. /// </returns> public override int GetHashCode() { unchecked { int hash = ((CallbackMethod != null ? CallbackMethod.GetHashCode() : 0) * 397) ^ (CallbackTarget != null ? CallbackTarget.GetHashCode() : 0); hash = (hash * 397) ^ Event.EventDetail.ID; hash = (hash * 397) ^ EllaModel.Instance.GetPublisherId(Event.Publisher); return(hash); } }
private void LoadDataFromARemoteServer(CallbackMethod callbackMethod) { Console.WriteLine("Lade daten!"); Thread.Sleep(3000); if (callbackMethod != null) { callbackMethod(new string[] { "Meine nachgeladenen Daten.", "Zweite Zeile" }); } }
private IEnumerator invokeWebMethod(string api_key, string url, CallbackMethod callback, params string[] args) { ProcessingCanvas.SetActive(true); // add form data var form = new WWWForm(); form.AddField("api_key", api_key); foreach (var arg in args) { var values = arg.Split('='); form.AddField(values[0], values[1]); } // invoke http method var www = new WWW(url, form); yield return(www); // check for server errors if (!string.IsNullOrEmpty(www.error)) { Debug.LogError(www.error); callback(false, null); ProcessingCanvas.SetActive(false); yield break; } // process response var response = generateResponse(www.text); if (response != null) { if (response.Type == XML.ResponseTypes.Error) { Debug.LogError("Failed: " + response.ErrorMessage); callback(false, null); ProcessingCanvas.SetActive(false); yield break; } callback(true, response); } else { Debug.LogError("response is null"); callback(false, null); ProcessingCanvas.SetActive(false); yield break; } ProcessingCanvas.SetActive(false); }
private static Dictionary <Event, CallbackMethod> listeners = new Dictionary <Event, CallbackMethod>(); // Creates Dictionary to hold events, and their listners // Function adds listeners to an Event public static void SubscribeListener(Event inEvent, CallbackMethod listener) { // If the event is not in the dictionary if (!listeners.ContainsKey(inEvent)) { listeners.Add(inEvent, listener); //Adds the event with the listener to the dictionary } // If the event is in the Dicitionary else { listeners[inEvent] += listener; //Adds the listener to the event } }
//Fires the code on the next update/fixed update. Lazy way to keep the code from affecting what you're doing right now /// <summary> /// Calls the specified code on the next Update(). /// </summary> /// <param name="code">The function to call.</param> /// <param name="mode">The time mode to run the Coroutine with.</param> /// <returns></returns> public static IEnumerator FireForUpdateRoutine(CallbackMethod code, Mode mode = Mode.UPDATE) { switch(mode) { case Mode.UPDATE: case Mode.REALTIME: yield return null; break; case Mode.FIXEDUPDATE: yield return new WaitForFixedUpdate(); break; } code(); }
//basically Invoke /// <summary> /// Calls the specified code after the specified time has passed. /// </summary> /// <param name="code">The function to call.</param> /// <param name="time">The amount of time to wait before calling the code.</param> /// <param name="callingScript">The <see cref="MonoBehaviour"/> to run the Coroutine on.</param> /// <param name="mode">The time mode to run the Coroutine with.</param> /// <returns></returns> public static IEnumerator FireAndForgetRoutine(CallbackMethod code, float time, MonoBehaviour callingScript, Mode mode = Mode.UPDATE) { switch(mode) { case Mode.UPDATE: case Mode.FIXEDUPDATE: yield return new WaitForSeconds(time); break; case Mode.REALTIME: yield return callingScript.StartCoroutine(WaitForRealSecondsRoutine(time)); break; } code(); }
//Removes listeners from events public static void UnSubscribeListener(Event inEvent, CallbackMethod listener) { //If the event is in the dictionary if (listeners.ContainsKey(inEvent)) { listeners[inEvent] -= listener; //Removes the listener from the event //If the event has no listeners if (listeners[inEvent] == null) { listeners.Remove(inEvent); //removes the event from the dicitonary } } }
//Fires the code on the next update/fixed update. Lazy way to keep the code from affecting what you're doing right now /// <summary> /// Calls the specified code on the next Update(). /// </summary> /// <param name="code">The function to call.</param> /// <param name="mode">The time mode to run the Coroutine with.</param> /// <returns></returns> public static IEnumerator FireForUpdateRoutine(CallbackMethod code, Mode mode = Mode.UPDATE) { switch (mode) { case Mode.UPDATE: case Mode.REALTIME: yield return(null); break; case Mode.FIXEDUPDATE: yield return(new WaitForFixedUpdate()); break; } code(); }
//basically Invoke /// <summary> /// Calls the specified code after the specified time has passed. /// </summary> /// <param name="code">The function to call.</param> /// <param name="time">The amount of time to wait before calling the code.</param> /// <param name="callingScript">The <see cref="MonoBehaviour"/> to run the Coroutine on.</param> /// <param name="mode">The time mode to run the Coroutine with.</param> /// <returns></returns> public static IEnumerator FireAndForgetRoutine(CallbackMethod code, float time, MonoBehaviour callingScript, Mode mode = Mode.UPDATE) { switch (mode) { case Mode.UPDATE: case Mode.FIXEDUPDATE: yield return(new WaitForSeconds(time)); break; case Mode.REALTIME: yield return(callingScript.StartCoroutine(WaitForRealSecondsRoutine(time))); break; } code(); }
/// <summary> /// Generate the necessary parameters /// </summary> public List <KeyValuePair <string, string> > GetParams() { var p = new List <KeyValuePair <string, string> >(); if (Command != null) { p.Add(new KeyValuePair <string, string>("Command", Command)); } if (Sim != null) { p.Add(new KeyValuePair <string, string>("Sim", Sim)); } if (CallbackMethod != null) { p.Add(new KeyValuePair <string, string>("CallbackMethod", CallbackMethod.ToString())); } if (CallbackUrl != null) { p.Add(new KeyValuePair <string, string>("CallbackUrl", Serializers.Url(CallbackUrl))); } if (CommandMode != null) { p.Add(new KeyValuePair <string, string>("CommandMode", CommandMode.ToString())); } if (IncludeSid != null) { p.Add(new KeyValuePair <string, string>("IncludeSid", IncludeSid)); } if (DeliveryReceiptRequested != null) { p.Add(new KeyValuePair <string, string>("DeliveryReceiptRequested", DeliveryReceiptRequested.Value.ToString().ToLower())); } return(p); }
IEnumerator PopulateOctree(CallbackMethod del) { GameObject[] gameObjects = GameObject.FindObjectsOfType(typeof(GameObject)) as GameObject[]; GameObject curGO; Triangle[] curTris = new Triangle[] {}; MeshFilter curMeshFilter = null; APAOctree finalNode; for (int i = 0; i < gameObjects.Length; i++) { curGO = gameObjects [i]; if (curGO == null || curGO.name.Contains("Combined Mesh") || curGO.name == null || curGO.layer != LayerMask.NameToLayer("Raycast")) { continue; } curMeshFilter = curGO.GetComponent <MeshFilter>(); if (!curMeshFilter) { continue; } curTris = new Triangle[] {}; curTris = GetTriangles(curGO); for (int k = 0; k < curTris.Length; k++) { finalNode = octree.IndexTriangle(curTris[k]); finalNode.AddTriangle(curTris[k]); } if (i % objectsPerChunk == 1) { yield return(0); } } del(); Debug.Log("Created Database"); Debug.Log("Total Indexed Triangles: " + GetTriangleCount(octree)); }
/// <summary> /// Generate the necessary parameters /// </summary> public List <KeyValuePair <string, string> > GetParams() { var p = new List <KeyValuePair <string, string> >(); if (CallbackUrl != null) { p.Add(new KeyValuePair <string, string>("CallbackUrl", CallbackUrl.ToString())); } if (TriggerValue != null) { p.Add(new KeyValuePair <string, string>("TriggerValue", TriggerValue)); } if (UsageCategory != null) { p.Add(new KeyValuePair <string, string>("UsageCategory", UsageCategory.ToString())); } if (CallbackMethod != null) { p.Add(new KeyValuePair <string, string>("CallbackMethod", CallbackMethod.ToString())); } if (FriendlyName != null) { p.Add(new KeyValuePair <string, string>("FriendlyName", FriendlyName)); } if (Recurring != null) { p.Add(new KeyValuePair <string, string>("Recurring", Recurring.ToString())); } if (TriggerBy != null) { p.Add(new KeyValuePair <string, string>("TriggerBy", TriggerBy.ToString())); } return(p); }
/// <summary> /// Generate the necessary parameters /// </summary> public List <KeyValuePair <string, string> > GetParams() { var p = new List <KeyValuePair <string, string> >(); if (CallbackMethod != null) { p.Add(new KeyValuePair <string, string>("CallbackMethod", CallbackMethod.ToString())); } if (CallbackUrl != null) { p.Add(new KeyValuePair <string, string>("CallbackUrl", CallbackUrl.ToString())); } if (FriendlyName != null) { p.Add(new KeyValuePair <string, string>("FriendlyName", FriendlyName)); } return(p); }
static void Main(string[] args) { try { // access ordinary functions CObjectNet.ObjectDllMethod(); string res = string.Empty; CObjectNet.ObjectDllFunction("", ref res); Console.WriteLine(res); // now do the function callback CallbackFunction cb_func = MyCallbackFunc; IntPtr cb_func_ptr = Marshal.GetFunctionPointerForDelegate(cb_func); gch_cb_meth = GCHandle.Alloc(cb_func); GC.Collect(); CObjectNet.ObjectDllCallback(cb_func_ptr); // access class/members CObjectNet pObj = new CObjectNet(); pObj.ObjectCreate(); pObj.InvokeMethod(); // now do the method callback CallbackMethod cb_meth = MyCallbackMethod; IntPtr cb_meth_ptr = Marshal.GetFunctionPointerForDelegate(cb_meth); gch_cb_meth = GCHandle.Alloc(cb_meth); GC.Collect(); IntPtr user_data = (IntPtr)GCHandle.Alloc(pObj); pObj.InvokeCallback(cb_meth_ptr, user_data); pObj.ObjectFree(); } catch (Exception e) { Console.WriteLine(e.StackTrace); } }
static void Main(string[] args) { try { string res = string.Empty; IObjectComLib pObj = new CObjectComLib(); pObj.ObjectCreate(); // call some ordinary functions pObj.ObjectDllMethod(); pObj.ObjectDllFunction("", ref res); Console.WriteLine(res); // call member functions pObj.InvokeMethod(); pObj.InvokeObjectMethod("CObjectComLib::InvokeObjectMethod ", ref res); Console.WriteLine(res); // now do the method callback CallbackMethod cb_meth = MyCallbackMethod; IntPtr cb_meth_ptr = Marshal.GetFunctionPointerForDelegate(cb_meth); gch_cb_meth = GCHandle.Alloc(cb_meth); GC.Collect(); //IntPtr user_data = (IntPtr) GCHandle.Alloc(pObj); //pObj.InvokeCallback(cb_meth_ptr, user_data); // user_data.ToPointer() // TODO... //pObj.Initialize(pObj); pObj.ObjectFree(); } catch (Exception e) { Console.WriteLine(e.StackTrace); } }
/// <summary> /// Generate the necessary parameters /// </summary> public List <KeyValuePair <string, string> > GetParams() { var p = new List <KeyValuePair <string, string> >(); if (UniqueName != null) { p.Add(new KeyValuePair <string, string>("UniqueName", UniqueName)); } if (Status != null) { p.Add(new KeyValuePair <string, string>("Status", Status.ToString())); } if (Fleet != null) { p.Add(new KeyValuePair <string, string>("Fleet", Fleet.ToString())); } if (CallbackUrl != null) { p.Add(new KeyValuePair <string, string>("CallbackUrl", Serializers.Url(CallbackUrl))); } if (CallbackMethod != null) { p.Add(new KeyValuePair <string, string>("CallbackMethod", CallbackMethod.ToString())); } if (AccountSid != null) { p.Add(new KeyValuePair <string, string>("AccountSid", AccountSid.ToString())); } return(p); }
/// <summary> /// Generate the necessary parameters /// </summary> public List <KeyValuePair <string, string> > GetParams() { var p = new List <KeyValuePair <string, string> >(); if (Command != null) { p.Add(new KeyValuePair <string, string>("Command", Command)); } if (Sim != null) { p.Add(new KeyValuePair <string, string>("Sim", Sim)); } if (CallbackMethod != null) { p.Add(new KeyValuePair <string, string>("CallbackMethod", CallbackMethod.ToString())); } if (CallbackUrl != null) { p.Add(new KeyValuePair <string, string>("CallbackUrl", CallbackUrl.AbsoluteUri)); } if (CommandMode != null) { p.Add(new KeyValuePair <string, string>("CommandMode", CommandMode.ToString())); } if (IncludeSid != null) { p.Add(new KeyValuePair <string, string>("IncludeSid", IncludeSid)); } return(p); }
/// <summary> /// Generate the necessary parameters /// </summary> public List <KeyValuePair <string, string> > GetParams() { var p = new List <KeyValuePair <string, string> >(); if (UniqueName != null) { p.Add(new KeyValuePair <string, string>("UniqueName", UniqueName)); } if (CallbackMethod != null) { p.Add(new KeyValuePair <string, string>("CallbackMethod", CallbackMethod.ToString())); } if (CallbackUrl != null) { p.Add(new KeyValuePair <string, string>("CallbackUrl", CallbackUrl.AbsoluteUri)); } if (FriendlyName != null) { p.Add(new KeyValuePair <string, string>("FriendlyName", FriendlyName)); } if (RatePlan != null) { p.Add(new KeyValuePair <string, string>("RatePlan", RatePlan.ToString())); } if (Status != null) { p.Add(new KeyValuePair <string, string>("Status", Status.ToString())); } if (CommandsCallbackMethod != null) { p.Add(new KeyValuePair <string, string>("CommandsCallbackMethod", CommandsCallbackMethod.ToString())); } if (CommandsCallbackUrl != null) { p.Add(new KeyValuePair <string, string>("CommandsCallbackUrl", CommandsCallbackUrl.AbsoluteUri)); } if (SmsFallbackMethod != null) { p.Add(new KeyValuePair <string, string>("SmsFallbackMethod", SmsFallbackMethod.ToString())); } if (SmsFallbackUrl != null) { p.Add(new KeyValuePair <string, string>("SmsFallbackUrl", SmsFallbackUrl.AbsoluteUri)); } if (SmsMethod != null) { p.Add(new KeyValuePair <string, string>("SmsMethod", SmsMethod.ToString())); } if (SmsUrl != null) { p.Add(new KeyValuePair <string, string>("SmsUrl", SmsUrl.AbsoluteUri)); } if (VoiceFallbackMethod != null) { p.Add(new KeyValuePair <string, string>("VoiceFallbackMethod", VoiceFallbackMethod.ToString())); } if (VoiceFallbackUrl != null) { p.Add(new KeyValuePair <string, string>("VoiceFallbackUrl", VoiceFallbackUrl.AbsoluteUri)); } if (VoiceMethod != null) { p.Add(new KeyValuePair <string, string>("VoiceMethod", VoiceMethod.ToString())); } if (VoiceUrl != null) { p.Add(new KeyValuePair <string, string>("VoiceUrl", VoiceUrl.AbsoluteUri)); } return(p); }
public void InvokeServiceMethod(ReignScores_ServiceTypes type, string method, CallbackMethod callback, MonoBehaviour services, params string[] args) { if (callback != null) { string url = string.Format("{0}{1}/{2}.cshtml", reignScoresURL, convertType(type), method); Debug.Log("Invoking URL: " + url); services.StartCoroutine(invokeWebMethod(convertAPI_Key(type), url, callback, args)); } }
private IEnumerator invokeWebMethod(string api_key, string url, CallbackMethod callback, params string[] args) { ProcessingCanvas.SetActive(true); // add form data var form = new WWWForm(); form.AddField("api_key", api_key); foreach (var arg in args) { var values = arg.Split('='); form.AddField(values[0], values[1]); } // invoke http method var www = new WWW(url, form); yield return www; // check for server errors if (!string.IsNullOrEmpty(www.error)) { Debug.LogError(www.error); callback(false, null); ProcessingCanvas.SetActive(false); yield break; } // process response var response = generateResponse(www.text); if (response != null) { if (response.Type == XML.ResponseTypes.Error) { Debug.LogError("Failed: " + response.ErrorMessage); callback(false, null); ProcessingCanvas.SetActive(false); yield break; } callback(true, response); } else { Debug.LogError("response is null"); callback(false, null); ProcessingCanvas.SetActive(false); yield break; } ProcessingCanvas.SetActive(false); }
public static void Show(MessageBoxManager messageBox, CallbackMethod callback) { MessageBoxManager.callback = callback; messageBox.gameObject.SetActive(true); }
//Fires the code on the next update/fixed update. Lazy way to keep the code from affecting what you're doing right now /// <summary> /// Calls the specified code on the next Update(). /// </summary> /// <param name="code">The function to call.</param> /// <param name="callingScript">The <see cref="MonoBehaviour"/> to run the Coroutine on.</param> /// <param name="mode">The time mode to run the Coroutine with.</param> /// <returns></returns> public static Coroutine FireForUpdate(this CallbackMethod code, MonoBehaviour callingScript, Mode mode = Mode.UPDATE) { return(RunIfActiveAndEnabled(callingScript, Routines.FireForUpdateRoutine(code, mode))); }
/// <summary> /// Executes the code after the Coroutine has finished. /// </summary> /// <param name="toFollow">The Coroutine to wait for.</param> /// <param name="code">The Code to execute after the Coroutine has finished.</param> /// <param name="callingScript">The <see cref="MonoBehaviour"/> to run the Coroutine on.</param> /// <returns></returns> public static Coroutine FollowedBy(this Coroutine toFollow, CallbackMethod code, MonoBehaviour callingScript) { return RunIfActiveAndEnabled(callingScript, Routines.WaitForRoutine(toFollow, code)); }
/// <summary> /// Executes the code after the Coroutine has finished. /// </summary> /// <param name="waitFor">The Coroutine to wait for.</param> /// <param name="code">The Code to execute after the Coroutine has finished</param> /// <returns></returns> public static IEnumerator WaitForRoutine(Coroutine waitFor, CallbackMethod code) { yield return waitFor; code(); }
public void Init(CallbackMethod del, Bounds bounds) { octree = new APAOctree(bounds, octreeDepth); StartCoroutine(PopulateOctree(del)); }
/// <summary> /// Executes the code after the Coroutine has finished. /// </summary> /// <param name="waitFor">The Coroutine to wait for.</param> /// <param name="code">The Code to execute after the Coroutine has finished</param> /// <returns></returns> public static IEnumerator WaitForRoutine(Coroutine waitFor, CallbackMethod code) { yield return(waitFor); code(); }
/// <summary> /// Executes the code after the Coroutine has finished. /// </summary> /// <param name="toFollow">The Coroutine to wait for.</param> /// <param name="code">The Code to execute after the Coroutine has finished.</param> /// <param name="callingScript">The <see cref="MonoBehaviour"/> to run the Coroutine on.</param> /// <returns></returns> public static Coroutine FollowedBy(this Coroutine toFollow, CallbackMethod code, MonoBehaviour callingScript) { return(RunIfActiveAndEnabled(callingScript, Routines.WaitForRoutine(toFollow, code))); }
//wrappers for the routines in the Routines class so that we don't need to call StartCoroutine() /// <summary> /// Calls the specified code after the specified time has passed. /// </summary> /// <param name="code">The function to call.</param> /// <param name="time">The amount of time to wait before calling the code.</param> /// <param name="callingScript">The <see cref="MonoBehaviour"/> to run the Coroutine on.</param> /// <param name="mode">The time mode to run the Coroutine with.</param> /// <returns></returns> public static Coroutine FireAndForget(this CallbackMethod code, float time, MonoBehaviour callingScript, Mode mode = Mode.UPDATE) { return(RunIfActiveAndEnabled(callingScript, Routines.FireAndForgetRoutine(code, time, callingScript, mode))); }
// Конструктор получает входную информацию и настраивает callback delegate. public WorkThreadCallBack(string text, int number, CallbackMethod callbackDelegate) { entryInformation = text; value = number; callback = callbackDelegate; }