/// <summary> /// Gets the current proxy. /// </summary> /// <returns>ParadoxCommandsProxy.</returns> public static ParadoxCommandsProxy GetProxy() { lock (paradoxCommandProxyLock) { // New instance? bool shouldReload = currentInstance == null; if (!shouldReload) { // Assemblies changed? shouldReload = currentInstance.ShouldReload(); } // If new instance or assemblies changed, reload if (shouldReload) { currentInstance = null; if (currentAppDomain != null) { try { AppDomain.Unload(currentAppDomain); } catch (Exception ex) { Trace.WriteLine(string.Format("Unexpected exception when unloading AppDomain for ParadoxCommandsProxy: {0}", ex)); } } currentAppDomain = CreateParadoxDomain(); currentInstance = CreateProxy(currentAppDomain); } return(currentInstance); } }
/// <summary> /// Gets the current proxy. /// </summary> /// <returns>ParadoxCommandsProxy.</returns> public static ParadoxCommandsProxy GetProxy() { lock (paradoxCommandProxyLock) { // New instance? bool shouldReload = currentInstance == null; if (!shouldReload) { // Assemblies changed? shouldReload = currentInstance.ShouldReload(); } // If new instance or assemblies changed, reload if (shouldReload) { currentInstance = null; if (currentAppDomain != null) { try { AppDomain.Unload(currentAppDomain); } catch (Exception ex) { Trace.WriteLine(string.Format("Unexpected exception when unloading AppDomain for ParadoxCommandsProxy: {0}", ex)); } } currentAppDomain = CreateParadoxDomain(); currentInstance = CreateProxy(currentAppDomain); } return currentInstance; } }