public void ProcessResolvedClipboardTrigger(ResolvedClipboardTrigger result) { if (result.ResolvedType == ResolvedClipboardTriggerType.Invalid || result.ResolvedType == ResolvedClipboardTriggerType.Filtered || result.Object is null) { return; } else if (result.ResolvedType == ResolvedClipboardTriggerType.Created) { if (!_listeners.Any(l => l.IsInterestedIn(result.Object))) { return; } _allCollection.Add(result.Object); if (result.Object.Linked != null) { _linkedCollection.GetOrAdd(result.Object.Linked).Add(result.Object); } } InformListeners(l => l.OnResolvedTrigger(result)); }
public Program GetProgram(string path) { if (!cache.TryGetValue(path, out var program)) { program = new Program(path); cache.Add(program); } return(program); }
protected CollectionManager(Func <T, TKey> keySelector, IEnumerable <T> items) { if (keySelector == null) { throw new ArgumentNullException(nameof(keySelector)); } _collection = new KeyedCollectionFunc <TKey, T>(keySelector); foreach (var item in items) { if (!_collection.Add(item)) { throw new ArgumentException($"A {typeof(T).Name} with key {keySelector(item)} is already added", nameof(items)); } } }