)>}]
شركة التطبيقات المتكاملة لتصميم وبرمجة البرمجيات الخاصة ش.ش.و.
Integrated Applications Programming Company
Home » Code Library » Guide (Ia.Ftn.Cl.Models.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.Xml.Linq;
    8:  
    9: namespace Ia.Ftn.Cl.Models.Data
   10: {
   11:     ////////////////////////////////////////////////////////////////////////////
   12:  
   13:     /// <summary publish="true">
   14:     /// Guide support class for Fixed Telecommunications Network (FTN) data model.
   15:     /// </summary>
   16:     /// 
   17:     /// <remarks> 
   18:     /// Copyright © 2006-2022 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
   19:     ///
   20:     /// 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
   21:     /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
   22:     ///
   23:     /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
   24:     /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
   25:     /// 
   26:     /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
   27:     /// 
   28:     /// Copyright notice: This notice may not be removed or altered from any source distribution.
   29:     /// </remarks> 
   30:     public class Guide
   31:     {
   32:         private static XDocument xDocument;
   33:  
   34:         private static readonly object objectLock = new object();
   35:  
   36:         ////////////////////////////////////////////////////////////////////////////
   37:  
   38:         /// <summary>
   39:         ///
   40:         /// </summary>
   41:         public Guide() { }
   42:  
   43:         ////////////////////////////////////////////////////////////////////////////
   44:  
   45:         /// <summary>
   46:         ///
   47:         /// </summary>
   48:         public static List<string> FrequentAnswerList()
   49:         {
   50:             var list = (from c in XDocument.Elements("guide").Elements("frequentAnswers").Elements("answer")
   51:                         select c.Value).ToList();
   52:  
   53:             return list;
   54:         }
   55:  
   56:         ////////////////////////////////////////////////////////////////////////////
   57:  
   58:         /// <summary>
   59:         ///
   60:         /// </summary>
   61:         public static List<string> ArticleList()
   62:         {
   63:             var list = (from c in XDocument.Elements("articles").Elements("article")
   64:                         select c.Value).ToList();
   65:  
   66:             return list;
   67:         }
   68:  
   69:         /*
   70:         ////////////////////////////////////////////////////////////////////////////
   71: 
   72:         /// <summary>
   73:         ///
   74:         /// </summary>
   75:         public static Dictionary<int, string> CategoryDictionary
   76:         {
   77:             get
   78:             {
   79:                 Dictionary<int, string> dictionary;
   80: 
   81:                 dictionary = new Dictionary<int, string>(100);
   82: 
   83:                 dictionary = (from c in XDocument.Elements("report").Elements("category")
   84:                               select new { Id = int.Parse(c.Attribute("id").Value), Name = c.Attribute("name").Value }).ToDictionary(r => r.Id, r => r.Name);
   85: 
   86:                 return dictionary;
   87:             }
   88:         }
   89:         */
   90:  
   91:         ////////////////////////////////////////////////////////////////////////////
   92:         ////////////////////////////////////////////////////////////////////////////
   93:  
   94:         /// <summary>
   95:         /// 
   96:         /// How to embed and access resources by using Visual C# http://support.microsoft.com/kb/319292/en-us
   97:         /// 
   98:         /// 1. Change the "Build Action" property of your XML file from "Content" to "Embedded Resource".
   99:         /// 2. Add "using System.Reflection".
  100:         /// 3. Manifest resource stream will start with the project namespace, the location of XML file.
  101:         /// 
  102:         /// </summary>
  103:  
  104:         public static XDocument XDocument
  105:         {
  106:             get
  107:             {
  108:                 if (xDocument == null)
  109:                 {
  110:                     lock (objectLock)
  111:                     {
  112:                         Assembly assembly;
  113:                         StreamReader streamReader;
  114:  
  115:                         assembly = Assembly.GetExecutingAssembly();
  116:                         streamReader = new StreamReader(assembly.GetManifestResourceStream("Ia.Ftn.Cl.Models.Data.guide.xml"));
  117:  
  118:                         try
  119:                         {
  120:                             if (streamReader.Peek() != -1) xDocument = System.Xml.Linq.XDocument.Load(streamReader);
  121:                         }
  122:                         catch (Exception)
  123:                         {
  124:                         }
  125:                         finally
  126:                         {
  127:                         }
  128:                     }
  129:                 }
  130:  
  131:                 return xDocument;
  132:             }
  133:         }
  134:  
  135:         ////////////////////////////////////////////////////////////////////////////
  136:         ////////////////////////////////////////////////////////////////////////////    
  137:     }
  138:  
  139:     ////////////////////////////////////////////////////////////////////////////
  140:     ////////////////////////////////////////////////////////////////////////////   
  141: }