Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Version {
- private Dictionary<string, Module> LoadedModules = new ...;
- public GetModule(Type paramModuleType) {
- // If instance yet was created, so return it.
- if(LoadedModules.ContainsKey(paramModuleType.Name)) {
- return LoadedModules[paramModuleType.Name];
- }
- // Else, it will be created and stored for next call.
- return LoadedModules[paramModuleType.Name] =
- (Module) Activator.CreateInstance(paramModuleType, this);
- }
- }
- var clientModule = ClientModule.From(versionInstance);
- public abstract class Module {
- public Version Version;
- protected Module(Version paramVersion) {
- Version = paramVersion;
- }
- static public Module From(Version paramVersion) {
- return paramVersion.GetModule(typeof(Module));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement