-
-
Save saitonakamura/0a2dd2170257c9ae04214d52b83969b0 to your computer and use it in GitHub Desktop.
This file contains 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
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