Beispiel #1
0
        // Token: 0x060018EB RID: 6379 RVA: 0x0005698C File Offset: 0x00054B8C
        protected override async Task <GetLinkPreviewResponse> InternalExecute()
        {
            GetLinkPreviewResponse getLinkPreviewResponse;

            try
            {
                DataProviderInformation dataProviderInformation = null;
                long elapsedTimeToWebPageStepCompletion         = 0L;
                long elapsedTimeToRegExStepCompletion           = 0L;
                base.CallContext.ProtocolLog.Set(GetLinkPreviewMetadata.Url, this.request.Url);
                if (GetLinkPreview.GetPreviewsDisabled())
                {
                    return(this.CreateDisabledResponse());
                }
                if (Interlocked.Increment(ref GetLinkPreview.getPreviewRequestCount) > GetLinkPreview.getPreviewRequestCountMax)
                {
                    return(this.CreateErrorResponse("MaxConcurrentRequestExceeded", "The maximum number of concurrent requests has been exceeded."));
                }
                bool      activeViewConvergenceEnabled = GetLinkPreview.GetActiveViewsConvergenceFlightEnabled(base.CallContext.ProtocolLog);
                Stopwatch stopwatch = Stopwatch.StartNew();
                LinkPreviewDataProvider dataProvider = null;
                dataProvider            = LinkPreviewDataProvider.GetDataProvider(this.request, base.CallContext.ProtocolLog, activeViewConvergenceEnabled);
                dataProviderInformation = await dataProvider.GetDataProviderInformation();

                elapsedTimeToWebPageStepCompletion = stopwatch.ElapsedMilliseconds;
                getLinkPreviewResponse             = dataProvider.CreatePreview(dataProviderInformation);
                stopwatch.Stop();
                elapsedTimeToRegExStepCompletion = stopwatch.ElapsedMilliseconds;
                getLinkPreviewResponse.ElapsedTimeToWebPageStepCompletion = elapsedTimeToWebPageStepCompletion;
                getLinkPreviewResponse.ElapsedTimeToRegExStepCompletion   = elapsedTimeToRegExStepCompletion;
                getLinkPreviewResponse.WebPageContentLength = dataProvider.ContentLength;
                this.LogWebMethodData(getLinkPreviewResponse);
            }
            catch (OwaPermanentException exception)
            {
                getLinkPreviewResponse = this.CreateErrorResponse(exception);
            }
            catch (LocalizedException exception2)
            {
                getLinkPreviewResponse = this.CreateErrorResponse(exception2);
            }
            catch (HttpRequestException requestException)
            {
                getLinkPreviewResponse = this.CreateErrorResponse(requestException);
            }
            catch (TaskCanceledException)
            {
                getLinkPreviewResponse = this.CreateErrorResponse("RequestTimeout", "The web page request timed out.");
            }
            catch (WebException webException)
            {
                getLinkPreviewResponse = this.CreateErrorResponse(webException);
            }
            finally
            {
                Interlocked.Decrement(ref GetLinkPreview.getPreviewRequestCount);
            }
            return(getLinkPreviewResponse);
        }
Beispiel #2
0
        public override GetLinkPreviewResponse CreatePreview(DataProviderInformation dataProviderInformation)
        {
            OEmbedInformation  oembedInformation = (OEmbedInformation)dataProviderInformation;
            string             text               = oembedInformation.Text;
            OEmbedResponse     oembedResponse     = oembedInformation.OEmbedResponse;
            LinkPreviewBuilder linkPreviewBuilder = new OEmbedVideoPreviewBuilder(this.request, text, oembedResponse, this.logger, dataProviderInformation.ResponseUri);

            return(linkPreviewBuilder.Execute());
        }
Beispiel #3
0
        // Token: 0x0600194A RID: 6474 RVA: 0x00057EF4 File Offset: 0x000560F4
        public override GetLinkPreviewResponse CreatePreview(DataProviderInformation dataProviderInformation)
        {
            string text = ((WebPageInformation)dataProviderInformation).Text;
            Dictionary <string, string> queryParmDictionary;
            LinkPreviewBuilder          linkPreviewBuilder;

            if (YouTubeLinkPreviewBuilder.TryGetYouTubePlayerQueryParms(dataProviderInformation.ResponseUri, this.logger, out queryParmDictionary))
            {
                linkPreviewBuilder = new YouTubeLinkPreviewBuilder(queryParmDictionary, this.request, text, this.logger, dataProviderInformation.ResponseUri);
            }
            else if (AmazonLinkPreviewBuilder.IsAmazonUri(dataProviderInformation.ResponseUri))
            {
                linkPreviewBuilder = new AmazonLinkPreviewBuilder(this.request, text, this.logger, dataProviderInformation.ResponseUri);
            }
            else if (CraigsListLinkPreviewBuilder.IsCraigsListUri(dataProviderInformation.ResponseUri))
            {
                linkPreviewBuilder = new CraigsListLinkPreviewBuilder(this.request, text, this.logger, dataProviderInformation.ResponseUri);
            }
            else
            {
                linkPreviewBuilder = new WebPageLinkPreviewBuilder(this.request, text, this.logger, dataProviderInformation.ResponseUri, false);
            }
            return(linkPreviewBuilder.Execute());
        }
 public abstract GetLinkPreviewResponse CreatePreview(DataProviderInformation dataProviderInformation);
Beispiel #5
0
        // Token: 0x06001955 RID: 6485 RVA: 0x00058434 File Offset: 0x00056634
        public override GetLinkPreviewResponse CreatePreview(DataProviderInformation dataProviderInformation)
        {
            LinkPreviewBuilder linkPreviewBuilder = new WikipediaLinkPreviewBuilder(this.request, ((WebPageInformation)dataProviderInformation).Text, this.logger, dataProviderInformation.ResponseUri);

            return(linkPreviewBuilder.Execute());
        }