Advertisement
Guest User

Untitled

a guest
Mar 1st, 2015
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. class Version {
  2. private Dictionary<string, Module> LoadedModules = new ...;
  3.  
  4. public GetModule(Type paramModuleType) {
  5. // If instance yet was created, so return it.
  6. if(LoadedModules.ContainsKey(paramModuleType.Name)) {
  7. return LoadedModules[paramModuleType.Name];
  8. }
  9.  
  10. // Else, it will be created and stored for next call.
  11. return LoadedModules[paramModuleType.Name] =
  12. (Module) Activator.CreateInstance(paramModuleType, this);
  13. }
  14. }
  15.  
  16. var clientModule = ClientModule.From(versionInstance);
  17.  
  18. public abstract class Module {
  19. public Version Version;
  20.  
  21. protected Module(Version paramVersion) {
  22. Version = paramVersion;
  23. }
  24.  
  25. static public Module From(Version paramVersion) {
  26. return paramVersion.GetModule(typeof(Module));
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement