/// <summary> /// Registers the hooks in the execution context. /// </summary> private void RegisterHooks() { ExecutionContext.Instance.ClearHooks(); List <Type> hooks = TypeLocatorHelper.GetImplementedTypes <IHook>(_testAssembly); foreach (Type type in hooks) { int priority = 0; HookPriorityAttribute hookPriorityAttribute = (HookPriorityAttribute)Attribute.GetCustomAttribute(type, typeof(HookPriorityAttribute)); if (hookPriorityAttribute != null) { priority = hookPriorityAttribute.Priority; } ExecutionContext.Instance.RegisterHook( new HookInstance { Instance = ClassActivatorHelper <IHook> .CreateInstance(type), Priority = priority }); } }
/// <summary> /// Gets the plugins. /// </summary> /// <typeparam name="T"></typeparam> /// <returns>List of plugins.</returns> private List <T> GetPlugins <T>() { List <T> plugins = new List <T>(); foreach (Assembly assembly in _pluginAssemblies) { List <Type> types = TypeLocatorHelper.GetImplementedTypes <T>(assembly); types.ForEach(x => { plugins.Add(ClassActivatorHelper <T> .CreateInstance(x)); }); } return(plugins); }