private void OnNewEvent(object sender, IEvent e) { if (e is Created created) { CollectionCreated?.Invoke(sender, created); } }
public BookCollection(string path, CollectionType collectionType, BookSelection bookSelection, TeamCollectionManager tcm = null, BloomWebSocketServer webSocketServer = null) { _path = path; _bookSelection = bookSelection; _tcManager = tcm; _webSocketServer = webSocketServer; Type = collectionType; if (collectionType == CollectionType.TheOneEditableCollection) { MakeCollectionCSSIfMissing(); } CollectionCreated?.Invoke(this, new EventArgs()); if (ContainsDownloadedBooks) { WatchDirectory(); } }
public async Task <BoxSet> CreateCollectionAsync(CollectionCreationOptions options) { var name = options.Name; // Need to use the [boxset] suffix // If internet metadata is not found, or if xml saving is off there will be no collection.xml // This could cause it to get re-resolved as a plain folder var folderName = _fileSystem.GetValidFilename(name) + " [boxset]"; var parentFolder = await GetCollectionsFolder(true).ConfigureAwait(false); if (parentFolder == null) { throw new ArgumentException(); } var path = Path.Combine(parentFolder.Path, folderName); _iLibraryMonitor.ReportFileSystemChangeBeginning(path); try { Directory.CreateDirectory(path); var collection = new BoxSet { Name = name, Path = path, IsLocked = options.IsLocked, ProviderIds = options.ProviderIds, DateCreated = DateTime.UtcNow }; parentFolder.AddChild(collection); if (options.ItemIdList.Count > 0) { await AddToCollectionAsync( collection.Id, options.ItemIdList.Select(x => new Guid(x)), false, new MetadataRefreshOptions(new DirectoryService(_fileSystem)) { // The initial adding of items is going to create a local metadata file // This will cause internet metadata to be skipped as a result MetadataRefreshMode = MetadataRefreshMode.FullRefresh }).ConfigureAwait(false); } else { _providerManager.QueueRefresh(collection.Id, new MetadataRefreshOptions(new DirectoryService(_fileSystem)), RefreshPriority.High); } CollectionCreated?.Invoke(this, new CollectionCreatedEventArgs { Collection = collection, Options = options }); return(collection); } finally { // Refresh handled internally _iLibraryMonitor.ReportFileSystemChangeComplete(path, false); } }
public void Apply(CollectionCreated evt) { Id = evt.AggregateId; }
protected DocumentCollection(string collectionName) { var @event = new CollectionCreated(CombGuid.Generate(), collectionName); RaiseEvent(@event); }