public static IConversationManager LoadConversationManager(ILoadingProgressCallback progressCallback, IPhoneDeviceInfo deviceInfo, bool mergeConversations)
        {
            IConversationManager conversationManager = null;

            using (DatabaseReader contactDatabaseReader = new DatabaseReader(DatabaseFinder.FindContactDatabasePath(deviceInfo.BackupPath)))
            {
                ContactReader contactReader = new ContactReader();
                contactReader.ParseDatabase(contactDatabaseReader);

                using (DatabaseReader textDatabaseReader = new DatabaseReader(DatabaseFinder.FindTextMessageDatabasePath(deviceInfo.BackupPath)))
                {
                    TextMessageReaderBase textMessageReader;
                    IEnumerable<ChatRoomInformation> chatReader;
                    IEnumerable<MessageAttachment> attachments;
                    int chatWorkEstimate;

                    if ((deviceInfo.OsVersion == null) || (deviceInfo.OsVersion.MajorVersion >= 6))
                    {
                        try
                        {
                            textMessageReader = new TextMessageReaderiOS6(deviceInfo.BackupPath);
                            textMessageReader.ParseDatabase(textDatabaseReader);
                            ChatRoomInformationReaderiOS6 chatRoomInfoReader = new ChatRoomInformationReaderiOS6();
                            chatRoomInfoReader.ParseDatabase(textDatabaseReader);
                            chatReader = chatRoomInfoReader;
                            attachments = new List<MessageAttachment>();
                            chatWorkEstimate = chatRoomInfoReader.ItemCountEstimate;
                        }
                        catch (DatabaseQueryException)
                        {
                            textMessageReader = new TextMessageReader(deviceInfo.BackupPath);
                            textMessageReader.ParseDatabase(textDatabaseReader);
                            chatReader = new List<ChatRoomInformation>();
                            attachments = new List<MessageAttachment>();
                            chatWorkEstimate = 0;
                        }
                    }
                    else if (deviceInfo.OsVersion.MajorVersion == 5)
                    {
                        textMessageReader = new TextMessageReader2(deviceInfo.BackupPath);
                        textMessageReader.ParseDatabase(textDatabaseReader);
                        ChatRoomInformationReader chatRoomInfoReader = new ChatRoomInformationReader();
                        chatRoomInfoReader.ParseDatabase(textDatabaseReader);
                        chatReader = chatRoomInfoReader;
                        attachments = new List<MessageAttachment>();
                        chatWorkEstimate = chatRoomInfoReader.ItemCountEstimate;
                    }
                    else
                    {
                        textMessageReader = new TextMessageReader(deviceInfo.BackupPath);
                        textMessageReader.ParseDatabase(textDatabaseReader);
                        chatReader = new List<ChatRoomInformation>();
                        attachments = new List<MessageAttachment>();
                        chatWorkEstimate = 0;
                    }

                    int workEstimate = AllYourTextsLib.Conversation.ConversationManager.GetWorkEstimate(contactReader.ItemCountEstimate,
                                                                                                        textMessageReader.ItemCountEstimate,
                                                                                                        chatWorkEstimate,
                                                                                                        0);
                    if (mergeConversations)
                    {
                        workEstimate += MergingConversationManager.GetWorkEstimateByContacts(contactReader.ItemCountEstimate);
                    }
                    progressCallback.Begin(workEstimate);

                    conversationManager = new ConversationManager(contactReader,
                                                                  textMessageReader,
                                                                  chatReader,
                                                                  attachments,
                                                                  progressCallback);
                    if (mergeConversations)
                    {
                        conversationManager = new MergingConversationManager(conversationManager, progressCallback);
                    }
                }
            }

            return conversationManager;
        }
        public static IConversationManager LoadConversationManager(ILoadingProgressCallback progressCallback, IPhoneDeviceInfo deviceInfo, bool mergeConversations)
        {
            IConversationManager conversationManager = null;

            using (DatabaseReader contactDatabaseReader = new DatabaseReader(DatabaseFinder.FindContactDatabasePath(deviceInfo.BackupPath)))
            {
                ContactReader contactReader = new ContactReader();
                contactReader.ParseDatabase(contactDatabaseReader);

                using (DatabaseReader textDatabaseReader = new DatabaseReader(DatabaseFinder.FindTextMessageDatabasePath(deviceInfo.BackupPath)))
                {
                    TextMessageReaderBase             textMessageReader;
                    IEnumerable <ChatRoomInformation> chatReader;
                    IEnumerable <MessageAttachment>   attachments;
                    int chatWorkEstimate;

                    if ((deviceInfo.OsVersion == null) || (deviceInfo.OsVersion.MajorVersion >= 6))
                    {
                        try
                        {
                            textMessageReader = new TextMessageReaderiOS6(deviceInfo.BackupPath);
                            textMessageReader.ParseDatabase(textDatabaseReader);
                            ChatRoomInformationReaderiOS6 chatRoomInfoReader = new ChatRoomInformationReaderiOS6();
                            chatRoomInfoReader.ParseDatabase(textDatabaseReader);
                            chatReader       = chatRoomInfoReader;
                            attachments      = new List <MessageAttachment>();
                            chatWorkEstimate = chatRoomInfoReader.ItemCountEstimate;
                        }
                        catch (DatabaseQueryException)
                        {
                            textMessageReader = new TextMessageReader(deviceInfo.BackupPath);
                            textMessageReader.ParseDatabase(textDatabaseReader);
                            chatReader       = new List <ChatRoomInformation>();
                            attachments      = new List <MessageAttachment>();
                            chatWorkEstimate = 0;
                        }
                    }
                    else if (deviceInfo.OsVersion.MajorVersion == 5)
                    {
                        textMessageReader = new TextMessageReader2(deviceInfo.BackupPath);
                        textMessageReader.ParseDatabase(textDatabaseReader);
                        ChatRoomInformationReader chatRoomInfoReader = new ChatRoomInformationReader();
                        chatRoomInfoReader.ParseDatabase(textDatabaseReader);
                        chatReader       = chatRoomInfoReader;
                        attachments      = new List <MessageAttachment>();
                        chatWorkEstimate = chatRoomInfoReader.ItemCountEstimate;
                    }
                    else
                    {
                        textMessageReader = new TextMessageReader(deviceInfo.BackupPath);
                        textMessageReader.ParseDatabase(textDatabaseReader);
                        chatReader       = new List <ChatRoomInformation>();
                        attachments      = new List <MessageAttachment>();
                        chatWorkEstimate = 0;
                    }

                    int workEstimate = AllYourTextsLib.Conversation.ConversationManager.GetWorkEstimate(contactReader.ItemCountEstimate,
                                                                                                        textMessageReader.ItemCountEstimate,
                                                                                                        chatWorkEstimate,
                                                                                                        0);
                    if (mergeConversations)
                    {
                        workEstimate += MergingConversationManager.GetWorkEstimateByContacts(contactReader.ItemCountEstimate);
                    }
                    progressCallback.Begin(workEstimate);

                    conversationManager = new ConversationManager(contactReader,
                                                                  textMessageReader,
                                                                  chatReader,
                                                                  attachments,
                                                                  progressCallback);
                    if (mergeConversations)
                    {
                        conversationManager = new MergingConversationManager(conversationManager, progressCallback);
                    }
                }
            }

            return(conversationManager);
        }