66
77namespace Umbraco . Cms . Core . Services ;
88
9+ /// <summary>
10+ /// Implements <see cref="IOEmbedService"/> for retrieving embeddable HTML markup using the oEmbed protocol.
11+ /// </summary>
912public class OEmbedService : IOEmbedService
1013{
1114 private readonly EmbedProvidersCollection _embedProvidersCollection ;
1215 private readonly ILogger < OEmbedService > _logger ;
1316
17+ /// <summary>
18+ /// Initializes a new instance of the <see cref="OEmbedService"/> class.
19+ /// </summary>
1420 public OEmbedService ( EmbedProvidersCollection embedProvidersCollection , ILogger < OEmbedService > logger )
1521 {
1622 _embedProvidersCollection = embedProvidersCollection ;
1723 _logger = logger ;
1824 }
1925
26+ /// <inheritdoc/>
2027 public async Task < Attempt < string , OEmbedOperationStatus > > GetMarkupAsync ( Uri url , int ? maxWidth , int ? maxHeight , CancellationToken cancellationToken )
2128 {
2229 // Find the first provider that supports the URL
2330 IEmbedProvider ? matchedProvider = _embedProvidersCollection
24- . FirstOrDefault ( provider => provider . UrlSchemeRegex . Any ( regex=> new Regex ( regex , RegexOptions . IgnoreCase ) . IsMatch ( url . OriginalString ) ) ) ;
31+ . FirstOrDefault ( provider => provider . UrlSchemeRegex
32+ . Any ( regex => new Regex ( regex , RegexOptions . IgnoreCase ) . IsMatch ( url . OriginalString ) ) ) ;
2533
2634 if ( matchedProvider is null )
2735 {
@@ -39,8 +47,8 @@ public async Task<Attempt<string, OEmbedOperationStatus>> GetMarkupAsync(Uri url
3947 }
4048 catch ( Exception e )
4149 {
42- _logger . LogError ( e , "Unexpected exception happened while trying to get oembed markup. Provider: {Provider}" , matchedProvider . GetType ( ) . Name ) ;
43- Attempt . FailWithStatus ( OEmbedOperationStatus . UnexpectedException , string . Empty , e ) ;
50+ _logger . LogError ( e , "Unexpected exception happened while trying to get oEmbed markup. Provider: {Provider}" , matchedProvider . GetType ( ) . Name ) ;
51+ return Attempt . FailWithStatus ( OEmbedOperationStatus . UnexpectedException , string . Empty , e ) ;
4452 }
4553
4654 return Attempt . FailWithStatus ( OEmbedOperationStatus . ProviderReturnedInvalidResult , string . Empty ) ;
0 commit comments