static ApplicationPartManagerExtensions() { //we use the default file provider, since the DI isn't initialized yet _fileProvider = CommonHelper.DefaultFileProvider; _baseAppLibraries = new List <string>(); //get all libraries from /bin/{version}/ directory _baseAppLibraries.AddRange(_fileProvider.GetFiles(AppDomain.CurrentDomain.BaseDirectory, "*.dll") .Select(fileName => _fileProvider.GetFileName(fileName))); //get all libraries from base site directory if (!AppDomain.CurrentDomain.BaseDirectory.Equals(Environment.CurrentDirectory, StringComparison.InvariantCultureIgnoreCase)) { _baseAppLibraries.AddRange(_fileProvider.GetFiles(Environment.CurrentDirectory, "*.dll") .Select(fileName => _fileProvider.GetFileName(fileName))); } //get all libraries from refs directory var refsPathName = _fileProvider.Combine(Environment.CurrentDirectory, SmiPluginDefaults.RefsPathName); if (_fileProvider.DirectoryExists(refsPathName)) { _baseAppLibraries.AddRange(_fileProvider.GetFiles(refsPathName, "*.dll") .Select(fileName => _fileProvider.GetFileName(fileName))); } }
/// <summary> /// Get all themes /// </summary> /// <returns>List of the theme descriptor</returns> public IList <ThemeDescriptor> GetThemes() { if (_themeDescriptors != null) { return(_themeDescriptors); } //load all theme descriptors _themeDescriptors = new List <ThemeDescriptor>(); var themeDirectoryPath = _fileProvider.MapPath(SmiPluginDefaults.ThemesPath); foreach (var descriptionFile in _fileProvider.GetFiles(themeDirectoryPath, SmiPluginDefaults.ThemeDescriptionFileName, false)) { var text = _fileProvider.ReadAllText(descriptionFile, Encoding.UTF8); if (string.IsNullOrEmpty(text)) { continue; } //get theme descriptor var themeDescriptor = GetThemeDescriptorFromText(text); //some validation if (string.IsNullOrEmpty(themeDescriptor?.SystemName)) { throw new Exception($"A theme descriptor '{descriptionFile}' has no system name"); } _themeDescriptors.Add(themeDescriptor); } return(_themeDescriptors); }
/// <summary> /// Delete picture thumbs /// </summary> /// <param name="picture">Picture</param> protected virtual void DeletePictureThumbs(Picture picture) { var filter = $"{picture.Id:0000000}*.*"; var currentFiles = _fileProvider.GetFiles(_fileProvider.GetAbsolutePath(SmiMediaDefaults.ImageThumbsPath), filter, false); foreach (var currentFileName in currentFiles) { var thumbFilePath = GetThumbLocalPath(currentFileName); _fileProvider.DeleteFile(thumbFilePath); } }
/// <summary> /// Gets all backup files /// </summary> /// <returns>Backup file collection</returns> public virtual IList <string> GetAllBackupFiles() { var path = GetBackupDirectoryPath(); if (!_fileProvider.DirectoryExists(path)) { throw new SmiException("Backup directory not exists"); } return(_fileProvider.GetFiles(path, $"*.{SmiCommonDefaults.DbBackupFileExtension}") .OrderByDescending(p => _fileProvider.GetLastWriteTime(p)).ToList()); }
/// <summary> /// Makes sure matching assemblies in the supplied folder are loaded in the app domain. /// </summary> /// <param name="directoryPath"> /// The physical path to a directory containing dlls to load in the app domain. /// </param> protected virtual void LoadMatchingAssemblies(string directoryPath) { var loadedAssemblyNames = new List <string>(); foreach (var a in GetAssemblies()) { loadedAssemblyNames.Add(a.FullName); } if (!_fileProvider.DirectoryExists(directoryPath)) { return; } foreach (var dllPath in _fileProvider.GetFiles(directoryPath, "*.dll")) { try { var an = AssemblyName.GetAssemblyName(dllPath); if (Matches(an.FullName) && !loadedAssemblyNames.Contains(an.FullName)) { App.Load(an); } //old loading stuff //Assembly a = Assembly.ReflectionOnlyLoadFrom(dllPath); //if (Matches(a.FullName) && !loadedAssemblyNames.Contains(a.FullName)) //{ // App.Load(a.FullName); //} } catch (BadImageFormatException ex) { Trace.TraceError(ex.ToString()); } } }