bool LoadBackend(string type, bool isGuest, bool throwIfFails) { int i = type.IndexOf(','); string assembly = type.Substring(i + 1).Trim(); type = type.Substring(0, i).Trim(); try { Assembly asm = Assembly.Load(assembly); if (asm != null) { Type t = asm.GetType(type); if (t != null) { backend = (ToolkitEngineBackend)Activator.CreateInstance(t); Initialize(isGuest); return(true); } } } catch (Exception ex) { if (throwIfFails) { throw new Exception("Toolkit could not be loaded", ex); } Application.NotifyException(ex); } if (throwIfFails) { throw new Exception("Toolkit could not be loaded"); } return(false); }
/// <summary> /// Exits the user code. /// </summary> /// <param name="error">Exception thrown during user code execution, or <c>null</c></param> internal void ExitUserCode (Exception error) { if (error != null) { Invoke (delegate { Application.NotifyException (error); }); } if (inUserCode == 1 && !exitCallbackRegistered) { while (exitActions.Count > 0) { try { exitActions.Dequeue ()(); } catch (Exception ex) { Invoke (delegate { Application.NotifyException (ex); }); } } } inUserCode--; }