Esempio n. 1
0
        public async Task PerformHardReloadAsync()
        {
            var shutdownPerformed = false;

            try
            {
                await m_Runtime.ShutdownAsync();

                shutdownPerformed = true;
                m_NuGetPackageManager.ClearCache();

                var bootstrapperAssembly = AppDomain.CurrentDomain.GetAssemblies()
                                           .FirstOrDefault(d => d.GetName().Name.Equals("OpenMod.Unturned.Module.Bootstrapper"));

                var bootstrapperClass = bootstrapperAssembly !.GetType("OpenMod.Unturned.Module.Bootstrapper.BootstrapperModule");
                var instanceProperty  = bootstrapperClass.GetProperty("Instance", BindingFlags.Public | BindingFlags.Static);
                var initializeMethod  = bootstrapperClass.GetMethod("initialize", BindingFlags.Instance | BindingFlags.Public);
                var moduleInstance    = instanceProperty !.GetValue(null);

                initializeMethod !.Invoke(moduleInstance, new object[0]);
            }
            catch (Exception ex)
            {
                if (shutdownPerformed)
                {
                    // fallback to unturned log because our logger is disposed at this point
                    UnturnedLog.exception(ex, "OpenMod has crashed.");
                }

                throw;
            }
        }
Esempio n. 2
0
        public async Task PerformHardReloadAsync()
        {
            var shutdownPerformed = false;

            try
            {
                await m_Runtime.ShutdownAsync();

                shutdownPerformed = true;
                m_NuGetPackageManager.ClearCache();

                BootstrapperModule.Instance !.initialize();
            }
            catch (Exception ex)
            {
                if (shutdownPerformed)
                {
                    // fallback to unturned log because our logger is disposed at this point
                    UnturnedLog.exception(ex, "OpenMod has crashed.");
                }

                throw;
            }
        }