Empeld plugin documentation.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events
pluginbase.Objects.Tasks.TaskObjectExtensions Class Reference

Helper methods for binding tasks on objects More...

Static Public Member Functions

static ICollection
< IScheduledTask
RegisterObjectTasks (this ITaskScheduler scheduler, object obj, Enum scope=null)
 Bind all TaskAttributes on a given object More...

Detailed Description

Helper methods for binding tasks on objects

Member Function Documentation

static ICollection<IScheduledTask> pluginbase.Objects.Tasks.TaskObjectExtensions.RegisterObjectTasks ( this ITaskScheduler  scheduler,
object  obj,
Enum  scope = null 

Bind all TaskAttributes on a given object

The object tasks.
scopeScope of the tasks to be bound
objObject to bind tasks to
21  {
22  var tasks = new List<IScheduledTask>();
23  foreach(var method in obj.GetType().GetAllMethods(x => Attribute.IsDefined(x, typeof(TaskAttribute))))
24  {
25  foreach(var attr in method.GetCustomAttributes(typeof(TaskAttribute), true).OfType<TaskAttribute>())
26  {
27  if (attr.HasScope(scope))
28  tasks.Add(scheduler.ScheduleTask(new WeakTask(method, obj, attr.Frequency, false)));
29  }
30  }
31  return tasks;
32  }

The documentation for this class was generated from the following file: