private static Notification CreateNotification(MapiNotification notification) { Notification result; if (notification.NotificationType == AdviseFlags.NewMail) { MapiNewMailNotification mapiNewMailNotification = notification as MapiNewMailNotification; result = new NewMailNotification(StoreObjectId.FromProviderSpecificId(mapiNewMailNotification.EntryId, ObjectClass.GetObjectType(mapiNewMailNotification.MessageClass)), StoreObjectId.FromProviderSpecificId(mapiNewMailNotification.ParentId, StoreObjectType.Folder), mapiNewMailNotification.MessageClass, (MessageFlags)mapiNewMailNotification.MessageFlags); } else if (notification.NotificationType == AdviseFlags.SearchComplete) { result = new ObjectNotification(null, null, null, null, (NotificationObjectType)0, null, NotificationType.SearchComplete); } else if (notification.NotificationType == AdviseFlags.ConnectionDropped) { MapiConnectionDroppedNotification mapiConnectionDroppedNotification = notification as MapiConnectionDroppedNotification; result = new ConnectionDroppedNotification(mapiConnectionDroppedNotification.ServerDN, mapiConnectionDroppedNotification.UserDN, mapiConnectionDroppedNotification.TickDeath); } else { MapiObjectNotification mapiObjectNotification = notification as MapiObjectNotification; if (mapiObjectNotification == null) { throw new InvalidOperationException(ServerStrings.ExNotSupportedNotificationType((uint)notification.NotificationType)); } AdviseFlags notificationType = notification.NotificationType; NotificationType type; if (notificationType <= AdviseFlags.ObjectDeleted) { if (notificationType == AdviseFlags.ObjectCreated) { type = NotificationType.Created; goto IL_10A; } if (notificationType == AdviseFlags.ObjectDeleted) { type = NotificationType.Deleted; goto IL_10A; } } else { if (notificationType == AdviseFlags.ObjectModified) { type = NotificationType.Modified; goto IL_10A; } if (notificationType == AdviseFlags.ObjectMoved) { type = NotificationType.Moved; goto IL_10A; } if (notificationType == AdviseFlags.ObjectCopied) { type = NotificationType.Copied; goto IL_10A; } } throw new InvalidOperationException(ServerStrings.ExNotSupportedNotificationType((uint)notification.NotificationType)); IL_10A: UnresolvedPropertyDefinition[] propertyDefinitions; if (mapiObjectNotification.Tags != null) { propertyDefinitions = PropertyTagCache.UnresolvedPropertyDefinitionsFromPropTags(mapiObjectNotification.Tags); } else { propertyDefinitions = Array <UnresolvedPropertyDefinition> .Empty; } result = new ObjectNotification((mapiObjectNotification.EntryId == null) ? null : StoreObjectId.FromProviderSpecificId(mapiObjectNotification.EntryId, StoreObjectType.Unknown), (mapiObjectNotification.ParentId == null) ? null : StoreObjectId.FromProviderSpecificId(mapiObjectNotification.ParentId, StoreObjectType.Folder), (mapiObjectNotification.OldId == null) ? null : StoreObjectId.FromProviderSpecificId(mapiObjectNotification.OldId, StoreObjectType.Unknown), (mapiObjectNotification.OldParentId == null) ? null : StoreObjectId.FromProviderSpecificId(mapiObjectNotification.OldParentId, StoreObjectType.Folder), (NotificationObjectType)mapiObjectNotification.ObjectType, propertyDefinitions, type); } return(result); }