示例#1
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());
        }
示例#2
0
        protected static DataProviderInformation ProcessOEmbedResponseStream(Uri responseUri, Encoding responseHeaderEncoding, MemoryStream memoryStream, RequestDetailsLogger logger)
        {
            memoryStream.Position = 0L;
            OEmbedResponse oembedResponse = null;

            try
            {
                DataContractJsonSerializer dataContractJsonSerializer = new DataContractJsonSerializer(typeof(OEmbedResponse));
                oembedResponse = (OEmbedResponse)dataContractJsonSerializer.ReadObject(memoryStream);
            }
            catch (SerializationException ex)
            {
                GetLinkPreview.ThrowInvalidRequestException("OEmbedResponseSerializationReadFailed", string.Format("Failed to read the OEmbed response object. Error {0}", ex.Message));
            }
            return(new OEmbedInformation
            {
                Text = null,
                ResponseUri = responseUri,
                OEmbedResponse = oembedResponse
            });
        }
示例#3
0
 public OEmbedVideoPreviewBuilder(GetLinkPreviewRequest request, string responseString, OEmbedResponse oEmbedResponse, RequestDetailsLogger logger, Uri responseUri) : base(request, responseString, logger, responseUri, true)
 {
     this.oEmbedResponse = oEmbedResponse;
 }