public void Setup() { _platform = new TestPlatform(); _session = new Session(_platform, "/"); _collectionFile = _session["articles"]; _products = _collectionFile.Collection <Product, Guid>("products", p => p.Id); }
public void Setup() { _platform = new TestPlatform(); _session = new Session(_platform, "/"); _provider = (InMemoryStreamProvider)_session.StreamProvider; _collectionFile = _session["articles"]; _articles = _collectionFile.Collection <Article, int>("articles", a => a.ID); }
public async Task Add(CollectionFile collectionFile) { var entity = _mapper.Map <CollectionFileEntity>(collectionFile); _collectionFileCacheService.AddToFilter(collectionFile.CollectionId, entity.Path); await _roomDbContext.CollectionFiles.AddAsync(entity); }
protected virtual void Dispose(bool disposing) { if (disposing) { database = null; session.Dispose(); } }
public Collection <T, string> GetCollection <T>() where T : IObjectIdentifier { try { var collectionName = $"{typeof(T).Name}s"; return(CollectionFile.Collection <T, string>(collectionName, x => x.Identifier)); } catch (Exception ex) { throw new Exception($"Error getting collection {ex.Message}"); } }
public async Task <Guid> SaveNew( MovedInformation movedInformation, Guid collectionId) { var newFile = new CollectionFile(Guid.NewGuid(), collectionId, movedInformation.MovedFileInfo.FullName, movedInformation.SystemFile.Md5, movedInformation.SystemFile.Size, movedInformation.SystemFile.File.FullName); await _collectionFileRepository.Add(newFile); return(newFile.Id); }
public void Setup() { _platform = new TestPlatform(); _session = new Session(_platform, "/"); _collectionFile = _session["indexables"]; }
public CollectionFile Create( [NotNull] ISMAPlugin requester, int elementId, [NotNull] Action <Stream> streamWriter, string extension, string crc32 = null) { if (elementId <= 0) { return(null); } CollectionFSFile dbFile = null; try { extension = extension?.TrimStart('.'); dbFile = new CollectionFSFile { ElementId = elementId, Extension = extension ?? string.Empty, PluginId = requester.Id }; dbFile.Id = DbFiles.Insert(dbFile).AsInt32; CollectionFile colFile = FromDbFile(dbFile); DirectoryEx.EnsureExists(Path.GetDirectoryName(colFile.Path)); using (var stream = File.Open(colFile.Path, System.IO.FileMode.Create, FileAccess.ReadWrite)) streamWriter(stream); if (crc32 != null) { var fsCrc32 = FileEx.GetCrc32(colFile.Path); if (fsCrc32 != crc32) { throw new IOException($"CRC32 did not match for file {colFile.Path}. Expected {crc32}, got {fsCrc32}"); } } return(colFile); } catch (Exception ex) { LogTo.Error(ex, "CollectionFS: Create threw an exception."); try { if (dbFile != null) { DbFiles.Delete(dbFile.Id); } } catch (Exception dbEx) { LogTo.Error(dbEx, "CollectionFS: Create threw an exception. Exception's DB cleanup code threw an exception"); } throw; } }
public TileManagerDialogButtonClickedEventArgs(CollectionFile <Tile> tileFile, DialogResult dialogResult) : base(dialogResult) { this.tileFile = tileFile; }
public Database(IPlatform platform, string path) { this.platform = platform; session = new Session(platform, path); database = session[SessionName]; }