)>}]
شركة التطبيقات المتكاملة لتصميم وبرمجة البرمجيات الخاصة ش.ش.و.
Integrated Applications Programming Company
Home » Code Library » Guide (Ia.Ftn.Cl.Model.Data)

Public general use code classes and xml files that we've compiled and used over the years:

Guide support class for Fixed Telecommunications Network (FTN) data model.

    1: using System;
    2: using System.Collections.Generic;
    3: using System.Data;
    4: using System.IO;
    5: using System.Linq;
    6: using System.Reflection;
    7: using System.Web;
    8: using System.Xml.Linq;
    9:  
   10: namespace Ia.Ftn.Cl.Model.Data
   11: {
   12:     ////////////////////////////////////////////////////////////////////////////
   13:  
   14:     /// <summary publish="true">
   15:     /// Guide support class for Fixed Telecommunications Network (FTN) data model.
   16:     /// </summary>
   17:     /// 
   18:     /// <remarks> 
   19:     /// Copyright © 2006-2022 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 class Guide
   32:     {
   33:         private static XDocument xDocument;
   34:  
   35:         private static readonly object objectLock = new object();
   36:  
   37:         ////////////////////////////////////////////////////////////////////////////
   38:  
   39:         /// <summary>
   40:         ///
   41:         /// </summary>
   42:         public Guide() { }
   43:  
   44:         ////////////////////////////////////////////////////////////////////////////
   45:  
   46:         /// <summary>
   47:         ///
   48:         /// </summary>
   49:         public static List<string> FrequentAnswerList()
   50:         {
   51:             var list = (from c in XDocument.Elements("guide").Elements("frequentAnswers").Elements("answer")
   52:                         select c.Value).ToList();
   53:  
   54:             return list;
   55:         }
   56:  
   57:         ////////////////////////////////////////////////////////////////////////////
   58:  
   59:         /// <summary>
   60:         ///
   61:         /// </summary>
   62:         public static List<string> ArticleList()
   63:         {
   64:             var list = (from c in XDocument.Elements("articles").Elements("article")
   65:                         select c.Value).ToList();
   66:  
   67:             return list;
   68:         }
   69:  
   70:         /*
   71:         ////////////////////////////////////////////////////////////////////////////
   72: 
   73:         /// <summary>
   74:         ///
   75:         /// </summary>
   76:         public static Dictionary<int, string> CategoryDictionary
   77:         {
   78:             get
   79:             {
   80:                 Dictionary<int, string> dictionary;
   81: 
   82:                 dictionary = new Dictionary<int, string>(100);
   83: 
   84:                 dictionary = (from c in XDocument.Elements("report").Elements("category")
   85:                               select new { Id = int.Parse(c.Attribute("id").Value), Name = c.Attribute("name").Value }).ToDictionary(r => r.Id, r => r.Name);
   86: 
   87:                 return dictionary;
   88:             }
   89:         }
   90:         */
   91:  
   92:         ////////////////////////////////////////////////////////////////////////////
   93:         ////////////////////////////////////////////////////////////////////////////
   94:  
   95:         /// <summary>
   96:         /// 
   97:         /// How to embed and access resources by using Visual C# http://support.microsoft.com/kb/319292/en-us
   98:         /// 
   99:         /// 1. Change the "Build Action" property of your XML file from "Content" to "Embedded Resource".
  100:         /// 2. Add "using System.Reflection".
  101:         /// 3. Manifest resource stream will start with the project namespace, the location of XML file.
  102:         /// 
  103:         /// </summary>
  104:  
  105:         public static XDocument XDocument
  106:         {
  107:             get
  108:             {
  109:                 if (xDocument == null)
  110:                 {
  111:                     lock (objectLock)
  112:                     {
  113:                         Assembly _assembly;
  114:                         StreamReader streamReader;
  115:  
  116:                         _assembly = Assembly.GetExecutingAssembly();
  117:                         streamReader = new StreamReader(_assembly.GetManifestResourceStream("Ia.Ftn.Cl.model.data.guide.xml"));
  118:  
  119:                         try
  120:                         {
  121:                             if (streamReader.Peek() != -1) xDocument = System.Xml.Linq.XDocument.Load(streamReader);
  122:                         }
  123:                         catch (Exception)
  124:                         {
  125:                         }
  126:                         finally
  127:                         {
  128:                         }
  129:                     }
  130:                 }
  131:  
  132:                 return xDocument;
  133:             }
  134:         }
  135:  
  136:         ////////////////////////////////////////////////////////////////////////////
  137:         ////////////////////////////////////////////////////////////////////////////    
  138:     }
  139:  
  140:     ////////////////////////////////////////////////////////////////////////////
  141:     ////////////////////////////////////////////////////////////////////////////   
  142: }