static BuiltInModules() { var modules = Assembly.GetExecutingAssembly().GetTypes() .Where(p => p.IsSubclassOf(typeof(IodineModule))); foreach (Type type in modules) { if (type.IsDefined(typeof(IodineBuiltinModule), false)) { IodineBuiltinModule attr = (IodineBuiltinModule)type.GetCustomAttributes( typeof(IodineBuiltinModule), false ).First(); IodineModule module = (IodineModule)Activator.CreateInstance(type); BuiltinDocString docstr = type.GetCustomAttribute <BuiltinDocString> (); if (docstr != null) { module.SetAttribute("__doc__", new IodineString(docstr.DocumentationString)); } Modules.Add(attr.Name, module); } } }
static BuiltInModules() { var modules = Assembly.GetExecutingAssembly().GetTypes() .Where(p => p.IsSubclassOf(typeof(IodineModule))); foreach (Type type in modules) { if (type.IsDefined(typeof(IodineBuiltinModule), false)) { IodineBuiltinModule attr = (IodineBuiltinModule)type.GetCustomAttributes( typeof(IodineBuiltinModule), false).First(); Modules.Add(attr.Name, (IodineModule)Activator.CreateInstance(type)); } } }