// ******************************************************************************//
//  RAYTHEON PROPRIETARY: THIS DOCUMENT CONTAINS DATA OR INFORMATION
//  PROPRIETARY TO RAYTHEON COMPANY AND IS RESTRICTED TO USE ONLY BY PERSONS
//  AUTHORIZED BY RAYTHEON COMPANY IN WRITING TO USE IT. DISCLOSURE TO
//  UNAUTHORIZED PERSONS WOULD LIKELY CAUSE SUBSTANTIAL COMPETITIVE HARM TO
//  RAYTHEON COMPANY''S BUSINESS POSITION. NEITHER SAID DOCUMENT NOR ITS
//  CONTENTS SHALL BE FURNISHED OR DISCLOSED TO OR COPIED OR USED BY PERSONS
//  OUTSIDE RAYTHEON COMPANY WITHOUT THE EXPRESS WRITTEN APPROVAL OF RAYTHEON
//  COMPANY.
//
//  THIS PROPRIETARY NOTICE IS NOT APPLICABLE IF DELIVERED TO THE U.S. GOVERNMENT
//
//  UNPUBLISHED WORK - COPYRIGHT RAYTHEON COMPANY.
//
//  WARNING: THIS DOCUMENT CONTAINS TECHNICAL DATA AND / OR TECHNOLOGY WHOSE
//  EXPORT OR DISCLOSURE TO NON-U.S. PERSONS, WHEREVER LOCATED, IS RESTRICTED
//  BY THE INTERNATIONAL TRAFFIC IN ARMS REGULATIONS (ITAR) (22 C.F.R. SECTION
//  120-130) OR THE EXPORT ADMINISTRATION REGULATIONS (EAR) (15 C.F.R. SECTION
//  730-774). THIS DOCUMENT CANNOT BE EXPORTED (E.G., PROVIDED TO A SUPPLIER
//  OUTSIDE OF THE UNITED STATES) OR DISCLOSED TO A NON-U.S. PERSON, WHEREVER
//  LOCATED, UNTIL A FINAL JURISDICTION AND CLASSIFICATION DETERMINATION HAS
//  BEEN COMPLETED AND APPROVED BY RAYTHEON, AND ANY REQUIRED U.S. GOVERNMENT
//  APPROVALS HAVE BEEN OBTAINED. VIOLATIONS ARE SUBJECT TO SEVERE CRIMINAL
//  PENALTIES.
//
//  DOD 5220.22-M, INDUSTRIAL SECURITY MANUAL, CHAPTER 5, SECTION 1 THROUGH 9 :
//  FOR CLASSIFIED DOCUMENTS FOLLOW THE PROCEDURES IN OR DOD 5200.1-R,
//  INFORMATION SECURITY PROGRAM, CHAPTER 6. FOR UNCLASSIFIED, LIMITED DOCUMENTS
//  DESTROY BY ANY  METHOD THAT WILL PREVENT DISCLOSURE OF CONTENTS OR
//  RECONSTRUCTION OF THE DOCUMENT.
// ****************************************************************************//

using System.Collections.Generic;

namespace Raytheon.Common
{
   /// <summary>
   /// supported file types
   /// </summary>
   public enum ConfigurationFileType
   {
      INI,
      XML,
      TOML,
      JSON,
      YAML,
      OTHER
   }

   /// <summary>
   /// updated version of IConfiguration interface
   /// allows reading and writing generic types as well as lists
   /// </summary>
   public interface IConfigurationFile
   {
      /// <summary>
      /// reads a single generic type value from the file section
      /// if value or section does not exist, will create one and will add the default value
      /// </summary>
      /// <typeparam name="T"></typeparam>
      /// <param name="section"></param>
      /// <param name="key"></param>
      /// <param name="defValue"></param>
      /// <returns></returns>
      T ReadValue<T>(string section, string key, T defValue = default);

      /// <summary>
      /// reads a single generic type value from the file section
      /// if value doesn't exist, throw exception
      /// </summary>
      /// <param name="section"></param>
      /// <param name="key"></param>
      /// <returns></returns>
      string ReadValue(string section, string key);

      /// <summary>
      /// reads a list of generic type values from the file section
      /// if list or section does not exist, will create one and will populate with the default list
      /// </summary>
      /// <typeparam name="T"></typeparam>
      /// <param name="section"></param>
      /// <param name="key"></param>
      /// <param name="defList"></param>
      /// <returns></returns>
      List<T> ReadList<T>(string section, string key, IList<T> defList = null);

      /// <summary>
      /// reads all available keys from the given section of configuration file
      /// </summary>
      /// <param name="section"></param>
      /// <returns></returns>
      List<string> ReadAllKeys(string section);

      /// <summary>
      /// reads all available sections from configuration file
      /// </summary>
      /// <returns></returns>
      List<string> ReadAllSections();

      /// <summary>
      /// writes a single value of a generic type
      /// </summary>
      /// <typeparam name="T"></typeparam>
      /// <param name="section"></param>
      /// <param name="key"></param>
      /// <param name="lineToWrite"></param>
      void WriteValue<T>(string section, string key, T lineToWrite);

      /// <summary>
      /// writes a list of generic values
      /// </summary>
      /// <typeparam name="T"></typeparam>
      /// <param name="section"></param>
      /// <param name="key"></param>
      /// <param name="listToWrite"></param>
      void WriteList<T>(string section, string key, IList<T> listToWrite);

      /// <summary>
      /// checks if the value exists in the given section and given key
      /// </summary>
      /// <param name="section"></param>
      /// <param name="key"></param>
      /// <returns></returns>
      bool ValueExists(string section, string key);

      /// <summary>
      /// configuration file name
      /// </summary>
      string FileName { get; }

      /// <summary>
      /// configuration file type
      /// </summary>
      ConfigurationFileType ConfigurationFileType { get; }
   }

}
