public static bool IsPublicFolder(string id) { bool result; try { using (MemoryStream decompressedMemoryStream = ServiceIdConverter.GetDecompressedMemoryStream(id)) { using (BinaryReader binaryReader = new BinaryReader(decompressedMemoryStream)) { result = (ServiceIdConverter.ReadIdStorageType(binaryReader, BasicTypes.Folder) == IdStorageType.PublicFolder); } } } catch (EndOfStreamException innerException) { throw new InvalidIdMalformedException(innerException); } catch (CorruptDataException innerException2) { throw new InvalidIdMalformedException(innerException2); } catch (FormatException innerException3) { throw new InvalidIdMalformedException(innerException3); } return(result); }
public static IdHeaderInformation ConvertFromConcatenatedId(string id, BasicTypes expectedType, List <AttachmentId> attachmentIds) { if (string.IsNullOrEmpty(id)) { throw new InvalidIdEmptyException(); } EnumValidator.ThrowIfInvalid <BasicTypes>(expectedType, "expectedType"); IdHeaderInformation result; try { IdHeaderInformation idHeaderInformation = new IdHeaderInformation(); using (MemoryStream decompressedMemoryStream = ServiceIdConverter.GetDecompressedMemoryStream(id)) { using (BinaryReader binaryReader = new BinaryReader(decompressedMemoryStream)) { idHeaderInformation.IdStorageType = ServiceIdConverter.ReadIdStorageType(binaryReader, expectedType); switch (idHeaderInformation.IdStorageType) { case IdStorageType.MailboxItemSmtpAddressBased: idHeaderInformation.MailboxId = new MailboxId(MailboxIdSerializer.EmailAddressFromBytes(ServiceIdConverter.ReadMoniker(binaryReader, expectedType))); idHeaderInformation.IdProcessingInstruction = ServiceIdConverter.ReadIdProcessingInstruction(binaryReader, expectedType); idHeaderInformation.StoreIdBytes = ServiceIdConverter.ReadStoreId(binaryReader, expectedType); break; case IdStorageType.PublicFolder: case IdStorageType.ActiveDirectoryObject: idHeaderInformation.StoreIdBytes = ServiceIdConverter.ReadStoreId(binaryReader, expectedType); break; case IdStorageType.PublicFolderItem: idHeaderInformation.IdProcessingInstruction = ServiceIdConverter.ReadIdProcessingInstruction(binaryReader, expectedType); idHeaderInformation.StoreIdBytes = ServiceIdConverter.ReadStoreId(binaryReader, expectedType); idHeaderInformation.FolderIdBytes = ServiceIdConverter.ReadStoreId(binaryReader, expectedType); break; case IdStorageType.MailboxItemMailboxGuidBased: case IdStorageType.ConversationIdMailboxGuidBased: idHeaderInformation.MailboxId = new MailboxId(MailboxIdSerializer.MailboxGuidFromBytes(ServiceIdConverter.ReadMoniker(binaryReader, expectedType))); idHeaderInformation.IdProcessingInstruction = ServiceIdConverter.ReadIdProcessingInstruction(binaryReader, expectedType); idHeaderInformation.StoreIdBytes = ServiceIdConverter.ReadStoreId(binaryReader, expectedType); break; default: ServiceIdConverter.TraceDebug("[IdConverter::ConvertFromConcatenatedId] Invalid id storage type"); throw new InvalidIdMalformedException(); } if (attachmentIds != null) { if (decompressedMemoryStream.Position < decompressedMemoryStream.Length) { ServiceIdConverter.ReadAttachmentIds(binaryReader, expectedType, attachmentIds); } else if (expectedType == BasicTypes.Attachment) { throw new InvalidIdNotAnItemAttachmentIdException(); } } } } result = idHeaderInformation; } catch (EndOfStreamException innerException) { throw new InvalidIdMalformedException(innerException); } catch (CorruptDataException innerException2) { throw new InvalidIdMalformedException(innerException2); } catch (FormatException innerException3) { throw new InvalidIdMalformedException(innerException3); } return(result); }