Ejemplo n.º 1
0
        // Token: 0x06003F26 RID: 16166 RVA: 0x00120A2C File Offset: 0x0011EC2C
        internal string AddImage(Image image)
        {
            if (image == null)
            {
                throw new ArgumentNullException("image");
            }
            if (image.Source == null)
            {
                throw new ArgumentNullException("image.Source");
            }
            if (string.IsNullOrEmpty(image.Source.ToString()))
            {
                throw new ArgumentException(SR.Get("WpfPayload_InvalidImageSource"));
            }
            if (this._images == null)
            {
                this._images = new List <Image>();
            }
            string text             = null;
            string imageContentType = WpfPayload.GetImageContentType(image.Source.ToString());

            for (int i = 0; i < this._images.Count; i++)
            {
                if (WpfPayload.ImagesAreIdentical(this.GetBitmapSourceFromImage(this._images[i]), this.GetBitmapSourceFromImage(image)))
                {
                    Invariant.Assert(imageContentType == WpfPayload.GetImageContentType(this._images[i].Source.ToString()), "Image content types expected to be consistent: " + imageContentType + " vs. " + WpfPayload.GetImageContentType(this._images[i].Source.ToString()));
                    text = WpfPayload.GetImageName(i, imageContentType);
                }
            }
            if (text == null)
            {
                text = WpfPayload.GetImageName(this._images.Count, imageContentType);
                this._images.Add(image);
            }
            return(WpfPayload.GetImageReference(text));
        }