protected override void InternalCopyFrom(IProperty srcProperty) { IPictureProperty pictureProperty = srcProperty as IPictureProperty; if (pictureProperty == null) { throw new UnexpectedTypeException("IPictureProperty", srcProperty); } string pictureData = pictureProperty.PictureData; if (PropertyState.Modified == srcProperty.State && pictureData != null) { base.CreateAirSyncNode(pictureData); } }
// Token: 0x060014E7 RID: 5351 RVA: 0x00079568 File Offset: 0x00077768 protected override void InternalCopyFromModified(IProperty srcProperty) { IPictureProperty pictureProperty = (IPictureProperty)srcProperty; if (string.IsNullOrEmpty(pictureProperty.PictureData)) { this.InternalSetToDefault(srcProperty); return; } if (pictureProperty.PictureData.Length > 50000) { AirSyncDiagnostics.TraceDebug(ExTraceGlobals.ProtocolTracer, null, "The size of contact picture is bigger than 50000 base64 chars"); throw new ConversionException("The size of contact picture is bigger than 50000 base64 chars"); } AttachmentId attachmentId = null; Contact contact = base.XsoItem as Contact; contact.Load(new PropertyDefinition[] { XsoPictureProperty.hasPicture }); object obj = contact.TryGetProperty(XsoPictureProperty.hasPicture); if (obj != null && obj is bool && (bool)obj) { foreach (AttachmentHandle handle in contact.AttachmentCollection) { using (Attachment attachment = contact.AttachmentCollection.Open(handle)) { attachment.Load(new PropertyDefinition[] { XsoPictureProperty.ispictureAttach }); obj = attachment.TryGetProperty(XsoPictureProperty.ispictureAttach); if (obj != null && obj is bool && (bool)obj) { AirSyncDiagnostics.TraceDebug(ExTraceGlobals.CommonTracer, null, "XsoPictureProperty.InternalCopyFromModified(), picture attachment exists."); attachmentId = attachment.Id; break; } } } } AirSyncDiagnostics.TraceDebug(ExTraceGlobals.CommonTracer, null, "XsoPictureProperty.InternalCopyFromModified(), creating a new picture attachment."); using (Attachment attachment2 = contact.AttachmentCollection.Create(AttachmentType.Stream)) { attachment2[XsoPictureProperty.ispictureAttach] = true; attachment2[AttachmentSchema.DisplayName] = "ContactPicture.jpg"; attachment2[XsoPictureProperty.attachFileName] = string.Empty; attachment2[XsoPictureProperty.attachLongFileName] = "ContactPicture.jpg"; attachment2[XsoPictureProperty.urlCompName] = "ContactPicture.jpg"; attachment2[XsoPictureProperty.attachExtension] = "jpg"; attachment2[XsoPictureProperty.attachFlags] = 0; attachment2[XsoPictureProperty.attachmentFlags] = 0; attachment2[XsoPictureProperty.attachmentHidden] = false; attachment2[XsoPictureProperty.attachmentLinkId] = 0; attachment2[XsoPictureProperty.attachEncoding] = new byte[0]; attachment2[XsoPictureProperty.exceptionStartTime] = new DateTime(4501, 1, 1); attachment2[XsoPictureProperty.exceptionEndTime] = new DateTime(4501, 1, 1); contact[XsoPictureProperty.hasPicture] = true; AirSyncDiagnostics.TraceDebug(ExTraceGlobals.CommonTracer, null, "XsoPictureProperty.InternalCopyFromModified(), writing the data to picture attachment."); using (Stream contentStream = ((StreamAttachment)attachment2).GetContentStream()) { contentStream.Position = 0L; byte[] array = Convert.FromBase64String(pictureProperty.PictureData); contentStream.Write(array, 0, array.Length); } attachment2.Save(); } if (attachmentId != null) { contact.AttachmentCollection.Remove(attachmentId); } }