/// <summary> /// Remove a specific emit protocol. Non-existent emitted protocols are ignored. /// </summary> protected virtual void RemoveEmitProtocol(string protocolName) { if (emitProtocols.Exists(p => p.Protocol == protocolName)) { emitProtocols.Remove(emitProtocols.Single(p => p.Protocol == protocolName)); EmitProtocolsChanged.Fire(this, EventArgs.Empty); } }
/// <summary> /// Add protocol that this receptor emits. /// </summary> protected virtual void AddEmitProtocol(string p, bool processInternalSemanticElements = true) { if (!emitProtocols.Contains(p)) { emitProtocols.Add(p); EmitProtocolsChanged.Fire(this, EventArgs.Empty); // Kludge to allow a receptor to specify that internal semantic elements of a protocol // should not be processed. ThumbnailCreatorReceptor and ThumbnailViewerReceptor are // good use cases for this, as otherwise an infinite loop will occur between the two, // as the creator also would emit the SE "ImageFilename" and the viewer emits "ImageFilename" // as part of the SE's ViewImage and GetImageMetadata if (processInternalSemanticElements) { AddInternalSemanticElements(p); } } }
/// <summary> /// Add the protocol that this receptor emits. Duplicates are ignored. /// </summary> protected virtual void AddEmitProtocol(string protocolName, bool processInternalSemanticElements = true) { // We can encounter the same protocol when we recurse into the internal semantics, so ignore repeats. if (!emitProtocols.Exists(p => p.Protocol == protocolName)) { bool cachedEnableState; cachedEmitProtocolConfig.TryGetValue(protocolName, out cachedEnableState).Else(() => cachedEnableState = true); emitProtocols.Add(new EmittedProtocol() { Protocol = protocolName, Enabled = cachedEnableState }); EmitProtocolsChanged.Fire(this, EventArgs.Empty); // Kludge to allow a receptor to specify that internal semantic elements of a protocol // should not be processed. ThumbnailCreatorReceptor and ThumbnailViewerReceptor are // good use cases for this, as otherwise an infinite loop will occur between the two, // as the creator also would emit the SE "ImageFilename" and the viewer emits "ImageFilename" // as part of the SE's ViewImage and GetImageMetadata if (processInternalSemanticElements) { AddInternalSemanticElements(protocolName); } } }
/// <summary> /// Remove all emit protocols. /// </summary> protected virtual void RemoveEmitProtocols() { emitProtocols.Clear(); EmitProtocolsChanged.Fire(this, EventArgs.Empty); }
/// <summary> /// Remove a specific emit protocol. /// </summary> protected virtual void RemoveEmitProtocol(string p) { emitProtocols.Remove(p); EmitProtocolsChanged.Fire(this, EventArgs.Empty); }