ILoader GetLoader(string path, int priority, ELoaderType loaderType) { for (int i = 0; i < m_AcitveLoaderList.Count; i++) { if (path == m_AcitveLoaderList[i].Url) { return(m_AcitveLoaderList[i]); } } for (int i = 0; i < m_WaitingLoaderList.Count; i++) { if (path == m_WaitingLoaderList[i].Url) { if (m_WaitingLoaderList[i].Priority < priority) { m_WaitingLoaderList[i].Priority = priority; } return(m_WaitingLoaderList[i]); } } ILoader loader = AddNewLoader(loaderType); loader.Init(path, priority); return(loader); }
/// <summary> /// Load header of the module with the best loader /// </summary> /// <param name="module">Module to fill</param> /// <returns>true if success</returns> private bool LoadHeader(SongModule module) { var toReturn = false; _currentLoader = null; foreach (var loader in Loaders) { //Reset the reader _reader.Rewind(); loader.Reader = _reader; if (loader.Test()) { _currentLoader = loader; break; } } // Loader not found... if (null == _currentLoader) { throw new SharpModException(SharpModExceptionResources.ERROR_NOT_A_MODULE); } if (!_uniTrack.UniInit()) { return(false); } _currentLoader.UniTrack = _uniTrack; // init module loader if (_currentLoader.Init(module)) { _reader.Rewind(); toReturn = _currentLoader.Load(); } // free unitrk allocations _uniTrack.UniCleanup(); return(toReturn); }