示例#1
0
        /// <summary>
        /// Returns a unique instance of an ImageFilter object which will
        /// actually perform the filtering for the specified ImageConsumer.
        /// The default implementation just clones this object.
        /// <para>
        /// Note: This method is intended to be called by the ImageProducer
        /// of the Image whose pixels are being filtered.  Developers using
        /// this class to filter pixels from an image should avoid calling
        /// this method directly since that operation could interfere
        /// with the filtering operation.
        /// </para>
        /// </summary>
        /// <param name="ic"> the specified <code>ImageConsumer</code> </param>
        /// <returns> an <code>ImageFilter</code> used to perform the
        ///         filtering for the specified <code>ImageConsumer</code>. </returns>
        public virtual ImageFilter GetFilterInstance(ImageConsumer ic)
        {
            ImageFilter instance = (ImageFilter)Clone();

            instance.Consumer = ic;
            return(instance);
        }
 /// <summary>
 /// Determines whether an ImageConsumer is on the list of consumers
 /// currently interested in data for this image.
 ///
 /// <para>
 /// This method is public as a side effect
 /// of this class implementing
 /// the <code>ImageProducer</code> interface.
 /// It should not be called from user code,
 /// and its behavior if called from user code is unspecified.
 ///
 /// </para>
 /// </summary>
 /// <param name="ic"> the specified <code>ImageConsumer</code> </param>
 /// <returns> true if the ImageConsumer is on the list; false otherwise </returns>
 /// <seealso cref= ImageConsumer </seealso>
 public virtual bool IsConsumer(ImageConsumer ic)
 {
     lock (this)
     {
         return(Proxies != null && Proxies.ContainsKey(ic));
     }
 }
 /// <summary>
 /// Remove an ImageConsumer from the list of consumers interested in
 /// data for this image.
 /// </summary>
 /// <param name="ic"> the ImageConsumer to be removed. </param>
 public virtual void RemoveConsumer(ImageConsumer ic)
 {
     lock (this)
     {
         Ics.Remove(ic);
     }
 }
 /// <summary>
 /// Determine if an ImageConsumer is on the list of consumers
 /// currently interested in data for this image.
 /// </summary>
 /// <param name="ic"> the ImageConsumer to be checked. </param>
 /// <returns> true if the ImageConsumer is on the list; false otherwise. </returns>
 public virtual bool IsConsumer(ImageConsumer ic)
 {
     lock (this)
     {
         return(Ics.Contains(ic));
     }
 }
 /// <summary>
 /// Adds an ImageConsumer to the list of consumers interested in
 /// data for this image.
 /// </summary>
 /// <param name="ic"> an ImageConsumer to be added to the interest list. </param>
 public virtual void AddConsumer(ImageConsumer ic)
 {
     lock (this)
     {
         if (!Ics.Contains(ic))
         {
             Ics.Add(ic);
         }
     }
 }
 /// <summary>
 /// Adds an ImageConsumer to the list of consumers interested in
 /// data for this image, and immediately starts delivery of the
 /// image data through the ImageConsumer interface.
 /// </summary>
 /// <param name="ic"> the ImageConsumer to be added to the list of consumers. </param>
 public virtual void StartProduction(ImageConsumer ic)
 {
     lock (this)
     {
         AddConsumer(ic);
         // Need to build a runnable object for the Thread.
         Thread thread = new Thread(this, "RenderableImageProducer Thread");
         thread.Start();
     }
 }
 /// <summary>
 /// Requests that a given ImageConsumer have the image data delivered
 /// one more time in top-down, left-right order.  The request is
 /// handed to the ImageFilter for further processing, since the
 /// ability to preserve the pixel ordering depends on the filter.
 ///
 /// <para>
 /// This method is public as a side effect
 /// of this class implementing
 /// the <code>ImageProducer</code> interface.
 /// It should not be called from user code,
 /// and its behavior if called from user code is unspecified.
 ///
 /// </para>
 /// </summary>
 /// <seealso cref= ImageConsumer </seealso>
 public virtual void RequestTopDownLeftRightResend(ImageConsumer ic)
 {
     if (Proxies != null)
     {
         ImageFilter imgf = (ImageFilter)Proxies[ic];
         if (imgf != null)
         {
             imgf.ResendTopDownLeftRight(Src);
         }
     }
 }
        /// <summary>
        /// Starts production of the filtered image.
        /// If the specified <code>ImageConsumer</code>
        /// isn't already a consumer of the filtered image,
        /// an instance of the original <code>ImageFilter</code>
        /// is created
        /// (using the filter's <code>getFilterInstance</code> method)
        /// to manipulate the image data
        /// for the <code>ImageConsumer</code>.
        /// The filter instance for the <code>ImageConsumer</code>
        /// is then passed to the <code>startProduction</code> method
        /// of the original <code>ImageProducer</code>.
        ///
        /// <para>
        /// This method is public as a side effect
        /// of this class implementing
        /// the <code>ImageProducer</code> interface.
        /// It should not be called from user code,
        /// and its behavior if called from user code is unspecified.
        ///
        /// </para>
        /// </summary>
        /// <param name="ic">  the consumer for the filtered image </param>
        /// <seealso cref= ImageConsumer </seealso>
        public virtual void StartProduction(ImageConsumer ic)
        {
            if (Proxies == null)
            {
                Proxies = new Hashtable();
            }
            ImageFilter imgf = (ImageFilter)Proxies[ic];

            if (imgf == null)
            {
                imgf        = Filter.GetFilterInstance(ic);
                Proxies[ic] = imgf;
            }
            Src.StartProduction(imgf);
        }
        public async Task Given_A_CardImageConsumer_If_Exception_Is_Thrown_IsSuccessful_Should_False()
        {
            // Arrange
            var cardImageConsumer = new ImageConsumer
            {
                Message = "{\"RemoteImageUrl\":\"https://vignette.wikia.nocookie.net/yugioh/images/f/f6/AdreusKeeperofArmageddon-BP01-EN-R-1E.png\",\"ImageFileName\":\"Adreus, Keeper of Armageddon\",\"ImageFolderPath\":\"D:\\\\Apps\\\\ygo-api\\\\Images\\\\Cards\"}\r"
            };

            _mediator.Send(Arg.Any <DownloadImageCommand>()).Throws(new Exception());

            // Act
            var result = await _sut.Handle(cardImageConsumer, CancellationToken.None);

            // Assert
            result.IsSuccessful.Should().BeFalse();
        }
 /// <summary>
 /// Adds the specified <code>ImageConsumer</code>
 /// to the list of consumers interested in data for the filtered image.
 /// An instance of the original <code>ImageFilter</code>
 /// is created
 /// (using the filter's <code>getFilterInstance</code> method)
 /// to manipulate the image data
 /// for the specified <code>ImageConsumer</code>.
 /// The newly created filter instance
 /// is then passed to the <code>addConsumer</code> method
 /// of the original <code>ImageProducer</code>.
 ///
 /// <para>
 /// This method is public as a side effect
 /// of this class implementing
 /// the <code>ImageProducer</code> interface.
 /// It should not be called from user code,
 /// and its behavior if called from user code is unspecified.
 ///
 /// </para>
 /// </summary>
 /// <param name="ic">  the consumer for the filtered image </param>
 /// <seealso cref= ImageConsumer </seealso>
 public virtual void AddConsumer(ImageConsumer ic)
 {
     lock (this)
     {
         if (Proxies == null)
         {
             Proxies = new Hashtable();
         }
         if (!Proxies.ContainsKey(ic))
         {
             ImageFilter imgf = Filter.GetFilterInstance(ic);
             Proxies[ic] = imgf;
             Src.AddConsumer(imgf);
         }
     }
 }
 /// <summary>
 /// Removes an ImageConsumer from the list of consumers interested in
 /// data for this image.
 ///
 /// <para>
 /// This method is public as a side effect
 /// of this class implementing
 /// the <code>ImageProducer</code> interface.
 /// It should not be called from user code,
 /// and its behavior if called from user code is unspecified.
 ///
 /// </para>
 /// </summary>
 /// <seealso cref= ImageConsumer </seealso>
 public virtual void RemoveConsumer(ImageConsumer ic)
 {
     lock (this)
     {
         if (Proxies != null)
         {
             ImageFilter imgf = (ImageFilter)Proxies[ic];
             if (imgf != null)
             {
                 Src.RemoveConsumer(imgf);
                 Proxies.Remove(ic);
                 if (Proxies.Count == 0)
                 {
                     Proxies = null;
                 }
             }
         }
     }
 }
 /// <summary>
 /// Requests that a given ImageConsumer have the image data delivered
 /// one more time in top-down, left-right order.
 /// </summary>
 /// <param name="ic"> the ImageConsumer requesting the resend. </param>
 public virtual void RequestTopDownLeftRightResend(ImageConsumer ic)
 {
     // So far, all pixels are already sent in TDLR order
 }