Exemplo n.º 1
0
        //
        protected void Begin(MentalTask task)
        {
            Clause clause = task.Message.Clause;

            if (clause != null)
            {
                Entity contextEntity = (Entity)clause[Ent_context];
                if (contextEntity != null)
                {
                    Context importContext = (Context)contextEntity.Value;
                    if (importContext != null)
                    {
                        task.Process.ImportContext(importContext);
                    }
                }
            }
        }
Exemplo n.º 2
0
        public override void OnReply(Task _task)
        {
            MentalTask task = (MentalTask)_task;

            if (Context != task.Context)
            {
                Method clonedTask = (Method)MemberwiseClone();
                clonedTask.Process = task.Process;
                clonedTask.Context = task.Context;
                //
                IEnumerator <TaskStatus> proc       = Procedure;
                Type       iterType                 = proc.GetType();
                MethodInfo procCloner               = iterType.GetMethod("MemberwiseClone", BindingFlags.NonPublic | BindingFlags.FlattenHierarchy | BindingFlags.Instance);
                FieldInfo  taskField                = iterType.GetField("bwxTask");
                IEnumerator <TaskStatus> clonedProc = (IEnumerator <TaskStatus>)procCloner.Invoke(proc, null);
                taskField.SetValue(clonedProc, clonedTask);
                clonedTask.Procedure = clonedProc;
                clonedTask.Schedule();
                return;
            }
            //else
            Schedule();
        }