Esempio n. 1
0
        /// <summary>
        /// Gets the current proxy.
        /// </summary>
        /// <returns>XenkoCommandsProxy.</returns>
        public static XenkoCommandsProxy GetProxy()
        {
            lock (commandProxyLock)
            {
                // New instance?
                bool shouldReload = currentInstance == null || solutionChanged;
                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($"Unexpected exception when unloading AppDomain for XenkoCommandsProxy: {ex}");
                        }
                    }

                    currentAppDomain = CreateXenkoDomain();
                    InitialzeFromSolution(solution, currentAppDomain);
                    currentInstance = CreateProxy(currentAppDomain);
                    currentInstance.Initialize();
                    solutionChanged = false;
                }

                return(currentInstance);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Gets the current proxy.
        /// </summary>
        /// <returns>XenkoCommandsProxy.</returns>
        public static XenkoCommandsProxy GetProxy()
        {
            lock (commandProxyLock)
            {
                // New instance?
                bool shouldReload = currentInstance == null || solutionChanged;
                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 XenkoCommandsProxy: {0}", ex));
                        }
                    }

                    currentAppDomain = CreateXenkoDomain();
                    InitialzeFromSolution(solution, currentAppDomain);
                    currentInstance = CreateProxy(currentAppDomain);
                    currentInstance.Initialize();
                    solutionChanged = false;
                }

                return currentInstance;
            }
        }