private Role LoadRole(RoleType roleType) { string fileName = Enum.GetName(typeof(RoleType), roleType) + ".xml"; string filePath = Path.Combine(_rolesDirectoryPath, fileName); Role role; if (_diskInputOutputService.FileExists(filePath)) { role = _diskInputOutputService.LoadXmlFile <Role>(filePath); } else { role = new Role { Ids = new List <string>(), Type = roleType }; } _cacheService.SetRole(role, filePath); return(role); }
private void EnsureImageExists(int maxDimension, string sourceFilePath, string destinationFilePath) { if (_diskInputOutputService.FileExists(destinationFilePath)) { return; } lock (GetImageSyncRoot(destinationFilePath)) { if (_diskInputOutputService.FileExists(destinationFilePath)) { return; } _diskInputOutputService.ResizeImage(maxDimension, sourceFilePath, destinationFilePath); } }
private Profile TryLoadProfile(string id) { string filePath = GetFilePath(id); if (!_diskInputOutputService.FileExists(filePath)) { return(null); } var profile = _diskInputOutputService.LoadXmlFile <Profile>(filePath); _cacheService.SetProfile(profile, filePath); return(profile); }