1: using System;
2: using System.Reflection;
3: using System.Xml.Linq;
4: using System.IO;
5: using System.Collections.Generic;
6: using Newtonsoft.Json;
7:
8: namespace Ia.Learning.Cl.Model.Data
9: {
10: ////////////////////////////////////////////////////////////////////////////
11:
12: /// <summary publish="true">
13: /// Textbook support data class
14: /// </summary>
15: /// <value>
16: /// https://msdn.microsoft.com/en-us/library/z1hkazw7(v=vs.100).aspx
17: /// </value>
18: /// <remarks>
19: /// Copyright © 2008-2016 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
20: ///
21: /// 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
22: /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
23: ///
24: /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
25: /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
26: ///
27: /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
28: ///
29: /// Copyright notice: This notice may not be removed or altered from any source distribution.
30: /// </remarks>
31: public partial class Textbook
32: {
33: private static List<Ia.Learning.Cl.Model.Business.Textbook> textbooks;
34:
35: ////////////////////////////////////////////////////////////////////////////
36:
37: /// <summary>
38: ///
39: /// </summary>
40: public Textbook() { }
41:
42: ////////////////////////////////////////////////////////////////////////////
43: ////////////////////////////////////////////////////////////////////////////
44:
45: /// <summary>
46: ///
47: /// How to embed and access resources by using Visual C# http://support.microsoft.com/kb/319292/en-us
48: ///
49: /// 1. Change the "Build Action" property of your XML file from "Content" to "Embedded Resource".
50: /// 2. Add "using System.Reflection".
51: ///
52: /// </summary>
53: public static List<Ia.Learning.Cl.Model.Business.Textbook> List
54: {
55: get
56: {
57: if (textbooks == null || textbooks.Count == 0)
58: {
59: string json;
60: Assembly assembly;
61:
62: assembly = Assembly.GetExecutingAssembly();
63:
64: try
65: {
66: using (StreamReader streamReader = new StreamReader(assembly.GetManifestResourceStream("Ia.Learning.Cl.model.data.textbook.json")))
67: {
68: json = streamReader.ReadToEnd();
69:
70: // JSON file must start with [{...
71:
72: textbooks = JsonConvert.DeserializeObject<List<Ia.Learning.Cl.Model.Business.Textbook>>(json);
73: }
74: }
75: catch (Exception e)
76: {
77: }
78: finally
79: {
80: }
81: }
82:
83: return textbooks;
84: }
85: }
86:
87: ////////////////////////////////////////////////////////////////////////////
88: ////////////////////////////////////////////////////////////////////////////
89: }
90:
91: ////////////////////////////////////////////////////////////////////////////
92: ////////////////////////////////////////////////////////////////////////////
93: }