Smartmobili.Cocoa.NSColorList._LoadAvailableColorLists C# (CSharp) Method

_LoadAvailableColorLists() private static method

private static _LoadAvailableColorLists ( NSNotification aNotification ) : void
aNotification NSNotification
return void
        private static void _LoadAvailableColorLists(NSNotification aNotification)
        {
            _colorListLock.Lock();

            /* FIXME ... we should ensure that we get housekeeping notifications */
            if (_availableColorLists != null && aNotification == null)
            {
                // Nothing to do ... already loaded
                _colorListLock.Unlock();
            }
            else
            {
                NSString dir;
                NSString file;
                NSEnumerator e;
                NSFileManager fm = NSFileManager.DefaultManager;
                NSDirectoryEnumerator de;
                NSColorList newList;

                if (_availableColorLists == null)
                {
                    // Create the global array of color lists
                    _availableColorLists = (NSMutableArray)NSMutableArray.Alloc().Init();
                }
                else
                {
                    _availableColorLists.RemoveAllObjects(); ;
                }

                /*
                 * Keep any pre-loaded system color list.
                 */
                if (ThemeColorList != null)
                {
                    _availableColorLists.AddObject(ThemeColorList);
                }

                /*
                 * Load color lists found in standard paths into the array
                 * FIXME: Check exactly where in the directory tree we should scan.
                 */
                e = NSSearchPathForDirectoriesInDomains(
                    NSSearchPathDirectory.NSLibraryDirectory,
                    NSSearchPathDomainMask.NSAllDomainsMask, true).ObjectEnumerator();

                while ((dir = (NSString)e.NextObject()) != null)
                {
                    bool flag = false;

                    dir = dir.StringByAppendingPathComponent(@"Colors");
                    if (!fm.FileExistsAtPath(dir, ref flag) || !flag)
                    {
                        // Only process existing directories
                        continue;
                    }

                    de = fm.EnumeratorAtPath(dir);
                    while ((file = (NSString)de.NextObject()) != null)
                    {
                        if (file.PathExtension().IsEqualToString(@"clr"))
                        {
                            NSString name;

                            name = file.StringByDeletingPathExtension();
                            newList = (NSColorList)NSColorList.Alloc().InitWithName(name, dir.StringByAppendingPathComponent(file));
                            _availableColorLists.AddObject(newList);
                        }
                    }
                }

                if (DefaultSystemColorList != null)
                {
                    _availableColorLists.AddObject(DefaultSystemColorList);
                }
                _colorListLock.Unlock();
            }
        }