Exemple #1
0
        private void LoadSettingFromDefaultFile(
            string fullPathToDirectory,
            Environments environment,
            FileFormats expectingFormat
            )
        {
            if (this.SettingsFilename == null)
            {
                return;
            }
            if (this.SettingsFilename.Count <= 0)
            {
                return;
            }

            var Environment = environment.ToString();

            if (!this.SettingsFilename.ContainsKey(Environment))
            {
                return;
            }
            this.LoadSettingFromFile(
                string.Format(@"{0}\{1}", fullPathToDirectory, this.SettingsFilename[Environment]),
                expectingFormat
                );
        }
 public static void UpdateConfigValueByEnvironment(Environments environment, string keyPart, string value)
 {
     try
     {
         var sdkConfigFile    = ConfigurationManager.AppSettings["SDKConfig"];
         var configFileReader = new CustomConfigurationFileReader(sdkConfigFile);
         var config           = configFileReader.Config;
         //System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
         config.AppSettings.Settings.Remove(keyPart + "_" + environment.ToString());
         config.AppSettings.Settings.Add(keyPart + "_" + environment.ToString(), value);
         config.Save(ConfigurationSaveMode.Modified);
     }
     catch (Exception)
     {
         //
     }
 }
        public string GetSharedCultureConfigByEnvironment(string key, Environments environment = Environments.Local)
        {
            var currentEnvironment = (from EnvironmentElement env in _envContextSection.Environments
                                      where env.Name == environment.ToString()
                                      select env)?.FirstOrDefault();
            var currentSite = (from SiteElement site in currentEnvironment?.Sites
                               where site.Name == "Shared"
                               select site)?.FirstOrDefault();
            var config = (from AddElement add in currentSite?.Adds
                          where add.Key == key
                          select add)?.FirstOrDefault();

            return(config?.Value);
        }
        public string GetConfigByCultureAndEnvironment(string key, CultureInfo culture, Environments environment = Environments.Local)
        {
            var currentEnvironment = (from EnvironmentElement env in _envContextSection.Environments
                                      where env.Name.ToLower() == environment.ToString().ToLower()
                                      select env)?.FirstOrDefault();
            var currentSite = (from SiteElement site in currentEnvironment?.Sites
                               where !string.IsNullOrEmpty(site.Culture) && site.Culture == culture.Name
                               select site)?.FirstOrDefault();
            var config = (from AddElement add in currentSite?.Adds
                          where add.Key == key
                          select add)?.FirstOrDefault();

            return(config?.Value);
        }
 public static string GetConfigValueByEnvironment(Environments environment, string keyPart)
 {
     try
     {
         var sdkConfigFile    = ConfigurationManager.AppSettings["SDKConfig"];
         var configFileReader = new CustomConfigurationFileReader(sdkConfigFile);
         var config           = configFileReader.Config;
         var setting          = config.AppSettings.Settings[keyPart + "_" + environment.ToString()].Value;
         return(setting);
     }
     catch (Exception)
     {
         return(null);
     }
 }
 public static string GetConfigValueByEnvironment(Environments environment, string keyPart)
 {
     try
     {
         var sdkConfigFile = ConfigurationManager.AppSettings["SDKConfig"];
         var configFileReader = new CustomConfigurationFileReader(sdkConfigFile);
         var config = configFileReader.Config;
         var setting = config.AppSettings.Settings[keyPart + "_" + environment.ToString()].Value;
         return setting;
     }
     catch (Exception)
     {
         return null;
     }
 }
        public SimpleClient(Environments environment, IConfiguration configuration
                            )
        {
            _environment  = environment;
            Configuration = configuration;

            var factory = DIContainer.Current.Resolve <IEnvironmentFactory>();
            var ee      = factory.GetEnvironment(environment);

            configuration.Environment = ee;
            DIContainer.Current.RegisterInstance(ee);
            DIContainer.Current.RegisterInstance(ee, environment.ToString());
            DIContainer.Current.RegisterInstance(configuration);
            SdkClient    = DIContainer.Current.Resolve <IClient>();
            _authManager = DIContainer.Current.Resolve <IAuthorizationManager>();
        }
Exemple #8
0
 private bool IsThisEnvironment(Environments environment)
 {
     return(this.IsThisEnvironment(environment.ToString()));
 }
 public static void SetConfigEnvironment(Environments environmentId)
 {
     UpdateConfigSetting("Environment", environmentId.ToString());
 }
Exemple #10
0
        public static void UpdateConfigValueByEnvironment(Environments environment, string keyPart, string value)
        {
            try
            {
                var sdkConfigFile = ConfigurationManager.AppSettings["SDKConfig"];
                var configFileReader = new CustomConfigurationFileReader(sdkConfigFile);
                var config = configFileReader.Config;
                //System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
                config.AppSettings.Settings.Remove(keyPart + "_" + environment.ToString());
                config.AppSettings.Settings.Add(keyPart + "_" + environment.ToString(), value);
                config.Save(ConfigurationSaveMode.Modified);
            }
            catch (Exception)
            {
                //
            }

        }
Exemple #11
0
 public static void SetConfigAppId(Environments environment, string AppId)
 {
     UpdateConfigSetting("AppId_" + environment.ToString(), AppId);
 }
 public ContainerFactory(Environments environment) : this(environment.ToString())
 {
 }
Exemple #13
0
 public static void SetConfigAppId(Environments environment, string AppId)
 {
     UpdateConfigSetting("AppId_" + environment.ToString(), AppId);
 }
Exemple #14
0
 public static void SetConfigEnvironment(Environments environmentId)
 {
     UpdateConfigSetting("Environment", environmentId.ToString());
 }
Exemple #15
0
 public override string ToString()
 {
     return((EnvironmentName ?? Environment.ToString()) + "; " + RenderTarget + "; " + ID);
 }