コード例 #1
0
        /// <summary>
        /// Maps a ImageAssetRenderDetails (which is potentially cached) into an
        /// ImageAssetFile object. If the dbImage is null then null is returned.
        /// </summary>
        /// <param name="dbImage">ImageAssetRenderDetails record to map.</param>
        /// <param name="contentStream">Steam containing the file data.</param>
        public ImageAssetFile Map(ImageAssetRenderDetails renderDetails, Stream contentStream)
        {
            if (renderDetails == null)
            {
                return(null);
            }

            if (contentStream == null)
            {
                throw new ArgumentNullException(nameof(contentStream));
            }

            var image = new ImageAssetFile()
            {
                ImageAssetId          = renderDetails.ImageAssetId,
                FileExtension         = renderDetails.FileExtension,
                FileName              = renderDetails.FileName,
                FileNameOnDisk        = renderDetails.FileNameOnDisk,
                Height                = renderDetails.Height,
                Width                 = renderDetails.Width,
                Title                 = renderDetails.Title,
                DefaultAnchorLocation = renderDetails.DefaultAnchorLocation,
                FileStamp             = renderDetails.FileStamp,
                FileUpdateDate        = renderDetails.FileUpdateDate,
                ContentStream         = contentStream,
                VerificationToken     = renderDetails.VerificationToken
            };

            return(image);
        }
コード例 #2
0
        /// <summary>
        /// Maps a ImageAssetRenderDetails (which is potentially cached) into an
        /// ImageAssetFile object. If the dbImage is null then null is returned.
        /// </summary>
        /// <param name="dbImage">ImageAssetRenderDetails record to map.</param>
        /// <param name="contentStream">Steam containing the file data.</param>
        public ImageAssetFile Map(ImageAssetRenderDetails cachedImage, Stream contentStream)
        {
            if (cachedImage == null)
            {
                return(null);
            }

            if (contentStream == null)
            {
                throw new ArgumentNullException(nameof(contentStream));
            }

            var image = new ImageAssetFile()
            {
                ImageAssetId          = cachedImage.ImageAssetId,
                Extension             = cachedImage.Extension,
                FileName              = cachedImage.FileName,
                Height                = cachedImage.Height,
                Width                 = cachedImage.Width,
                Title                 = cachedImage.Title,
                DefaultAnchorLocation = cachedImage.DefaultAnchorLocation,
                UpdateDate            = cachedImage.UpdateDate,
                ContentStream         = contentStream
            };

            return(image);
        }