Exemplo n.º 1
0
        public void Run(Recipe recipe, Task task, params object[] parameters )
        {
            //TODO: Tasks should run in their own appdomain?
            //      We need to create an app domain that has the
            //      base dir the same as the target assembly

            var recipeInstance = Activator.CreateInstance(recipe.Class);
            SetContextualInformationIfInheritsRecipeBase(recipeInstance);
            task.Method.Invoke(recipeInstance, parameters);
        }
Exemplo n.º 2
0
        private static void AddTasksToRecipe(Type type, Recipe recipe)
        {
            //loop through methods in class
            foreach(var method in type.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly ))
            {
                var dependsAttribute = method.GetCustomAttribute<DependsOnAttribute>(false);
                var dependencies = new string[] {};

                if (dependsAttribute != null)
                    dependencies = dependsAttribute.Dependencies;

                //get the task based on attribute contents
                Task t = CreateTaskFromMethod(method);

                //build list of dependent tasks
                CreateDependentTasks(type, dependencies, t);

                //add the task to the recipe
                recipe.Tasks.Add(t);
            }
        }
Exemplo n.º 3
0
        private static void AddTasksToRecipe(Type type, Recipe recipe)
        {
            //loop through methods in class
            foreach(var method in type.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly ))
            {
                //get the custom attributes on the method
                var foundAttributes = method.GetCustomAttributes(typeof(TaskAttribute), false);

                if(foundAttributes.Length > 1)
                    throw new Exception("Should only be one task attribute on a method");

                //if none, skp to the next method
                if (foundAttributes.Length == 0)
                    continue;

                var taskAttribute = foundAttributes[0] as TaskAttribute;

                if (taskAttribute == null)
                    throw new Exception("couldn't cast TaskAttribute correctly, more that one assembly loaded?");

                //get the task based on attribute contents
                Task t = CreateTaskFromAttribute(method, taskAttribute);

                //build list of dependent tasks
                CreateDependentTasks(type, taskAttribute, t);

                //add the task to the recipe
                recipe.Tasks.Add(t);
            }
        }