1: using System;
2: using System.Data;
3: using System.Xml.Linq;
4:
5: namespace Ia.Cl.Model.Db
6: {
7: ////////////////////////////////////////////////////////////////////////////
8:
9: /// <summary publish="true">
10: /// XML Database support class. This handles storing and retrieving XDocument storage.
11: /// </summary>
12: /// <remarks>
13: /// Copyright © 2001-2020 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
14: ///
15: /// This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
16: /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
17: ///
18: /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
19: /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
20: ///
21: /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
22: ///
23: /// Copyright notice: This notice may not be removed or altered from any source distribution.
24: /// </remarks>
25:
26: public static class Xml
27: {
28: ////////////////////////////////////////////////////////////////////////////
29:
30: /// <summary>
31: ///
32: /// </summary>
33: public static XDocument Read(string name)
34: {
35: string filePath;
36: XDocument xDocument;
37:
38: filePath = Ia.Cl.Model.Default.AbsolutePath() + name;
39:
40: xDocument = XDocument.Load(filePath + ".xdocument.xml");
41:
42: return xDocument;
43: }
44:
45: ////////////////////////////////////////////////////////////////////////////
46:
47: /// <summary>
48: ///
49: /// </summary>
50: public static bool Save(string name)
51: {
52: bool b;
53: string r;
54: string filePath;
55: XDocument xDocument;
56:
57: filePath = Ia.Cl.Model.Default.AbsolutePath() + name;
58:
59: try
60: {
61: xDocument = new XDocument();
62:
63: xDocument.Save(filePath + ".xdocument.xml");
64:
65: b = true;
66: }
67: catch (Exception ex)
68: {
69: b = false;
70: #if DEBUG
71: r = "Error: " + ex.ToString();
72: #else
73: r = "Error: " + ex.Message;
74: #endif
75: }
76: finally
77: {
78: }
79:
80: return b;
81: }
82:
83: ////////////////////////////////////////////////////////////////////////////
84: ////////////////////////////////////////////////////////////////////////////
85: }
86:
87: ////////////////////////////////////////////////////////////////////////////
88: ////////////////////////////////////////////////////////////////////////////
89: }
90: