)>}]
شركة التطبيقات المتكاملة لتصميم وبرمجة البرمجيات الخاصة ش.ش.و.
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:     /// </remarks> 
   20:     public class Guide
   21:     {
   22:         private static XDocument xDocument;
   23:  
   24:         private static readonly object objectLock = new object();
   25:  
   26:         ////////////////////////////////////////////////////////////////////////////
   27:  
   28:         /// <summary>
   29:         ///
   30:         /// </summary>
   31:         public Guide() { }
   32:  
   33:         ////////////////////////////////////////////////////////////////////////////
   34:  
   35:         /// <summary>
   36:         ///
   37:         /// </summary>
   38:         public static List<string> FrequentAnswerList()
   39:         {
   40:             var list = (from c in XDocument.Elements("guide").Elements("frequentAnswers").Elements("answer")
   41:                         select c.Value).ToList();
   42:  
   43:             return list;
   44:         }
   45:  
   46:         ////////////////////////////////////////////////////////////////////////////
   47:  
   48:         /// <summary>
   49:         ///
   50:         /// </summary>
   51:         public static List<string> ArticleList()
   52:         {
   53:             var list = (from c in XDocument.Elements("articles").Elements("article")
   54:                         select c.Value).ToList();
   55:  
   56:             return list;
   57:         }
   58:  
   59:         /*
   60:         ////////////////////////////////////////////////////////////////////////////
   61: 
   62:         /// <summary>
   63:         ///
   64:         /// </summary>
   65:         public static Dictionary<int, string> CategoryDictionary
   66:         {
   67:             get
   68:             {
   69:                 Dictionary<int, string> dictionary;
   70: 
   71:                 dictionary = new Dictionary<int, string>(100);
   72: 
   73:                 dictionary = (from c in XDocument.Elements("report").Elements("category")
   74:                               select new { Id = int.Parse(c.Attribute("id").Value), Name = c.Attribute("name").Value }).ToDictionary(r => r.Id, r => r.Name);
   75: 
   76:                 return dictionary;
   77:             }
   78:         }
   79:         */
   80:  
   81:         ////////////////////////////////////////////////////////////////////////////
   82:         ////////////////////////////////////////////////////////////////////////////
   83:  
   84:         /// <summary>
   85:         /// 
   86:         /// How to embed and access resources by using Visual C# http://support.microsoft.com/kb/319292/en-us
   87:         /// 
   88:         /// 1. Change the "Build Action" property of your XML file from "Content" to "Embedded Resource".
   89:         /// 2. Add "using System.Reflection".
   90:         /// 3. Manifest resource stream will start with the project namespace, the location of XML file.
   91:         /// 
   92:         /// </summary>
   93:  
   94:         public static XDocument XDocument
   95:         {
   96:             get
   97:             {
   98:                 if (xDocument == null)
   99:                 {
  100:                     lock (objectLock)
  101:                     {
  102:                         Assembly assembly;
  103:                         StreamReader streamReader;
  104:  
  105:                         assembly = Assembly.GetExecutingAssembly();
  106:                         streamReader = new StreamReader(assembly.GetManifestResourceStream("Ia.Ftn.Cl.Models.Data.guide.xml"));
  107:  
  108:                         try
  109:                         {
  110:                             if (streamReader.Peek() != -1) xDocument = System.Xml.Linq.XDocument.Load(streamReader);
  111:                         }
  112:                         catch (Exception)
  113:                         {
  114:                         }
  115:                         finally
  116:                         {
  117:                         }
  118:                     }
  119:                 }
  120:  
  121:                 return xDocument;
  122:             }
  123:         }
  124:  
  125:         ////////////////////////////////////////////////////////////////////////////
  126:         ////////////////////////////////////////////////////////////////////////////    
  127:     }
  128:  
  129:     ////////////////////////////////////////////////////////////////////////////
  130:     ////////////////////////////////////////////////////////////////////////////   
  131: }