protected void AddFile(TModel item, Stream contents, string filename, Realm realm) { var existing = item.Files.FirstOrDefault(f => string.Equals(f.Filename, filename, StringComparison.OrdinalIgnoreCase)); if (existing != null) { ReplaceFile(existing, contents, realm); return; } var file = realmFileStore.Add(contents, realm); var namedUsage = new RealmNamedFileUsage(file, filename); item.Files.Add(namedUsage); }
private List <RealmNamedFileUsage> createFileInfos(ArchiveReader reader, RealmFileStore files, Realm realm) { var fileInfos = new List <RealmNamedFileUsage>(); // import files to manager foreach (var filenames in getShortenedFilenames(reader)) { using (Stream s = reader.GetStream(filenames.original)) { var item = new RealmNamedFileUsage(files.Add(s, realm), filenames.shortened); fileInfos.Add(item); } } return(fileInfos); }
protected void ReplaceFile(RealmNamedFileUsage file, Stream contents, Realm realm) { file.File = realmFileStore.Add(contents, realm); }
protected void DeleteFile(TModel item, RealmNamedFileUsage file, Realm realm) { item.Files.Remove(file); }
public void ReplaceFile(TModel item, RealmNamedFileUsage file, Stream contents) => performFileOperation(item, managed => ReplaceFile(file, contents, managed.Realm));
public void DeleteFile(TModel item, RealmNamedFileUsage file) => performFileOperation(item, managed => DeleteFile(managed, managed.Files.First(f => f.Filename == file.Filename), managed.Realm));