示例#1
0
        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));
        }
示例#2
0
 public Program GetProgram(string path)
 {
     if (!cache.TryGetValue(path, out var program))
     {
         program = new Program(path);
         cache.Add(program);
     }
     return(program);
 }
示例#3
0
        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));
                }
            }
        }