[Test] public void RequestContent() { // Create a test resource and save it somewhere to be retrieved later Pixmap resource = new Pixmap(); string path = PathOp.Combine(DualityApp.DataDirectory, "Test" + Resource.GetFileExtByType <Pixmap>()); resource.Save(path, false); resource.Dispose(); resource = null; // Request the resource from its path and expect it to be valid Assert.IsNotNull(ContentProvider.RequestContent <Pixmap>(path).Res); Assert.IsNotNull(ContentProvider.RequestContent(path).Res); Assert.IsTrue(ContentProvider.HasContent(path)); CollectionAssert.Contains(ContentProvider.GetLoadedContent <Pixmap>(), new ContentRef <Pixmap>(null, path)); CollectionAssert.Contains(ContentProvider.GetAvailableContent <Pixmap>(), new ContentRef <Pixmap>(null, path)); // Request the resource multiple times and expect the same instance to be returned ContentRef <Pixmap> requestA = ContentProvider.RequestContent <Pixmap>(path); ContentRef <Pixmap> requestB = ContentProvider.RequestContent <Pixmap>(path); Assert.AreEqual(requestA, requestB); Assert.AreSame(requestA.Res, requestB.Res); // Dispose the resource and expect an automatic reload on access Pixmap oldResource = requestA.Res; oldResource.Dispose(); Assert.IsNotNull(requestA.Res); Assert.IsNotNull(requestB.Res); Assert.AreEqual(requestA, requestB); Assert.AreSame(requestA.Res, requestB.Res); }
public void ImportFile(string srcFile, string targetName, string targetDir) { string[] output = this.GetOutputFiles(srcFile, targetName, targetDir); Pixmap res = new Pixmap(srcFile); res.Save(output[0]); }
public void ImportFile(string srcFile, string targetName, string targetDir) { string[] output = this.GetOutputFiles(srcFile, targetName, targetDir); PixelData pixelData = LoadPixelData(srcFile); Pixmap res = new Pixmap(pixelData); res.SourcePath = srcFile; res.Save(output[0]); }