Skip to content

Instantly share code, notes, and snippets.

@saitonakamura
Created February 28, 2019 10:31
Show Gist options
  • Save saitonakamura/0a2dd2170257c9ae04214d52b83969b0 to your computer and use it in GitHub Desktop.
Save saitonakamura/0a2dd2170257c9ae04214d52b83969b0 to your computer and use it in GitHub Desktop.
void Main()
{
var c = new ConfigStuff(new ConfigResolver());
c.GetNormalized().Dump();
}
// Define other methods and classes here
class ConfigStuff {
private readonly Lazy<object> _configNormalizedLazy;
public ConfigStuff(IConfigResolver configResolver)
{
_configNormalizedLazy = new Lazy<object>(() => Normalize(configResolver.Get()));
}
public object GetNormalized() {
return _configNormalizedLazy.Value;
}
private object Normalize(dynamic config) {
var normalizedConfig = new { url = config.url.ToUpper() };
return normalizedConfig;
}
}
interface IConfigResolver {
object Get();
}
class ConfigResolver : IConfigResolver {
public object Get() {
return new { url = "http://lal" };
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment