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; }
private static void LoadUserPreferences() { try { if (false == System.IO.Directory.Exists(WebAnnotationPath)) { System.IO.Directory.CreateDirectory(WebAnnotationPath); LoadServerUserSettings(); } if (false == System.IO.File.Exists(UserSettingsFilePath)) { LoadServerUserSettings(); } UserSettingsDoc = XRoot.Load(UserSettingsFilePath); } 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(); } }
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; }
private static void CreateNewUserSettingsFile() { Global.UserSettingsDoc = new XRoot(new UserSettings()); SaveUserSettings(); }