示例#1
0
        private PhotoMetadata ReadPhotoOfSizeOrBestMatch(IItem photo, UserPhotoSize size, Stream output)
        {
            UserPhotoSize userPhotoSize = size;
            PhotoMetadata result;

            try
            {
IL_02:
                using (Stream stream = photo.OpenPropertyStream(MailboxPhotoReader.GetPropertyDefinitionForSize(userPhotoSize), PropertyOpenMode.ReadOnly))
                {
                    stream.CopyTo(output);
                    result = new PhotoMetadata
                    {
                        Length      = stream.Length,
                        ContentType = "image/jpeg"
                    };
                }
            }
            catch (ObjectNotFoundException)
            {
                this.tracer.TraceDebug <UserPhotoSize>((long)this.GetHashCode(), "Mailbox photo reader: photo of size {0} not found.", userPhotoSize);
                userPhotoSize = MailboxPhotoReader.NextSmallerSize(userPhotoSize);
                goto IL_02;
            }
            return(result);
        }
示例#2
0
 // Token: 0x0600121B RID: 4635 RVA: 0x0004CA34 File Offset: 0x0004AC34
 private void CreatePreviewItem(IDictionary <UserPhotoSize, byte[]> photos)
 {
     using (IItem item = Item.Create((MailboxSession)this.session, "IPM.UserPhoto.Preview", this.GetPhotoStoreId()))
     {
         foreach (UserPhotoSize userPhotoSize in MailboxPhotoWriter.AllPhotoSizes)
         {
             byte[] buffer;
             if (!photos.TryGetValue(userPhotoSize, out buffer))
             {
                 this.tracer.TraceDebug <UserPhotoSize>((long)this.GetHashCode(), "Mailbox photo writer: photo of size {0} not available in preview (input).  Skipped.", userPhotoSize);
             }
             else
             {
                 this.tracer.TraceDebug <UserPhotoSize>((long)this.GetHashCode(), "Mailbox photo writer: storing photo of size {0} onto preview item.", userPhotoSize);
                 using (MemoryStream memoryStream = new MemoryStream(buffer))
                 {
                     this.StorePhotoOfSpecificSize(item, userPhotoSize, MailboxPhotoReader.GetPropertyDefinitionForSize(userPhotoSize), memoryStream);
                 }
             }
         }
         item.Save(SaveMode.ResolveConflicts);
         this.tracer.TraceDebug((long)this.GetHashCode(), "Mailbox photo writer: preview item created successfully.");
     }
 }