Created
February 1, 2018 10:17
-
-
Save FNGgames/d386a7ab8fe2b9b748133a3165917037 to your computer and use it in GitHub Desktop.
Context helpers
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
public static class ContextHelpers | |
{ | |
private static readonly Dictionary<string, IContext> _contextsLookup = new Dictionary<string, IContext>(); | |
public static IContext GetContextByName(this Contexts contexts, string name) | |
{ | |
if (_contextsLookup.Count == 0) SetContextsDictionary(contexts); | |
return _contextsLookup[name]; | |
} | |
private static void SetContextsDictionary(Contexts contexts) | |
{ | |
foreach (var context in contexts.allContexts) | |
{ | |
_contextsLookup.Add(context.contextInfo.name, context); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment