Пример #1
0
        private void FinalizeTaskCreation()
        {
            foreach (PropertyInfo taskProperty in GetInfo().KnownTasks.Values)
            {
                MyTask task = taskProperty.GetValue(this) as MyTask;

                try
                {
                    if (task == null)
                    {
                        task = (MyTask)Activator.CreateInstance(taskProperty.PropertyType);
                        taskProperty.SetValue(this, task);
                    }

                    try
                    {
                        task.InitPropertiesDefault();
                    }
                    catch (Exception e)
                    {
                        MyLog.ERROR.WriteLine("Task initialization: " + e.Message);
                    }

                    task.GenericOwner = this;
                    task.PropertyName = taskProperty.Name;

                    m_tasks.Add(taskProperty.Name, task);
                }
                catch (Exception e)
                {
                    MyLog.ERROR.WriteLine("Automated task creation failed: " + e.Message);
                }
            }
        }