Exemple #1
0
        /// <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
                });
            }
        }
Exemple #2
0
        /// <summary>
        /// Gets the log plugins.
        /// </summary>
        /// <returns></returns>
        private List <ILogPlugin> GetLogPlugins()
        {
            List <ILogPlugin> plugins = GetPlugins <ILogPlugin>();

            if (!plugins.Any())
            {
                plugins.Add(
                    ClassActivatorHelper <BasicFileLogPlugin>
                    .CreateInstance(
                        typeof(BasicFileLogPlugin),
                        Path.Combine(Path.GetTempPath(), "YellowJacket")));     // TODO: need to have this in the input args
            }
            return(plugins);
        }
Exemple #3
0
        /// <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);
        }