Created
April 6, 2022 13:41
-
-
Save angusbreno/d107aadf7077ec3f8de12272beb8fc06 to your computer and use it in GitHub Desktop.
exemplo do exemplo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace Naylah | |
{ | |
public class ConfigurationStore : Dictionary<string, object> | |
{ | |
public ConfigurationStore(IEnumerable<IConfigurationSource> configurationSources) | |
{ | |
} | |
public async Task Initialize() | |
{ | |
foreach (var config in configurationSources) | |
{ | |
foreach (var configitem in config.GetConfigurations()) | |
{ | |
//verificar se existe para override.... | |
Upsert(configitem.Key, configitem.Value); | |
} | |
} | |
} | |
} | |
public interface IConfigurationSource | |
{ | |
Task<Dictionary<string, object>> GetConfigurations(); | |
} | |
public class ProcessEnvConfigurationSource : IConfigurationSource | |
{ | |
public Dictionary<string, object> GetConfigurations() | |
{ | |
Dictionary<string, object> processEnvConfigs = new Dictionary<string, object>(); | |
///for/// | |
//...... | |
return processEnvConfigs; | |
} | |
} | |
public class IndexScriptVariableConfigurationSource : IConfigurationSource | |
{ | |
public Dictionary<string, object> GetConfigurations() | |
{ | |
///pegar info, descriptigravar | |
Dictionary<string, object> IndexScriptVariablConfigs = new Dictionary<string, object>(); | |
///for/// | |
//...... | |
return IndexScriptVariablConfigs; | |
} | |
} | |
public class RestConfigurationSource : IConfigurationSource | |
{ | |
public Dictionary<string, object> GetConfigurations() | |
{ | |
//http | |
///pegar info, descriptigravar | |
Dictionary<string, object> IndexScriptVariablConfigs = new Dictionary<string, object>(); | |
///for/// | |
//...... | |
return IndexScriptVariablConfigs; | |
} | |
} | |
//// | |
var s1 = new ProcessEnvConfigurationSource(); | |
var s2 = new IndexScriptVariableConfigurationSource(); | |
var store = new ConfigurationStore(new List<>{s1, s2}); | |
store.InitAsyc(); | |
var phurl = store["powerhuburl"] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment