<commit_before>﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;

namespace Mozu.Api.ToolKit.Config
{

    public class AppSetting : IAppSetting
    {
        public string AppName { get; private set; }
        public string ApplicationId { get; private set; }
        public string SharedSecret { get; private set; }
        public string SMTPServerUrl { get; private set; }
        public string BaseUrl { get; private set; }
        public string Log4NetConfig { get; private set; }
        public IDictionary<string, Object> Settings { get; private set; }

        public AppSetting()
        {
            InitAppConfig();
        }

        public AppSetting(string configPath, string appName, string environment)
        {
            Init(configPath, appName, environment);
        }

        private void InitAppConfig()
        {
            Settings = new Dictionary<string, object>();

            foreach (var key in ConfigurationManager.AppSettings.AllKeys)
            {
                Settings.Add(key, ConfigurationManager.AppSettings[key]);
            }

            if (Settings.ContainsKey("SmptServer"))
                SMTPServerUrl = Settings["SmptServer"].ToString();

            //if (!Settings.ContainsKey("MozuAuthUrl"))
            //    throw new Exception("MozuAuthUrl is not set in config file");

            //BaseUrl = Settings["BaseUrl"].ToString();


            if (Settings.ContainsKey("AppName"))
                AppName = Settings["AppName"].ToString();

            SetProperties();

            if (String.IsNullOrEmpty(ApplicationId))
                throw new Exception("ApplicationID not set in config file");

            if (String.IsNullOrEmpty(SharedSecret))
                throw new Exception("SharedSecret not set in config file");
        }


        private void SetProperties()
        {
           
            if (Settings.ContainsKey("ApplicationId"))
                ApplicationId = Settings["ApplicationId"].ToString();

            if (Settings.ContainsKey("SharedSecret"))
                SharedSecret = Settings["SharedSecret"].ToString();
        }

        private void Init(string configPath, string appName, string environment)
        {
            AppName = appName;
            var appConfig = Path.Combine(configPath, appName, "App.config");
            Log4NetConfig = Path.Combine(configPath, appName, "log4net.config");
            var commonConfig = Path.Combine(configPath, "Common.config");

            if (!File.Exists(appConfig))
                throw new IOException("Settings File not found");

            if (!File.Exists(commonConfig))
                throw new IOException("Url setting File not found");


            var configFileMap = new ExeConfigurationFileMap { ExeConfigFilename = appConfig };<commit_msg>remove restriction on applicationID and sharedsecret<commit_after>﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;

namespace Mozu.Api.ToolKit.Config
{

    public class AppSetting : IAppSetting
    {
        public string AppName { get; private set; }
        public string ApplicationId { get; private set; }
        public string SharedSecret { get; private set; }
        public string SMTPServerUrl { get; private set; }
        public string BaseUrl { get; private set; }
        public string Log4NetConfig { get; private set; }
        public IDictionary<string, Object> Settings { get; private set; }

        public AppSetting()
        {
            InitAppConfig();
        }

        public AppSetting(string configPath, string appName, string environment)
        {
            Init(configPath, appName, environment);
        }

        private void InitAppConfig()
        {
            Settings = new Dictionary<string, object>();

            foreach (var key in ConfigurationManager.AppSettings.AllKeys)
            {
                Settings.Add(key, ConfigurationManager.AppSettings[key]);
            }

            if (Settings.ContainsKey("SmptServer"))
                SMTPServerUrl = Settings["SmptServer"].ToString();


            if (Settings.ContainsKey("MozuAuthUrl"))
                BaseUrl = Settings["MozuAuthUrl"].ToString();

            if (Settings.ContainsKey("AppName"))
                AppName = Settings["AppName"].ToString();

            SetProperties();
           
        }


        private void SetProperties()
        {
           
            if (Settings.ContainsKey("ApplicationId"))
                ApplicationId = Settings["ApplicationId"].ToString();

            if (Settings.ContainsKey("SharedSecret"))
                SharedSecret = Settings["SharedSecret"].ToString();
        }

        private void Init(string configPath, string appName, string environment)
        {
            AppName = appName;
            var appConfig = Path.Combine(configPath, appName, "App.config");
            Log4NetConfig = Path.Combine(configPath, appName, "log4net.config");
            var commonConfig = Path.Combine(configPath, "Common.config");

            if (!File.Exists(appConfig))
                throw new IOException("Settings File not found");

            if (!File.Exists(commonConfig))
                throw new IOException("Url setting File not found");


            var configFileMap = new ExeConfigurationFileMap { ExeConfigFilename = appConfig };
{'fraction_non_alphanumeric': 0.09557066715677265, 'fraction_numerical': 0.0011027384671935306, 'mean_word_length': 2.189917936694021, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '828038', 'n_tokens_mistral': 1327, 'n_tokens_neox': 1274, 'n_words': 346}