Stetic.Application.NotifyLibraryUnloaded C# (CSharp) Method

NotifyLibraryUnloaded() private method

private NotifyLibraryUnloaded ( string name ) : void
name string
return void
        internal void NotifyLibraryUnloaded(string name)
        {
            // Remove cached types from the unloaded library
            ArrayList toDelete = new ArrayList ();
            lock (types) {
                foreach (ComponentType ct in types.Values) {
                    if (ct.Library == name)
                        toDelete.Add (ct.Name);
                }
                foreach (string s in toDelete)
                    types.Remove (s);
            }
        }

Usage Example

Example #1
0
        public bool UpdateLibraries(ArrayList libraries, ArrayList projects, bool allowBackendRestart, bool forceUnload)
        {
            try {
                Registry.BeginChangeSet();

                libraries.Add(Registry.CoreWidgetLibrary.Name);

                // Notify libraries that need to be unloaded and loaded again

                foreach (WidgetLibrary lib in Registry.RegisteredWidgetLibraries)
                {
                    if (lib.NeedsReload)
                    {
                        appFrontend.NotifyLibraryUnloaded(lib.Name);
                    }
                }

                if (!Registry.ReloadWidgetLibraries() && allowBackendRestart)
                {
                    return(false);
                }

                // Store a list of registered libraries, used later to know which
                // ones need to be unloaded

                ArrayList loaded = new ArrayList();
                foreach (WidgetLibrary alib in Registry.RegisteredWidgetLibraries)
                {
                    loaded.Add(alib.Name);
                }

                // Load required libraries

                Hashtable visited = new Hashtable();
                LoadLibraries(new AssemblyResolver(this), visited, libraries);

                foreach (ProjectBackend project in projects)
                {
                    LoadLibraries(project.Resolver, visited, project.WidgetLibraries);
                }

                // Unload libraries which are not required

                foreach (string name in loaded)
                {
                    if (!visited.Contains(name))
                    {
                        if (forceUnload && allowBackendRestart)
                        {
                            return(false);
                        }
                        appFrontend.NotifyLibraryUnloaded(name);
                        Registry.UnregisterWidgetLibrary(Registry.GetWidgetLibrary(name));
                    }
                }

                return(true);
            }
            finally {
                Registry.EndChangeSet();
            }
        }