src/RumahScarlett/RumahScarlett.CommonComponents/ConfigHelper.cs
/// <summary>
/// Method untuk mengambil data dari config file
/// </summary>
/// <param name="keyName">Key / Name Locate</param>
/// <returns>Mengembalikan nilai string</returns>
Method untuk mengambil data dari config file
Method untuk mengambil data dari config file
public static string GetConfig(object keyName)
      {
         var appSetting = string.Empty;
         try
         {
            if (keyName is int)
            {
               appSetting = ConfigurationManager.AppSettings[(int)keyName];
            }
            else
            {
               appSetting = ConfigurationManager.AppSettings[(string)keyName];
            }
         }
         catch (NullReferenceException ex)
         {
            throw ex;
         }
         return appSetting;
      }
public static string GetConfig ( object keyName ) { var appSetting = string . Empty ; try { if ( keyName is int ) { appSetting = ConfigurationManager . AppSettings [ ( int ) keyName ] ; } else { appSetting = ConfigurationManager . AppSettings [ ( string ) keyName ] ; } } catch ( NullReferenceException ex ) { throw ex ; } return appSetting ; }
Method untuk mengambil data dari config file
Method untuk mengambil data dari config file
// Jika key berupa int, maka cast key ke int
Mengembalikan nilai string
Mengembalikan nilai string
keyName
object
Key / Name Locate
Key / Name Locate