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

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

CompanyInformation Support class for TentPlay data model

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