public static void RegisterModule(IModule module) { var config = new ModuleConfiguration(); module.Configure(config); ModuleConfigurations[module.GetType()] = config; RoutesConfig.AddRoute(config.ModuleHttpRoute, module.GetType()); }
public static T CreateAndConfigure <T>(IProfile Profile) { try { IModule res = Activator.CreateInstance(System.Type.GetType(Profile.Type)) as IModule; if (res == null) { ExceptionManager.Throw(new CreateAndConfigureModuleException("Factory: Could not create " + Profile.Type, null)); } res.Configure(Profile); return((T)(res as object)); } catch (Exception ex) { ExceptionManager.Throw(new CreateAndConfigureModuleException("Factory: Could not create or configure or cast " + Profile.Type, ex)); return(default(T)); } }
public void Configure() { // load modules, configure each // note that Configure() may cause the _modules collection to be modified, // hence the while over the linked list in lieu of iteration. LinkedListNode <IModule> node = _modules.First; while (node != null) { IModule module = node.Value; if (_debug) { this.LogTrace("Configuring module: " + module.GetType().Name, LogCategory.INJECTOR); } module.Configure(this); node = node.Next; } }
/// <summary> /// Configure the given module. /// </summary> /// <param name="moduleName">The name of module used to extract configuration</param> /// <param name="module">The IModule to configure</param> private void Configure(string moduleName, IModule module) { var configurationType = module.GetConfigurationType(); // Execute the configure method for IModule // I extract the Get<T> generic function from the TomlTable using reflection. var getMethod = typeof(TomlTable).GetMethods() .Where(x => x.Name == "Get") .First(x => x.IsGenericMethod); // Then I make it generic again var generic = getMethod.MakeGenericMethod(configurationType); // Dots (.) have special meaning in TOML files, so remove them from the config lookup moduleName = moduleName.Replace(".", ""); // Invoke it. The Get<T> method requires the configuration key as param dynamic dynamicConfig = generic.Invoke(_moduleConfigurations, new object[] { moduleName }); // Configure the module with the settings module.Configure(dynamicConfig); }
public static Injector CreateInjector(IModule module) { module.Configure(); return(new Injector(module)); }
public static void RegisterModule(this IServiceCollection services, IModule module) => module.Configure(services);
public IModuleRegistrar RegisterModule(IModule module) { module.Configure(_registry); return(this); }
public static void Setup <TRefrence>(IModule <TRefrence> instance, TRefrence reference) { instance.Configure(reference); instance.Init(); }
public static IWebJobsBuilder AddModule(this IWebJobsBuilder builder, IModule module) { module.Configure(builder); return(builder); }