Beispiel #1
0
        public static bool Load(string BookmarkFileName)
        {
            try
            {
                if (System.IO.File.Exists(BookmarkFileName))
                {
                    BookmarkXMLDoc = XRoot.Load(BookmarkFileName);
                    FolderUIObjRoot = new FolderUIObj(null, FolderRoot);
                    SelectedFolder = FolderUIObjRoot;
                    return true;
                }
            }
            catch (Xml.Schema.Linq.LinqToXsdException)
            {
                //We found it, but could not parse it
                HandleIncorrectXSDMessage();
            }
            catch
            {

            }

            return false;
        }
Beispiel #2
0
 private static bool LoadBookmarksFromBackup()
 {
     if (System.IO.File.Exists(BookmarkUndoFilePath))
     {
         BookmarkXMLDoc = XRoot.Load(Global.BookmarkUndoFilePath);
         return true;
     }
     else
     {
         CreateNewBookmarkFile();
         return false;
     }
 }
Beispiel #3
0
 private static void CreateNewBookmarkFile()
 {
     Folder newFolderRoot = new Folder();
     newFolderRoot.name = "root";
     BookmarkXMLDoc = new XRoot(newFolderRoot);
     BookmarkXMLDoc.Save(BookmarkFilePath);
 }
Beispiel #4
0
        public bool Initialize()
        {
            //Check if there is a local favorites XML file, if it does not exist, create it, we always return true

            try
            {
                if (false == System.IO.Directory.Exists(BookmarkPath))
                {
                    System.IO.Directory.CreateDirectory(BookmarkPath);
                }

                if (false == System.IO.File.Exists(BookmarkFilePath))
                {
                    bool Restored = LoadBookmarksFromBackup();
                    if (!Restored)
                    {
                        CreateNewBookmarkFile();
                    }
                }
                else
                {
                    BookmarkXMLDoc = XRoot.Load(BookmarkFilePath);
                }
            }
            catch (System.IO.FileNotFoundException )
            {
                CreateNewBookmarkFile();
            }
            catch (Xml.Schema.Linq.LinqToXsdException )
            {
                //We found it, but could not parse it
                HandleIncorrectXSDMessage();
                LoadBookmarksFromBackup();
            }
            catch (System.Xml.XmlException )
            {
                //We found it, but could not parse it
                HandleIncorrectXSDMessage();
                LoadBookmarksFromBackup();
            }
            catch (Exception )
            {
                //We found it, but could not parse it
              //  HandleIncorrectXSDMessage();
              //  LoadBookmarksFromBackup();
            }

            FolderUIObjRoot = new FolderUIObj(null, FolderRoot);
            SelectedFolder = FolderUIObjRoot;

            return true;
        }
Beispiel #5
0
 public static XRoot Parse(string text, LoadOptions options)
 {
     XRoot root = new XRoot();
     root.doc = XDocument.Parse(text, options);
     XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
     if ((typedRoot == null)) {
         throw new LinqToXsdException("Invalid root element in xml document.");
     }
     root.rootObject = typedRoot;
     return root;
 }
Beispiel #6
0
 public static XRoot Load(XmlReader xmlReader)
 {
     XRoot root = new XRoot();
     root.doc = XDocument.Load(xmlReader);
     XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
     if ((typedRoot == null)) {
         throw new LinqToXsdException("Invalid root element in xml document.");
     }
     root.rootObject = typedRoot;
     return root;
 }