private async Task CheckFactoryAsync(TextClipboardImplementation textImplementation, ILinkedTextContentFactory factory) { foreach (var regex in factory.Regexes) { var matches = regex.Matches(textImplementation.Source); if (matches.Count > 0) { //TODO make matches distinct foreach (Match match in matches) { var content = await factory.Create(textImplementation, regex, match).ConfigureAwait(false); if (content.Model is DataObject dataObject) { await foreach (var implementation in clipboardObjectManager.CreateLinkedImplementationsAsync(dataObject, textImplementation)) { textImplementation.LinkedContent.Add(new LinkedTextContent <ClipboardImplementation>(content.Capture, implementation, content.Kind)); } } else { textImplementation.LinkedContent.Add(content); } } } } }
public override Task <ILinkedTextContent?> Create(TextClipboardImplementation textClipboardImplementation, Regex regex, Match match) { string?path = null; if (ReferenceEquals(urlLinuxRegex, regex)) { path = match.Groups[1].Value; if (match.Groups[2].Value == "$") { path = path[0..1] + ":" + path[2..];
public Task ProvideAsync(TextClipboardImplementation textImplementation) { return(Task.WhenAll(factories.Select(f => Task.Run(() => CheckFactoryAsync(textImplementation, f))))); }
public abstract Task <ILinkedTextContent?> Create(TextClipboardImplementation textClipboardImplementation, Regex regex, Match match);