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

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

Webhook API Controller class.

    1: using Microsoft.Extensions.Configuration;
    2: using System.IO;
    3:  
    4: namespace Ia.Cl.Model
    5: {
    6:     ////////////////////////////////////////////////////////////////////////////
    7:  
    8:     /// <summary publish="true">
    9:     /// Webhook API Controller class.
   10:     /// </summary>
   11:     /// <see cref="https://jamiemaguire.net/index.php/2023/12/23/reading-appsettings-json-from-class-library-projects-in-net/"/>
   12:     /// <remarks> 
   13:     /// Copyright � 2019-2024 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 ApplicationConfiguration
   26:     {
   27:         private static IConfigurationRoot _configuration;
   28:  
   29:         ////////////////////////////////////////////////////////////////////////////
   30:  
   31:         /// <summary>
   32:         ///
   33:         /// </summary>
   34:         static ApplicationConfiguration()
   35:         {
   36:             var builder = new ConfigurationBuilder()
   37:                 .SetBasePath(Directory.GetCurrentDirectory())
   38:                 .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
   39:             _configuration = builder.Build();
   40:         }
   41:  
   42:         ////////////////////////////////////////////////////////////////////////////
   43:  
   44:         /// <summary>
   45:         ///
   46:         /// </summary>
   47:         public static string GetSetting(string key)
   48:         {
   49:             return _configuration[key];
   50:         }
   51:  
   52:         ////////////////////////////////////////////////////////////////////////////
   53:         ////////////////////////////////////////////////////////////////////////////
   54:     }
   55:  
   56:     ////////////////////////////////////////////////////////////////////////////
   57:     ////////////////////////////////////////////////////////////////////////////
   58: }