public File( IDirectoryCache directoryCache, IFileParameters fileParameters, IFactory <IIndexBlockProvider, int, ICommonAccessParameters> indexBlockProviderFactory, IFactory <IIndex <byte>, IIndexBlockProvider, ICommonAccessParameters> indexFactory, IFactory <IBlockStream <byte>, IBlockProvider <byte> > blockStreamFactory) { if (fileParameters == null) { throw new ArgumentNullException(nameof(fileParameters)); } if (indexBlockProviderFactory == null) { throw new ArgumentNullException(nameof(indexBlockProviderFactory)); } if (blockStreamFactory == null) { throw new ArgumentNullException(nameof(blockStreamFactory)); } this.directoryCache = directoryCache ?? throw new ArgumentNullException(nameof(directoryCache)); directoryBlockId = fileParameters.ParentDirectoryBlockId; Size = fileParameters.Size; var provider = indexBlockProviderFactory.Create(fileParameters.BlockId, this.directoryCache); index = indexFactory.Create(provider, directoryCache); blockStream = blockStreamFactory.Create(index); }
void RecursiveFillOutputByAdditionalResourcesDirectory(IDirectoryCache directoryCache, string resourcesPath, Dictionary <string, object> filesContent) { Owner.DiskCache.UpdateIfNeeded(directoryCache); foreach (var child in directoryCache) { if (child is IDirectoryCache) { RecursiveFillOutputByAdditionalResourcesDirectory(child as IDirectoryCache, resourcesPath, filesContent); } if (child.IsInvalid) { continue; } var outPathFileName = PathUtils.Subtract(child.FullPath, resourcesPath); TakenNames.Add(outPathFileName); if (child is IFileCache) { filesContent[outPathFileName] = new Lazy <object>(() => { return((child as IFileCache).ByteContent); }); } } }
void RecursiveFileSearch(IDirectoryCache owner, IDiskCache diskCache, Regex fileRegex, List <string> res) { diskCache.UpdateIfNeeded(owner); if (owner.IsInvalid) { return; } foreach (var item in owner) { if (item is IDirectoryCache) { if (item.Name == "node_modules") { continue; } if (item.IsInvalid) { continue; } RecursiveFileSearch(item as IDirectoryCache, diskCache, fileRegex, res); } else if (item is IFileCache && !item.IsVirtual) { if (fileRegex.IsMatch(item.Name)) { res.Add(item.FullPath); } } } }
void RecursiveAddFilesContent(IDirectoryCache directory, RefDictionary <string, object> filesContent, HashSet <string> takenNames, string destDir) { DiskCache.UpdateIfNeeded(directory); foreach (var child in directory) { if (child.IsInvalid) { continue; } var outPathFileName = destDir + "/" + child.Name; takenNames.Add(outPathFileName); if (child is IDirectoryCache) { RecursiveAddFilesContent(child as IDirectoryCache, filesContent, takenNames, outPathFileName); continue; } if (child is IFileCache) { filesContent.GetOrAddValueRef(outPathFileName) = new Lazy <object>(() => { var res = ((IFileCache)child).ByteContent; ((IFileCache)child).FreeCache(); return(res); }); } } }
public static TSProject FindInfoForModule(IDirectoryCache projectDir, IDirectoryCache dir, IDiskCache diskCache, ILogger logger, string moduleName, out string diskName) { if (projectDir.TryGetChildNoVirtual("node_modules") is IDirectoryCache pnmdir) { diskCache.UpdateIfNeeded(pnmdir); if (pnmdir.TryGetChild(moduleName, true) is IDirectoryCache mdir) { diskName = mdir.Name; diskCache.UpdateIfNeeded(mdir); return(Get(mdir, diskCache, logger, diskName)); } } while (dir != null) { if (diskCache.TryGetItem(PathUtils.Join(dir.FullPath, "node_modules")) is IDirectoryCache nmdir) { diskCache.UpdateIfNeeded(nmdir); if (nmdir.TryGetChild(moduleName, true) is IDirectoryCache mdir) { diskName = mdir.Name; diskCache.UpdateIfNeeded(mdir); return(Get(mdir, diskCache, logger, diskName)); } } dir = dir.Parent; } diskName = null; return(null); }
/// <summary> /// See interface docs. /// </summary> /// <param name="directoryCache"></param> /// <param name="icao24"></param> /// <param name="registration"></param> /// <param name="existingDetail"></param> /// <returns></returns> public PictureDetail FindPicture(IDirectoryCache directoryCache, string icao24, string registration, PictureDetail existingDetail) { var result = existingDetail; if (existingDetail == null) { result = FindPicture(directoryCache, icao24, registration); } else { var fileName = GetImageFileName(directoryCache, icao24, registration); if (String.IsNullOrEmpty(fileName)) { result = null; } else { var fileInfo = new FileInfo(fileName); if (fileInfo == null) { result = null; } else if (fileInfo.LastWriteTimeUtc != existingDetail.LastModifiedTime || fileInfo.Length != existingDetail.Length) { result = FindPicture(directoryCache, icao24, registration); } } } return(result); }
void RecursiveFillOutputByAdditionalResourcesDirectory(IDirectoryCache directoryCache, string resourcesPath, RefDictionary <string, object> filesContent, BuildResult buildResult) { Owner.DiskCache.UpdateIfNeeded(directoryCache); foreach (var child in directoryCache) { if (child is IDirectoryCache) { RecursiveFillOutputByAdditionalResourcesDirectory(child as IDirectoryCache, resourcesPath, filesContent, buildResult); continue; } if (child.IsInvalid) { continue; } var outPathFileName = PathUtils.Subtract(child.FullPath, resourcesPath); buildResult.TakenNames.Add(outPathFileName); if (child is IFileCache) { filesContent.GetOrAddValueRef(outPathFileName) = new Lazy <object>(() => { var res = ((IFileCache)child).ByteContent; ((IFileCache)child).FreeCache(); return(res); }); } } }
/// <summary> /// Gets the filename of the aircraft's picture, if any. /// </summary> /// <param name="directoryCache"></param> /// <param name="icao24"></param> /// <param name="registration"></param> /// <returns></returns> private string GetImageFileName(IDirectoryCache directoryCache, string icao24, string registration) { string result = null; if (!String.IsNullOrEmpty(icao24)) { result = SearchForPicture(directoryCache, icao24, "jpg") ?? SearchForPicture(directoryCache, icao24, "jpeg") ?? SearchForPicture(directoryCache, icao24, "png") ?? SearchForPicture(directoryCache, icao24, "gif") ?? SearchForPicture(directoryCache, icao24, "bmp"); } if (result == null && !String.IsNullOrEmpty(registration)) { var icaoCompliantRegistration = Describe.IcaoCompliantRegistration(registration); result = SearchForPicture(directoryCache, icaoCompliantRegistration, "jpg") ?? SearchForPicture(directoryCache, icaoCompliantRegistration, "jpeg") ?? SearchForPicture(directoryCache, icaoCompliantRegistration, "png") ?? SearchForPicture(directoryCache, icaoCompliantRegistration, "gif") ?? SearchForPicture(directoryCache, icaoCompliantRegistration, "bmp"); } return(result); }
/// <summary> /// See interface docs. /// </summary> /// <param name="directoryCache"></param> /// <param name="icao24"></param> /// <param name="registration"></param> /// <returns></returns> public PictureDetail FindPicture(IDirectoryCache directoryCache, string icao24, string registration) { PictureDetail result = null; var fileName = GetImageFileName(directoryCache, icao24, registration); if (!String.IsNullOrEmpty(fileName)) { var fileInfo = new FileInfo(fileName); if (fileInfo != null) { var imageDimensionsFetcher = Factory.Singleton.Resolve <IImageDimensionsFetcher>(); var size = imageDimensionsFetcher.ReadDimensions(fileName); result = new PictureDetail() { FileName = fileName, Width = size.Width, Height = size.Height, LastModifiedTime = fileInfo.LastWriteTimeUtc, Length = fileInfo.Length, }; } } return(result); }
void RunYarnWithParam(IDirectoryCache projectDirectory, string param) { var fullPath = projectDirectory.FullPath; var project = TSProject.Get(projectDirectory, _diskCache, _logger, null); project.LoadProjectJson(true); if (project.ProjectOptions.NpmRegistry != null) { if (!(projectDirectory.TryGetChildNoVirtual(".npmrc") is IFileCache)) { File.WriteAllText(PathUtils.Join(fullPath, ".npmrc"), "registry =" + project.ProjectOptions.NpmRegistry); } } var par = param; par += " --no-emoji --non-interactive"; if (!string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("BBCoreNoLinks"))) { par += " --no-bin-links"; } RunYarn(fullPath, par); }
public void TestInitialise() { _ClassFactorySnapshot = Factory.TakeSnapshot(); CreateBackgroundWorkerMock(); _HeartbeatService = TestUtilities.CreateMockSingleton <IHeartbeatService>(); _Log = TestUtilities.CreateMockSingleton <ILog>(); _Log.Setup(g => g.WriteLine(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())).Callback(() => { throw new InvalidOperationException("Log was unexpectedly written"); }); _CacheChangedEvent = new EventRecorder <EventArgs>(); _Now = new DateTime(2001, 2, 3, 4, 5, 6, 789); _LastModifiedUtc = new DateTime(2009, 8, 7, 6, 5, 4, 321); _Files = new List <TestFileInfo>(); _Provider = new Mock <IDirectoryCacheProvider>() { DefaultValue = DefaultValue.Mock }.SetupAllProperties(); _Provider.Setup(p => p.FolderExists(It.IsAny <string>())).Returns(true); _Provider.Setup(p => p.UtcNow).Returns(() => { return(_Now); }); _Provider.Setup(p => p.GetFilesInFolder(It.IsAny <string>())).Returns(new List <TestFileInfo>()); _DirectoryCache = Factory.Singleton.Resolve <IDirectoryCache>(); _DirectoryCache.Provider = _Provider.Object; }
/// <summary> /// See base docs. /// </summary> protected override void DoInitialise() { _AutoConfigDatabase = Factory.Singleton.Resolve <IAutoConfigBaseStationDatabase>().Singleton; _AutoConfigDatabase.Database.AircraftUpdated += BaseStationDatabase_AircraftUpdated; _AutoConfigDatabase.Database.FileNameChanged += BaseStationDatabase_FileNameChanged; _AircraftOnlineLookupManager = Factory.Singleton.Resolve <IAircraftOnlineLookupManager>().Singleton; _AircraftOnlineLookupManager.AircraftFetched += AircraftOnlineLookupManager_AircraftFetched; _PictureManager = Factory.Singleton.Resolve <IAircraftPictureManager>().Singleton; var autoConfigurationPictureFolderCache = Factory.Singleton.Resolve <IAutoConfigPictureFolderCache>().Singleton; _PictureFolderCache = autoConfigurationPictureFolderCache.DirectoryCache; autoConfigurationPictureFolderCache.CacheConfigurationChanged += AutoConfigPictureFolderCache_CacheConfigurationChanged; _StandingDataManager = Factory.Singleton.Resolve <IStandingDataManager>().Singleton; _StandingDataManager.LoadCompleted += StandingDataManager_LoadCompleted; if (_PictureLookupThread == null) { _PictureLookupThread = new BackgroundThreadQueue <LookupPictureDetail>("PictureLookup", BackgroundThreadQueueMechanism.ThreadPool); _PictureLookupThread.MaximumParallelThreads = 10; _PictureLookupThread.StartBackgroundThread(PictureLookupThread_ProcessLookup, PictureLookupThread_ProcessException); } base.DoInitialise(); }
void RecursiveAddFilesContent(IDirectoryCache directory, MainBuildResult buildResult, string destDir) { DiskCache.UpdateIfNeeded(directory); foreach (var child in directory) { if (child.IsInvalid) { continue; } var outPathFileName = (destDir != "" ? destDir + "/" : "") + child.Name; buildResult.TakenNames.Add(outPathFileName); if (child is IDirectoryCache) { RecursiveAddFilesContent(child as IDirectoryCache, buildResult, outPathFileName); continue; } if (child is IFileCache) { buildResult.FilesContent.GetOrAddValueRef(outPathFileName) = new Lazy <object>(() => { var res = ((IFileCache)child).ByteContent; ((IFileCache)child).FreeCache(); return(res); }); } } }
public void UpgradeAll(IDirectoryCache projectDirectory) { _diskCache.UpdateIfNeeded(projectDirectory); File.Delete(PathUtils.Join(projectDirectory.FullPath, "package-lock.json")); var dirToDelete = projectDirectory.TryGetChild("node_modules") as IDirectoryCache; RecursiveDelete(dirToDelete); Install(projectDirectory); }
public void UpgradeAll(IDirectoryCache projectDirectory) { if (!IsUsedInProject(projectDirectory)) { Install(projectDirectory); return; } RunYarnWithParam(projectDirectory, "upgrade"); }
public IEnumerable <PackagePathVersion> GetLockedDependencies(IDirectoryCache projectDirectory) { var yarnLockFile = projectDirectory.TryGetChildNoVirtual("yarn.lock") as IFileCache; if (yarnLockFile == null) { return(Enumerable.Empty <PackagePathVersion>()); } return(ParseYarnLock(projectDirectory, yarnLockFile.Utf8Content)); }
/// <summary> /// See interface docs. /// </summary> public void Initialise() { if (DirectoryCache == null) { DirectoryCache = Factory.Singleton.Resolve <IDirectoryCache>(); LoadConfiguration(); var configStorage = Factory.Singleton.ResolveSingleton <IConfigurationStorage>(); configStorage.ConfigurationChanged += ConfigurationStorage_ConfigurationChanged; } }
public void Dispose() { if (directoryCache == null || file == null) { return; } isDisposed = true; directoryCache.UnRegisterFile(file.BlockId); directoryCache = null; file = null; }
/// <summary> /// See interface docs. /// </summary> /// <param name="directoryCache"></param> /// <param name="icao24"></param> /// <param name="registration"></param> /// <returns></returns> public Image LoadPicture(IDirectoryCache directoryCache, string icao24, string registration) { Image result = null; var fileName = GetImageFileName(directoryCache, icao24, registration); if (!String.IsNullOrEmpty(fileName)) { result = LoadImage(fileName); } return(result); }
public DirectoryEntry( IDirectoryCache directoryCache, IDirectory directory, bool unRegisterDirectoryOnDispose, IFactory <IDirectoryEntry, IDirectoryCache, IDirectory, bool> directoryFactory, IFactory <IFileEntry, IDirectoryCache, IFile> fileFactory) { this.directoryCache = directoryCache ?? throw new ArgumentNullException(nameof(directoryCache)); this.directory = directory ?? throw new ArgumentNullException(nameof(directory)); this.unRegisterDirectoryOnDispose = unRegisterDirectoryOnDispose; this.directoryFactory = directoryFactory ?? throw new ArgumentNullException(nameof(directoryFactory)); this.fileFactory = fileFactory ?? throw new ArgumentNullException(nameof(fileFactory)); }
public UnsafeDirectoryReader( IDirectoryCache directoryCache, IFactory <IIndexBlockProvider, int, ICommonAccessParameters> indexBlockProviderFactory, IFactory <IIndex <DirectoryItem>, IIndexBlockProvider, ICommonAccessParameters> directoryIndexFactory, IFactory <IUnsafeDirectory, IIndex <DirectoryItem>, IDirectoryCache, DirectoryHeader> directoryFactory, IFactory <IBlockStream <DirectoryItem>, IBlockProvider <DirectoryItem> > directoryBlockStreamFactory) { this.directoryCache = directoryCache ?? throw new ArgumentNullException(nameof(directoryCache)); this.indexBlockProviderFactory = indexBlockProviderFactory ?? throw new ArgumentNullException(nameof(indexBlockProviderFactory)); this.directoryIndexFactory = directoryIndexFactory ?? throw new ArgumentNullException(nameof(directoryIndexFactory)); this.directoryFactory = directoryFactory ?? throw new ArgumentNullException(nameof(directoryFactory)); this.directoryBlockStreamFactory = directoryBlockStreamFactory ?? throw new ArgumentNullException(nameof(directoryBlockStreamFactory)); }
public DeletionDirectory( IDirectoryCache directoryCache, int blockId, IFactory <IUnsafeDirectoryReader, IDirectoryCache> unsafeDirectoryReaderFactory) { this.directoryCache = directoryCache ?? throw new ArgumentNullException(nameof(directoryCache)); if (blockId < 0) { throw new ArgumentOutOfRangeException(nameof(blockId)); } BlockId = blockId; unsafeDirectoryReader = unsafeDirectoryReaderFactory.Create(directoryCache); }
void RecursiveDelete(IDirectoryCache dirToDelete) { if (dirToDelete == null) { return; } _diskCache.UpdateIfNeeded(dirToDelete); foreach (var item in dirToDelete) { if (item is IFileCache) { try { File.Delete(item.FullPath); } catch (Exception) { // ignored } continue; } var dir = item as IDirectoryCache; if (dir != null && dir.IsLink) { try { Directory.Delete(dir.FullPath, false); } catch (Exception) { // ignored } } RecursiveDelete(dir); } try { Directory.Delete(dirToDelete.FullPath, true); } catch (Exception) { // ignored } }
static bool IsExampleOrSpecDir(IDirectoryCache rootProjectDir, IDirectoryCache?dir) { while (dir != null) { if (IsExampleOrSpecDir(dir.Name)) { return(true); } dir = dir.Parent; if (dir == rootProjectDir) { break; } } return(false); }
public static TSProject Get(IDirectoryCache dir, IDiskCache diskCache, ILogger logger) { if (dir == null) { return(null); } if (dir.AdditionalInfo == null) { dir.AdditionalInfo = new TSProject { Owner = dir, DiskCache = diskCache, Logger = logger } } ; return((TSProject)dir.AdditionalInfo); } }
public Directory( IIndex <DirectoryItem> index, IDirectoryCache directoryCache, DirectoryHeader header, IFactory <IIndexBlockProvider, int, ICommonAccessParameters> indexBlockProviderFactory, IFactory <IIndex <short>, IIndexBlockProvider, ICommonAccessParameters> indexFactory, IFactory <IBlockStream <short>, IBlockProvider <short> > blockStreamFactory, IFactory <IIndex <DirectoryItem>, IIndexBlockProvider, ICommonAccessParameters> directoryIndexFactory, IFactory <IDirectory, IIndex <DirectoryItem>, IDirectoryCache, DirectoryHeader> directoryFactory, IFactory <IFile, IFileParameters, IDirectoryCache> fileFactory, IFactory <IBlockStream <DirectoryItem>, IBlockProvider <DirectoryItem> > directoryBlockStreamFactory, IFactory <IDeletionFile, IFileParameters, IDirectoryCache> deletionFileFactory, IFactory <IDeletionDirectory, int, IDirectoryCache> deletionDirectoryFactory ) { if (indexFactory == null) { throw new ArgumentNullException(nameof(indexFactory)); } if (directoryBlockStreamFactory == null) { throw new ArgumentNullException(nameof(directoryBlockStreamFactory)); } this.index = index ?? throw new ArgumentNullException(nameof(index)); this.directoryCache = directoryCache ?? throw new ArgumentNullException(nameof(directoryCache)); this.indexBlockProviderFactory = indexBlockProviderFactory ?? throw new ArgumentNullException(nameof(indexBlockProviderFactory)); this.directoryIndexFactory = directoryIndexFactory ?? throw new ArgumentNullException(nameof(directoryIndexFactory)); this.directoryFactory = directoryFactory ?? throw new ArgumentNullException(nameof(directoryFactory)); this.fileFactory = fileFactory ?? throw new ArgumentNullException(nameof(fileFactory)); this.deletionFileFactory = deletionFileFactory ?? throw new ArgumentNullException(nameof(deletionFileFactory)); this.deletionDirectoryFactory = deletionDirectoryFactory ?? throw new ArgumentNullException(nameof(deletionDirectoryFactory)); blockStream = directoryBlockStreamFactory.Create(index); nameBlockIndex = header.NameBlockIndex; var nameIndexProvider = indexBlockProviderFactory.Create(nameBlockIndex, directoryCache); nameIndex = indexFactory.Create(nameIndexProvider, directoryCache); nameIndexBlockStream = blockStreamFactory.Create(nameIndex); firstEmptyItemOffset = header.FirstEmptyItemOffset; itemsCount = header.ItemsCount; lastNameOffset = header.LastNameOffset; parentDirectoryBlockId = header.ParentDirectoryBlockIndex; }
public void SetUp() { directoryCache = Mock.Of <IDirectoryCache>(); rootDirectory = Mock.Of <IDirectory>(); provider = new Mock <IFileSystemProvider>(); provider.SetupGet(x => x.DirectoryCache).Returns(directoryCache); provider.SetupGet(x => x.RootDirectory).Returns(rootDirectory); providerFactory = new Mock <IFactory <IFileSystemProvider> >(); providerFactory.Setup(x => x.Create()).Returns(provider.Object); directory = new Mock <IDirectoryEntry>(); directoryFactory = new Mock <IFactory <IDirectoryEntry, IDirectoryCache, IDirectory, bool> >(); directoryFactory.Setup(x => x.Create(It.IsAny <IDirectoryCache>(), It.IsAny <IDirectory>(), It.IsAny <bool>())) .Returns(directory.Object); }
IDictionary <string, object> InspectAssets(IDirectoryCache rootDir, string srcPath) { _cache.UpdateIfNeeded(rootDir); var assetsMap = new Dictionary <string, object>(); var assetsFiles = rootDir.ToList(); foreach (var assetFile in assetsFiles) { if (assetFile is IDirectoryCache dir) { assetsMap[SanitizeKey(dir.Name)] = InspectAssets(dir, srcPath); } else { assetsMap[SanitizeKey(PathUtils.ExtractQuality(assetFile.Name).Name)] = PathUtils.Subtract(PathUtils.ExtractQuality(assetFile.FullPath).Name, srcPath); } } return(assetsMap); }
public static TSProject Get(IDirectoryCache dir, IDiskCache diskCache, ILogger logger, string diskName) { if (dir == null) { return(null); } if (dir.AdditionalInfo == null) { var proj = new TSProject { Owner = dir, DiskCache = diskCache, Logger = logger, Name = diskName, ProjectOptions = new ProjectOptions() }; proj.ProjectOptions.Owner = proj; dir.AdditionalInfo = proj; } return((TSProject)dir.AdditionalInfo); }
public void Dispose() { if (directory == null || directoryCache == null) { return; } isDisposed = true; directory?.Flush(); if (unRegisterDirectoryOnDispose) { directoryCache?.UnRegisterDirectory(directory.BlockId); } directoryCache = null; directory = null; }
/// <summary> /// See interface docs. /// </summary> /// <param name="directoryCache"></param> /// <param name="icao24"></param> /// <param name="registration"></param> /// <returns></returns> public string FindPicture(IDirectoryCache directoryCache, string icao24, string registration) { string result = null; if(!String.IsNullOrEmpty(icao24)) { result = SearchForPicture(directoryCache, icao24, "jpg") ?? SearchForPicture(directoryCache, icao24, "jpeg") ?? SearchForPicture(directoryCache, icao24, "png") ?? SearchForPicture(directoryCache, icao24, "bmp"); } if(result == null && !String.IsNullOrEmpty(registration)) { var icaoCompliantRegistration = Describe.IcaoCompliantRegistration(registration); result = SearchForPicture(directoryCache, icaoCompliantRegistration, "jpg") ?? SearchForPicture(directoryCache, icaoCompliantRegistration, "jpeg") ?? SearchForPicture(directoryCache, icaoCompliantRegistration, "png") ?? SearchForPicture(directoryCache, icaoCompliantRegistration, "bmp"); } return result; }
public void TestInitialise() { _ClassFactorySnapshot = Factory.TakeSnapshot(); CreateBackgroundWorkerMock(); _HeartbeatService = TestUtilities.CreateMockSingleton<IHeartbeatService>(); _Log = TestUtilities.CreateMockSingleton<ILog>(); _Log.Setup(g => g.WriteLine(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>())).Callback(() => { throw new InvalidOperationException("Log was unexpectedly written"); }); _CacheChangedEvent = new EventRecorder<EventArgs>(); _Now = new DateTime(2001, 2, 3, 4, 5, 6, 789); _LastModifiedUtc = new DateTime(2009, 8, 7, 6, 5, 4, 321); _Files = new List<TestFileInfo>(); _Provider = new Mock<IDirectoryCacheProvider>() { DefaultValue = DefaultValue.Mock }.SetupAllProperties(); _Provider.Setup(p => p.FolderExists(It.IsAny<string>())).Returns(true); _Provider.Setup(p => p.UtcNow).Returns(() => { return _Now; }); _Provider.Setup(p => p.GetFilesInFolder(It.IsAny<string>())).Returns(new List<TestFileInfo>()); _DirectoryCache = Factory.Singleton.Resolve<IDirectoryCache>(); _DirectoryCache.Provider = _Provider.Object; }
/// <summary> /// Creates a new object. /// </summary> public ImagePage() { _PictureManager = Factory.Singleton.Resolve<IAircraftPictureManager>().Singleton; _PictureFolderCache = Factory.Singleton.Resolve<IAutoConfigPictureFolderCache>().Singleton.DirectoryCache; _ForceSingleThreadAccess = Factory.Singleton.Resolve<IRuntimeEnvironment>().Singleton.IsMono; }
/// <summary> /// Creates a new object. /// </summary> public ReportRowsJsonPage() : base() { _PictureManager = Factory.Singleton.Resolve<IAircraftPictureManager>().Singleton; _PictureFolderCache = Factory.Singleton.Resolve<IAutoConfigPictureFolderCache>().Singleton.DirectoryCache; }
/// <summary> /// Creates a new object. /// </summary> public BaseStationAircraftList() { Provider = new DefaultProvider(); _PictureManager = Factory.Singleton.Resolve<IAircraftPictureManager>().Singleton; _PictureDirectoryCache = Factory.Singleton.Resolve<IAutoConfigPictureFolderCache>().Singleton.DirectoryCache; _PictureDirectoryCache.CacheChanged += PictureDirectoryCache_CacheChanged; _PictureLookupQueue.StartBackgroundThread(SearchForPicture, (ex) => { OnExceptionCaught(new EventArgs<Exception>(ex)); }); _DatabaseLookupQueue.StartBackgroundThread(LoadAircraftDetails, (ex) => { OnExceptionCaught(new EventArgs<Exception>(ex)); }); }
/// <summary> /// Finalises or disposes of the object. Note that this class is sealed. /// </summary> /// <param name="disposing"></param> private void Dispose(bool disposing) { if(disposing) { if(_Port30003Listener != null) _Port30003Listener.Port30003MessageReceived -= BaseStationListener_MessageReceived; if(_PictureLookupQueue != null) _PictureLookupQueue.Dispose(); if(_DatabaseLookupQueue != null) _DatabaseLookupQueue.Dispose(); if(_PictureDirectoryCache != null) { _PictureDirectoryCache.CacheChanged -= PictureDirectoryCache_CacheChanged; _PictureDirectoryCache = null; } } }
/// <summary> /// Returns the full path to the file if the file exists or null if it does not. /// </summary> /// <param name="directoryCache"></param> /// <param name="fileName"></param> /// <param name="extension"></param> /// <returns></returns> private string SearchForPicture(IDirectoryCache directoryCache, string fileName, string extension) { var fullPath = Path.Combine(directoryCache.Folder ?? "", String.Format("{0}.{1}", fileName, extension)); return directoryCache.FileExists(fullPath) ? fullPath : null; }