Beispiel #1
0
        private ResolvedClipboardTrigger CreateResolvedClipboardTrigger(ClipboardTrigger trigger, IDataObject dataObject)
        {
            // Check if clipboard object already exists in list
            if (dataObject.TryGetWClipboardId(out var guid) && _allCollection.TryGetValue(guid, out var refClipboardObject))
            {
                refClipboardObject.Triggers.Add(trigger);
                return(new ResolvedClipboardTrigger(trigger, refClipboardObject, ResolvedClipboardTriggerType.WClipboardId));
            }

            //Extract Formats
            //TODO retry exceptions
            var equatableFormats = formatsExtractors.SelectMany(fe => fe.Extract(trigger, dataObject)).ToList();

            trigger.AdditionalInfo.Add(new OriginalFormatsInfo(dataObject.GetFormats()));

            //Check if it contains any data
            if (equatableFormats.Count == 0)
            {
                return(new ResolvedClipboardTrigger(trigger, null, ResolvedClipboardTriggerType.Invalid));
            }

            //Filter
            if (ShouldFilter(trigger, equatableFormats))
            {
                return(new ResolvedClipboardTrigger(trigger, null, ResolvedClipboardTriggerType.Filtered));
            }

            //Check for Equals
            return(CheckForEqualsReference(trigger, dataObject, equatableFormats));
        }
Beispiel #2
0
 public Program GetProgram(string path)
 {
     if (!cache.TryGetValue(path, out var program))
     {
         program = new Program(path);
         cache.Add(program);
     }
     return(program);
 }
Beispiel #3
0
 public bool TryGetValue(TKey key, [MaybeNullWhen(false)] out T value)
 {
     return(_collection.TryGetValue(key, out value));
 }