)>}]
شركة التطبيقات المتكاملة لتصميم وبرمجة البرمجيات الخاصة ش.ش.و.
Integrated Applications Programming Company
Skip Navigation LinksHome » Code Library » CompanyInformation

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