Professional Applications Programmers/Consultants برمجة واستشارات تطبيقات الإنترنت
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;
   2:  using System.Xml.Linq;
   3:  using System.IO;
   4:  using System.Reflection;
   5:   
   6:  namespace Ia.TentPlay.Cl.Model.Data
   7:  {
   8:      ////////////////////////////////////////////////////////////////////////////
   9:   
  10:      /// <summary publish="true">
  11:      /// CompanyInformation Support class for TentPlay data model
  12:      /// </summary>
  13:      /// 
  14:      /// <remarks> 
  15:      /// Copyright © 2006-2018 Jasem Y. Al-Shamlan (info@ia.com.kw), Internet 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 CompanyInformation
  28:      {
  29:          private static string companyName, companyEmail, companyUrl, applicationCompanyName, applicationCompanyEmail, applicationCompanyUrl, facebookProfileUrl, facebookProfileId, googlePlusUrl, 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 GooglePlusUrl
 122:          {
 123:              get
 124:              {
 125:                  if (string.IsNullOrEmpty(googlePlusUrl)) RetrieveCompanyInformationFromXml();
 126:   
 127:                  return googlePlusUrl;
 128:              }
 129:          }
 130:   
 131:          /// <summary/>
 132:          public static string InstagramUserName
 133:          {
 134:              get
 135:              {
 136:                  if (string.IsNullOrEmpty(instagramUserName)) RetrieveCompanyInformationFromXml();
 137:   
 138:                  return instagramUserName;
 139:              }
 140:          }
 141:   
 142:          /// <summary/>
 143:          public static string TwitterUserName
 144:          {
 145:              get
 146:              {
 147:                  if (string.IsNullOrEmpty(twitterUserName)) RetrieveCompanyInformationFromXml();
 148:   
 149:                  return twitterUserName;
 150:              }
 151:          }
 152:   
 153:          /// <summary/>
 154:          public static string PinterestUserName
 155:          {
 156:              get
 157:              {
 158:                  if (string.IsNullOrEmpty(pinterestUserName)) RetrieveCompanyInformationFromXml();
 159:   
 160:                  return pinterestUserName;
 161:              }
 162:          }
 163:   
 164:          /// <summary/>
 165:          public static string ApplicationDownloadLink
 166:          {
 167:              get
 168:              {
 169:                  if (string.IsNullOrEmpty(applicationDownloadLink)) RetrieveCompanyInformationFromXml();
 170:   
 171:                  return applicationDownloadLink;
 172:              }
 173:          }
 174:   
 175:          ////////////////////////////////////////////////////////////////////////////
 176:   
 177:          /// <summary>
 178:          ///
 179:          /// </summary>
 180:          private static void RetrieveCompanyInformationFromXml()
 181:          {
 182:              XElement xElement;
 183:   
 184:              xElement = XDocument.Element("companyInformation");
 185:   
 186:              companyName = xElement.Element("companyName").Value;
 187:              companyEmail = xElement.Element("companyEmail").Value;
 188:              companyUrl = xElement.Element("companyUrl").Value;
 189:   
 190:              applicationCompanyName = xElement.Element("applicationCompanyName").Value;
 191:              applicationCompanyEmail = xElement.Element("applicationCompanyEmail").Value;
 192:              applicationCompanyUrl = xElement.Element("applicationCompanyUrl").Value;
 193:   
 194:              facebookProfileUrl = xElement.Element("facebookProfileUrl").Value;
 195:              facebookProfileId = xElement.Element("facebookProfileId").Value;
 196:              googlePlusUrl = xElement.Element("googlePlusUrl").Value;
 197:              instagramUserName = xElement.Element("instagramUserName").Value;
 198:              twitterUserName = xElement.Element("twitterUserName").Value;
 199:              pinterestUserName = xElement.Element("pinterestUserName").Value;
 200:   
 201:              applicationDownloadLink = xElement.Element("applicationDownloadLink").Value;
 202:          }
 203:   
 204:          ////////////////////////////////////////////////////////////////////////////
 205:          ////////////////////////////////////////////////////////////////////////////
 206:   
 207:          /// <summary>
 208:          /// 
 209:          /// How to embed and access resources by using Visual C# http://support.microsoft.com/kb/319292/en-us
 210:          /// 
 211:          /// 1. Change the "Build Action" property of your XML file from "Content" to "Embedded Resource".
 212:          /// 2. Add "using System.Reflection".
 213:          /// 3. See sample below.
 214:          /// 
 215:          /// </summary>
 216:   
 217:          private static XDocument XDocument
 218:          {
 219:              get
 220:              {
 221:                  Assembly _assembly;
 222:                  StreamReader streamReader;
 223:   
 224:                  if (xDocument == null)
 225:                  {
 226:                      _assembly = Assembly.GetExecutingAssembly();
 227:                      streamReader = new StreamReader(_assembly.GetManifestResourceStream("Ia.TentPlay.Cl.model.data.company-information.xml"));
 228:   
 229:                      try
 230:                      {
 231:                          if (streamReader.Peek() != -1) xDocument = System.Xml.Linq.XDocument.Load(streamReader);
 232:                      }
 233:                      catch (Exception)
 234:                      {
 235:                      }
 236:                      finally
 237:                      {
 238:                      }
 239:                  }
 240:   
 241:                  return xDocument;
 242:              }
 243:          }
 244:   
 245:          ////////////////////////////////////////////////////////////////////////////
 246:          ////////////////////////////////////////////////////////////////////////////    
 247:      }
 248:  }