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

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

Project Support class for NFC data model

    1: using System;
    2: using System.Xml.Linq;
    3: using System.IO;
    4: using System.Reflection;
    5:  
    6: namespace Ia.Cl.Model.Nfc.Data
    7: {
    8:     ////////////////////////////////////////////////////////////////////////////
    9:  
   10:     /// <summary publish="true">
   11:     /// Project Support class for NFC data model
   12:     /// </summary>
   13:     /// 
   14:     /// <remarks> 
   15:     /// Copyright © 2020-2021 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
   16:     ///
   17:     /// 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
   18:     /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
   19:     ///
   20:     /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
   21:     /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
   22:     /// 
   23:     /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
   24:     /// 
   25:     /// Copyright notice: This notice may not be removed or altered from any source distribution.
   26:     /// </remarks> 
   27:     public static class Project
   28:     {
   29:         private static string companyName, companyEmail, companyUrl, applicationCompanyName, applicationCompanyEmail, applicationCompanyUrl, facebookProfileUrl, facebookProfileId, instagramUserName, twitterUserName, pinterestUserName, applicationDownloadLink;
   30:         private static XDocument xDocument;
   31:  
   32:         /// <summary/>
   33:         public static string CompanyName
   34:         {
   35:             get
   36:             {
   37:                 if (string.IsNullOrEmpty(companyName)) RetrieveCompanyInformationFromXml();
   38:  
   39:                 return companyName;
   40:             }
   41:         }
   42:  
   43:         /// <summary/>
   44:         public static string CompanyEmail
   45:         {
   46:             get
   47:             {
   48:                 if (string.IsNullOrEmpty(companyEmail)) RetrieveCompanyInformationFromXml();
   49:  
   50:                 return companyEmail;
   51:             }
   52:         }
   53:  
   54:         /// <summary/>
   55:         public static string CompanyUrl
   56:         {
   57:             get
   58:             {
   59:                 if (string.IsNullOrEmpty(companyUrl)) RetrieveCompanyInformationFromXml();
   60:  
   61:                 return companyUrl;
   62:             }
   63:         }
   64:  
   65:         /// <summary/>
   66:         public static string ApplicationCompanyName
   67:         {
   68:             get
   69:             {
   70:                 if (string.IsNullOrEmpty(applicationCompanyName)) RetrieveCompanyInformationFromXml();
   71:  
   72:                 return applicationCompanyName;
   73:             }
   74:         }
   75:  
   76:         /// <summary/>
   77:         public static string ApplicationCompanyEmail
   78:         {
   79:             get
   80:             {
   81:                 if (string.IsNullOrEmpty(applicationCompanyEmail)) RetrieveCompanyInformationFromXml();
   82:  
   83:                 return applicationCompanyEmail;
   84:             }
   85:         }
   86:  
   87:         /// <summary/>
   88:         public static string ApplicationCompanyUrl
   89:         {
   90:             get
   91:             {
   92:                 if (string.IsNullOrEmpty(applicationCompanyUrl)) RetrieveCompanyInformationFromXml();
   93:  
   94:                 return applicationCompanyUrl;
   95:             }
   96:         }
   97:  
   98:         /// <summary/>
   99:         public static string FacebookProfileUrl
  100:         {
  101:             get
  102:             {
  103:                 if (string.IsNullOrEmpty(facebookProfileUrl)) RetrieveCompanyInformationFromXml();
  104:  
  105:                 return facebookProfileUrl;
  106:             }
  107:         }
  108:  
  109:         /// <summary/>
  110:         public static string FacebookProfileId
  111:         {
  112:             get
  113:             {
  114:                 if (string.IsNullOrEmpty(facebookProfileId)) RetrieveCompanyInformationFromXml();
  115:  
  116:                 return facebookProfileId;
  117:             }
  118:         }
  119:  
  120:         /// <summary/>
  121:         public static string InstagramUserName
  122:         {
  123:             get
  124:             {
  125:                 if (string.IsNullOrEmpty(instagramUserName)) RetrieveCompanyInformationFromXml();
  126:  
  127:                 return instagramUserName;
  128:             }
  129:         }
  130:  
  131:         /// <summary/>
  132:         public static string TwitterUserName
  133:         {
  134:             get
  135:             {
  136:                 if (string.IsNullOrEmpty(twitterUserName)) RetrieveCompanyInformationFromXml();
  137:  
  138:                 return twitterUserName;
  139:             }
  140:         }
  141:  
  142:         /// <summary/>
  143:         public static string PinterestUserName
  144:         {
  145:             get
  146:             {
  147:                 if (string.IsNullOrEmpty(pinterestUserName)) RetrieveCompanyInformationFromXml();
  148:  
  149:                 return pinterestUserName;
  150:             }
  151:         }
  152:  
  153:         /// <summary/>
  154:         public static string ApplicationDownloadLink
  155:         {
  156:             get
  157:             {
  158:                 if (string.IsNullOrEmpty(applicationDownloadLink)) RetrieveCompanyInformationFromXml();
  159:  
  160:                 return applicationDownloadLink;
  161:             }
  162:         }
  163:  
  164:         ////////////////////////////////////////////////////////////////////////////
  165:  
  166:         /// <summary>
  167:         ///
  168:         /// </summary>
  169:         private static void RetrieveCompanyInformationFromXml()
  170:         {
  171:             XElement xElement;
  172:  
  173:             xElement = XDocument.Element("companyInformation");
  174:  
  175:             companyName = xElement.Element("companyName").Value;
  176:             companyEmail = xElement.Element("companyEmail").Value;
  177:             companyUrl = xElement.Element("companyUrl").Value;
  178:  
  179:             applicationCompanyName = xElement.Element("applicationCompanyName").Value;
  180:             applicationCompanyEmail = xElement.Element("applicationCompanyEmail").Value;
  181:             applicationCompanyUrl = xElement.Element("applicationCompanyUrl").Value;
  182:  
  183:             facebookProfileUrl = xElement.Element("facebookProfileUrl").Value;
  184:             facebookProfileId = xElement.Element("facebookProfileId").Value;
  185:             instagramUserName = xElement.Element("instagramUserName").Value;
  186:             twitterUserName = xElement.Element("twitterUserName").Value;
  187:             pinterestUserName = xElement.Element("pinterestUserName").Value;
  188:  
  189:             applicationDownloadLink = xElement.Element("applicationDownloadLink").Value;
  190:         }
  191:  
  192:         ////////////////////////////////////////////////////////////////////////////
  193:         ////////////////////////////////////////////////////////////////////////////
  194:  
  195:         /// <summary>
  196:         /// 
  197:         /// How to embed and access resources by using Visual C# http://support.microsoft.com/kb/319292/en-us
  198:         /// 
  199:         /// 1. Change the "Build Action" property of your XML file from "Content" to "Embedded Resource".
  200:         /// 2. Add "using System.Reflection".
  201:         /// 3. Manifest resource stream will start with the project namespace, the location of XML file.
  202:         /// 
  203:         /// </summary>
  204:  
  205:         private static XDocument XDocument
  206:         {
  207:             get
  208:             {
  209:                 Assembly assembly;
  210:                 StreamReader streamReader;
  211:  
  212:                 if (xDocument == null)
  213:                 {
  214:                     assembly = Assembly.GetExecutingAssembly();
  215:                     streamReader = new StreamReader(assembly.GetManifestResourceStream("Ia.Cl.Models.Data.Nfc.project.xml"));
  216:  
  217:                     try
  218:                     {
  219:                         if (streamReader.Peek() != -1) xDocument = System.Xml.Linq.XDocument.Load(streamReader);
  220:                     }
  221:                     catch (Exception)
  222:                     {
  223:                     }
  224:                     finally
  225:                     {
  226:                     }
  227:                 }
  228:  
  229:                 return xDocument;
  230:             }
  231:         }
  232:  
  233:         ////////////////////////////////////////////////////////////////////////////
  234:         ////////////////////////////////////////////////////////////////////////////    
  235:     }
  236: }