Esempio n. 1
0
        public static void test()
        {
            var p = new MorkParser();

            p.Open(@"c:\temp\abook.mab");

            foreach (var table in p.GetTables(0x80))
            {
                foreach (MorkRowMap rowScope in table.Value.Select(x => x.Value))
                {
                    foreach (var row in p.GetRows(rowScope))
                    {
                        string text = string.Join(",",
                                                  row.Select(cell => string.Format("{0}={1}", cell.Key, cell.Value)));
                        Debug.WriteLine(text);
                    }
                }
            }
        }
Esempio n. 2
0
        public bool Load()
        {
            var profilesIniDirectory =
                Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Thunderbird";

            var activeProfileDirectory = ProfileManager.GetActiveProfileDirectory(profilesIniDirectory);

            if (activeProfileDirectory == null)
            {
                return(false);
            }

            var addressBookPath = Path.Combine(activeProfileDirectory, "abook.mab");

            if (!File.Exists(addressBookPath))
            {
                return(false);
            }

            using (var copy = new DisposableFileCopy(addressBookPath))
            {
                var p = new MorkParser();
                p.Open(copy.TempCopyPath);

                FirstNameOid   = p.GetColumnOid("FirstName");
                LastNameOid    = p.GetColumnOid("LastName");
                DisplayNameOid = p.GetColumnOid("DisplayName");
                EmailOid       = p.GetColumnOid("PrimaryEmail");

                _data = new ReadOnlyCollection <ReadOnlyDictionary <int, string> >(
                    (from table in p.GetTables(0x80)
                     from rowScope in table.Value.Select(x => x.Value)
                     from row in p.GetRows(rowScope)
                     select new ReadOnlyDictionary <int, string>(row.ToDictionary(kvp => kvp.Key, kvp => kvp.Value))).ToList());
            }

            return(true);
        }