예제 #1
0
        /// <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);
            }
        }
예제 #2
0
        /// <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;
            }
        }