示例#1
0
        private static void OnDiscardPluginData(IEnumerable <CorePlugin> oldPlugins)
        {
            oldPlugins = oldPlugins.NotNull().Distinct();
            if (!oldPlugins.Any())
            {
                oldPlugins = null;
            }

            if (DiscardPluginData != null)
            {
                DiscardPluginData(null, EventArgs.Empty);
            }

            // Clean globally cached type values
            availTypeDict.Clear();
            ReflectionHelper.ClearTypeCache();
            Component.ClearTypeCache();

            // Dispose any existing Resources that could reference plugin data
            if (!Scene.Current.IsEmpty)
            {
                Scene.Current.Dispose();
            }
            foreach (Resource r in ContentProvider.EnumeratePluginContent().ToArray())
            {
                ContentProvider.RemoveContent(r.Path);
            }

            // Clean input sources that a disposed Assembly forgot to unregister.
            if (oldPlugins != null)
            {
                foreach (CorePlugin plugin in oldPlugins)
                {
                    CleanInputSources(plugin.PluginAssembly);
                }
            }
            // Clean event bindings that are still linked to the disposed Assembly.
            if (oldPlugins != null)
            {
                foreach (CorePlugin plugin in oldPlugins)
                {
                    CleanEventBindings(plugin.PluginAssembly);
                }
            }
        }
示例#2
0
        private static void pluginManager_PluginsRemoved(object sender, DualityPluginEventArgs e)
        {
            // Clean globally cached type data
            ImageCodec.ClearTypeCache();
            ObjectCreator.ClearTypeCache();
            ReflectionHelper.ClearTypeCache();
            Component.ClearTypeCache();
            Serializer.ClearTypeCache();
            CloneProvider.ClearTypeCache();

            // Clean input sources that a disposed Assembly forgot to unregister.
            foreach (CorePlugin plugin in e.Plugins)
            {
                CleanInputSources(plugin.PluginAssembly);
            }

            // Clean event bindings that are still linked to the disposed Assembly.
            foreach (CorePlugin plugin in e.Plugins)
            {
                CleanEventBindings(plugin.PluginAssembly);
            }
        }