Esempio n. 1
0
        // This dialogue greets the user (as a result of face recognition input
        // from the vision process.
        private void GenerateGreetingDialogue()
        {
            Boolean isAlwaysAvailable           = true;
            double  inputTimeoutInterval        = double.MaxValue; // No reason to have a timeout here, since the dialogue is _activated_ upon receiving matching input.
            int     inputMaximumRepetitionCount = 1;               // Greet the user only once.

            Dialogue greetingDialogue = new Dialogue("GreetingDialogue", isAlwaysAvailable);

            // The agent checks if a face has just been detected.
            // NOTE: This requires, of course, that the Vision process should send the
            // appropriate message, in this case "FaceDetected".
            InputItem itemGD1 = new InputItem("GD1", null, inputTimeoutInterval, inputMaximumRepetitionCount, "", "");

            itemGD1.AllowVisionInput = true; // Default value = false. Must set to true for this dialogue item.
            //itemGD1.DoReset = false; // Make sure that the greeting runs only once.
            InputAction inputActionGD1 = new InputAction(greetingDialogue.Context, "GD2");

            inputActionGD1.RequiredSource = AgentConstants.VISION_INPUT_TAG;
            inputActionGD1.PatternList.Add(new Pattern("FaceDetected"));
            itemGD1.InputActionList.Add(inputActionGD1);
            greetingDialogue.DialogueItemList.Add(itemGD1);
            OutputItem   itemGD2         = new OutputItem("GD2", AgentConstants.SPEECH_OUTPUT_TAG, null, false, 1);
            OutputAction outputActionGD2 = new OutputAction("", "");

            outputActionGD2.PatternList.Add(new Pattern("Hello user"));
            itemGD2.OutputAction = outputActionGD2;
            greetingDialogue.DialogueItemList.Add(itemGD2);

            agent.DialogueList.Add(greetingDialogue);
        }
 public DirectionActionChange(Hand hand, OutputAction action, Direction direction, bool state)
 {
     this.hand      = hand;
     this.action    = action;
     this.direction = direction;
     this.state     = state;
 }
Esempio n. 3
0
 public static IDisposable BindAction <T>(this IReactive <UIView> reactive, OutputAction <T> action)
 {
     return(Observable.Using(
                () => action.Enabled.Subscribe(e => { reactive.Base.UserInteractionEnabled = e; }),
                _ => reactive.Base.Rx().Tap()
                )
            .Subscribe(action.Inputs));
 }
Esempio n. 4
0
        static void Main()
        {
            var utils = new Utilities();
            var unsortedCollection = utils.GetRandomNumbersCollection(elementsCount, 100);

            OutputAction <int> outputAction = GetOutputAction <int>(utils);

            PerfromSort(new MergeSorter <int>(), unsortedCollection, outputAction, isAscendingSort);
            PerfromSort(new QuickSorter <int>(), unsortedCollection, outputAction, isAscendingSort);

            Console.ReadKey();
        }
        public async Task ArrayToTableString(byte[] output, int outputLenth = 0)
        {
            if (output.Length == 0)
            {
                throw new ArgumentException("File is empty");
            }

            if (OutputActionAsync.GetInvocationList() == null || OutputActionAsync.GetInvocationList().Length == 0)
            {
                isProgressAsync = false;
            }
            else
            {
                isProgressAsync = true;
            }

            var writingLenth = outputLenth != 0 ? outputLenth : output.Length;

            for (int i = 0; i < writingLenth; i++)
            {
                if (i % byteLineWidth == 0 && i != 0)
                {
                    if (isProgressAsync)
                    {
                        await OutputActionAsync?.Invoke("|\n");

                        await OutputActionAsync?.Invoke($"{RowLine}\n");
                    }
                    else
                    {
                        OutputAction?.Invoke("|\n");
                        OutputAction?.Invoke($"{RowLine}\n");
                    }
                }
                if (isProgressAsync)
                {
                    await OutputActionAsync?.Invoke(AlignCentre(output[i]));
                }
                else
                {
                    OutputAction?.Invoke(AlignCentre(output[i]));
                }

                WritingProgess = (double)(i + 1) / writingLenth;
            }

            Finalize?.Invoke();
        }
Esempio n. 6
0
    /// <summary>
    /// Sets the raw output.
    /// Used internally.
    /// </summary>
    /// <param name="rawOutput">The raw output.</param>
    void ICanParseOutput.SetRawOutput(IEnumerable <string>?rawOutput)
    {
        string[] outputlines = Array.Empty <string>();
        T?       parsed      = default;

        if (rawOutput != null)
        {
            outputlines = rawOutput.ToArray();
            parsed      = OutputParser.Parse(outputlines);
        }

        RawOutputAction?.Invoke(outputlines);
        if (parsed != null)
        {
            OutputAction?.Invoke(parsed);
        }
    }
Esempio n. 7
0
        private static void PerfromSort <T>(SorterBase <T> sorter, ICollection <T> unsortedCollection,
                                            OutputAction <T> outputAction, bool isAsc)
            where T : IComparable
        {
            DisplaySortCaption(sorter, unsortedCollection.Count);

            outputAction(unsortedCollection, nameof(unsortedCollection));

            sw.Start();
            var sortedCollection = sorter.Sort(unsortedCollection, isAsc);

            sw.Stop();

            outputAction(sortedCollection, nameof(sortedCollection));

            DisplaySortPerformanceResults();
        }
Esempio n. 8
0
        public static IDisposable BindAction <T>(this IReactive <View> reactive, OutputAction <T> action, ButtonEventType eventType = ButtonEventType.Tap)
        {
            IObservable <Unit> eventObservable = Observable.Empty <Unit>();

            switch (eventType)
            {
            case ButtonEventType.Tap:
                eventObservable = reactive.Base.Rx().Tap();
                break;

            case ButtonEventType.LongPress:
                eventObservable = reactive.Base.Rx().LongPress();
                break;
            }

            return(Observable.Using(
                       () => action.Enabled.Subscribe(e => { reactive.Base.Enabled = e; }),
                       _ => eventObservable
                       )
                   .Subscribe(action.Inputs));
        }
        public async Task ArrayToTableString(bool[] output, int outputLenth = 0)
        {
            if (output.Length == 0)
            {
                throw new ArgumentException("File is empty");
            }

            var writingLenth = outputLenth != 0 ? outputLenth : output.Length;

            for (int i = 0; i < writingLenth; i++)
            {
                if (i % binaryLineWidth == 0 && i != 0)
                {
                    if (isProgressAsync)
                    {
                        await OutputActionAsync?.Invoke("|\n");

                        await OutputActionAsync?.Invoke($"{RowLine}\n");
                    }
                    else
                    {
                        OutputAction?.Invoke("|\n");
                        OutputAction?.Invoke($"{RowLine}\n");
                    }
                }
                if (isProgressAsync)
                {
                    await OutputActionAsync?.Invoke($"| {Convert.ToInt16(output[i])} ");
                }
                else
                {
                    OutputAction?.Invoke($"| {Convert.ToInt16(output[i])} ");
                }

                WritingProgess = (double)(i + 1) / writingLenth;
            }

            Finalize?.Invoke();
        }
Esempio n. 10
0
 public OutputAction <TElement> FromFunction <TElement>(Func <TElement> action)
 {
     return(OutputAction <TElement> .FromFunction(action, schedulerProvider.MainScheduler));
 }
        public DiagnosticPipeline(
            IHealthReporter healthReporter,
            IReadOnlyCollection <IObservable <EventData> > inputs,
            IReadOnlyCollection <IFilter> globalFilters,
            IReadOnlyCollection <EventSink> sinks,
            DiagnosticPipelineConfiguration pipelineConfiguration = null,
            bool disposeDependencies    = false,
            TaskScheduler taskScheduler = null)
        {
            Requires.NotNull(healthReporter, nameof(healthReporter));
            Requires.NotNull(inputs, nameof(inputs));
            Requires.Argument(inputs.Count > 0, nameof(inputs), "There must be at least one input");
            Requires.NotNull(sinks, nameof(sinks));
            Requires.Argument(sinks.Count > 0, nameof(sinks), "There must be at least one sink");

            this.batcherTimerDisposalLock = new object();
            this.pipelineConfiguration    = pipelineConfiguration ?? new DiagnosticPipelineConfiguration();
            taskScheduler = taskScheduler ?? TaskScheduler.Current;

            // An estimatie how many batches of events to allow inside the pipeline.
            // We want to be able to process full buffer of events, but also have enough batches in play in case of high concurrency.
            int MaxNumberOfBatchesInProgress = Math.Max(
                5 * this.pipelineConfiguration.MaxConcurrency,
                this.pipelineConfiguration.PipelineBufferSize / this.pipelineConfiguration.MaxEventBatchSize);

            this.Inputs = inputs;
            this.Sinks  = sinks;

            // Just play nice and make sure there is always something to enumerate on
            this.GlobalFilters = globalFilters ?? new IFilter[0];

            this.HealthReporter          = healthReporter;
            this.cancellationTokenSource = new CancellationTokenSource();
            var propagateCompletion = new DataflowLinkOptions()
            {
                PropagateCompletion = true
            };

            // One disposable for each input subscription.
            this.inputSubscriptions = new List <IDisposable>(inputs.Count);

            var inputBuffer = new BufferBlock <EventData>(
                new DataflowBlockOptions()
            {
                BoundedCapacity   = this.pipelineConfiguration.PipelineBufferSize,
                CancellationToken = this.cancellationTokenSource.Token,
                TaskScheduler     = taskScheduler
            });

            this.pipelineHead = inputBuffer;

            var batcher = new BatchBlock <EventData>(
                this.pipelineConfiguration.MaxEventBatchSize,
                new GroupingDataflowBlockOptions()
            {
                BoundedCapacity   = this.pipelineConfiguration.PipelineBufferSize,
                CancellationToken = this.cancellationTokenSource.Token,
                TaskScheduler     = taskScheduler
            }
                );

            inputBuffer.LinkTo(batcher, propagateCompletion);

            ISourceBlock <EventData[]> sinkSource;
            FilterAction filterTransform;

            if (this.GlobalFilters.Count > 0)
            {
                filterTransform = new FilterAction(
                    this.GlobalFilters,
                    this.cancellationTokenSource.Token,
                    MaxNumberOfBatchesInProgress,
                    this.pipelineConfiguration.MaxConcurrency,
                    healthReporter,
                    taskScheduler);
                var globalFiltersBlock = filterTransform.GetFilterBlock();
                batcher.LinkTo(globalFiltersBlock, propagateCompletion);
                sinkSource = globalFiltersBlock;
            }
            else
            {
                sinkSource = batcher;
            }

            bool usingBroadcastBlock = sinks.Count > 1;

            if (usingBroadcastBlock)
            {
                var broadcaster = new BroadcastBlock <EventData[]>(
                    (events) => events?.Select((e) => e.DeepClone()).ToArray(),
                    new DataflowBlockOptions()
                {
                    BoundedCapacity   = MaxNumberOfBatchesInProgress,
                    CancellationToken = this.cancellationTokenSource.Token,
                    TaskScheduler     = taskScheduler
                });
                sinkSource.LinkTo(broadcaster, propagateCompletion);
                sinkSource = broadcaster;
            }

            this.outputCompletionTasks = new List <Task>(sinks.Count);
            foreach (var sink in sinks)
            {
                ISourceBlock <EventData[]> outputSource = sinkSource;

                if (sink.Filters != null && sink.Filters.Count > 0)
                {
                    filterTransform = new FilterAction(
                        sink.Filters,
                        this.cancellationTokenSource.Token,
                        MaxNumberOfBatchesInProgress,
                        this.pipelineConfiguration.MaxConcurrency,
                        healthReporter,
                        taskScheduler);
                    var filterBlock = filterTransform.GetFilterBlock();

                    if (usingBroadcastBlock)
                    {
                        var lossReportingPropagator = new LossReportingPropagatorBlock <EventData[]>(this.HealthReporter);
                        sinkSource.LinkTo(lossReportingPropagator, propagateCompletion);
                        lossReportingPropagator.LinkTo(filterBlock, propagateCompletion);
                    }
                    else
                    {
                        sinkSource.LinkTo(filterBlock, propagateCompletion);
                    }
                    outputSource = filterBlock;
                }
                else if (usingBroadcastBlock)
                {
                    var lossReportingPropagator = new LossReportingPropagatorBlock <EventData[]>(this.HealthReporter);
                    sinkSource.LinkTo(lossReportingPropagator, propagateCompletion);
                    outputSource = lossReportingPropagator;
                }

                OutputAction outputAction = new OutputAction(
                    sink.Output,
                    this.cancellationTokenSource.Token,
                    MaxNumberOfBatchesInProgress,
                    this.pipelineConfiguration.MaxConcurrency,
                    healthReporter,
                    taskScheduler);
                var outputBlock = outputAction.GetOutputBlock();
                outputSource.LinkTo(outputBlock, propagateCompletion);
                this.outputCompletionTasks.Add(outputBlock.Completion);
            }

            IObserver <EventData> inputBufferObserver = new TargetBlockObserver <EventData>(inputBuffer, this.HealthReporter);

            foreach (var input in inputs)
            {
                this.inputSubscriptions.Add(input.Subscribe(inputBufferObserver));
            }

            this.disposed            = false;
            this.disposeDependencies = disposeDependencies;

            this.batcherTimer = new Timer(
                (_) => {
                try
                {
                    lock (this.batcherTimerDisposalLock)
                    {
                        if (!this.disposed)
                        {
                            batcher.TriggerBatch();

                            this.batcherTimer.Change(dueTime: TimeSpan.FromMilliseconds(this.pipelineConfiguration.MaxBatchDelayMsec), period: Timeout.InfiniteTimeSpan);
                        }
                    }
                }
                catch { }
            },
                state: null,
                dueTime: TimeSpan.FromMilliseconds(this.pipelineConfiguration.MaxBatchDelayMsec),
                period: Timeout.InfiniteTimeSpan);
        }
 public PushModelOutputAction(OutputAction child = null)
     : base(child)
 {
 }
        private ActionsControllerPressManager AddOutputActionHandler(StateChangeHandlerDelegate <Vector2ActionChangeEvent> handler, OutputAction outputAction)
        {
            AddHandler(handler,
                       Vector2AxisActionChangeComparator,
                       ActionsController.Vector2ActionChange[outputAction]);

            return(this);
        }
Esempio n. 14
0
        public void Execute()
        {
            Debug.WriteLine("Execution start");
            // init registers
            int a = 0; // accumulator
            int c = 0; // code pointer
            int d = 0; // data pointer

            while (true)
            {
                int instruction = Memory[c];
                if (instruction > 32 && instruction < 127) // [33-126]
                {
                    int  opCodeEncrypted = (c + instruction - 33) % 94;
                    char opCode          = DecryptionTable[opCodeEncrypted];
                    Debug.WriteLine($"Opcode:{opCodeEncrypted} => {opCode}");

                    // Perform instruction
                    switch (opCode)
                    {
                    case 'j':     // 40: mov d,[d]
                        Debug.WriteLine("Instruction: MOV");
                        d = Memory[d];
                        break;

                    case 'i':     // 4: jmp[d]
                        Debug.WriteLine("Instruction: JMP");
                        c = Memory[d];
                        break;

                    case '*':     // 39: rotr [d] | mov a,d
                        Debug.WriteLine("Instruction: ROTR");
                        Memory[d] = Memory[d] / 3 + Memory[d] % 3 * 19683;
                        a         = Memory[d];
                        break;

                    case 'p':     // 62: crazy [d],a | mov a,[d]
                        Debug.WriteLine("Instruction: CRAZY");
                        Memory[d] = Crazy(a, Memory[d]);
                        a         = Memory[d];
                        break;

                    case '<':     // 5: stdout
                        Debug.WriteLine("Instruction: STDOUT");
                        OutputAction?.Invoke((char)(a & 0xFF));
                        break;

                    case '/':     // 23: stdin
                        Debug.WriteLine("Instruction: STDIN");
                        char?input = InputFunc?.Invoke();
                        if (input == null)
                        {
                            Debug.WriteLine("Null input");
                        }
                        else
                        {
                            if (input.Value == '\n')
                            {
                                a = 10;
                            }
                            //else if (input == EOF) // TODO
                            //  a = int.MaxValue;
                            else
                            {
                                a = input.Value;
                            }
                        }
                        break;

                    case 'v':     // 81: end
                        Debug.WriteLine("Instruction: END OF PROGRAM");
                        return;

                    case 'o':     // 68: nop
                        Debug.WriteLine("Instruction: NOP");
                        break;

                    default:
                        Debug.WriteLine("Instruction: INVALID");
                        break;
                    }

                    // Encrypt instruction
                    Memory[c] = EncryptionTable[Memory[c] - 33];
                    // Advance c and d
                    if (c == MaxValue)
                    {
                        c = 0;
                    }
                    else
                    {
                        c++;
                    }
                    if (d == MaxValue)
                    {
                        d = 0;
                    }
                    else
                    {
                        d++;
                    }
                }
                else
                {
                    Debug.WriteLine($"Skipping invalid instruction {instruction}");
                }
            }
        }
 public ActionChange(Hand hand, OutputAction action, bool state)
 {
     this.hand   = hand;
     this.action = action;
     this.state  = state;
 }
Esempio n. 16
0
        public void Execute()
        {
            Random random = new Random();

            int maxX = Grid.GetLength(1);
            int maxY = Grid.GetLength(0);

            int        x          = 0;
            int        y          = 0;
            Directions direction  = 0;
            bool       stringMode = false;
            bool       skip       = false;

            while (true)
            {
                // cyclic boundaries
                if (x < 0 || y < 0 || x >= maxX || y >= maxY)
                {
                    switch (direction)
                    {
                    case Directions.Right:
                        x = 0;
                        break;

                    case Directions.Down:
                        y = 0;
                        break;

                    case Directions.Left:
                        x = maxX - 1;
                        break;

                    case Directions.Up:
                        y = maxY - 1;
                        break;
                    }
                }
                //
                char instruction = Grid[y, x];
                Debug.WriteLine($"Instruction at {x},{y} = {instruction}  string:{stringMode} skip:{skip}");

                // skip or not
                if (skip)
                {
                    skip = false; // skip instruction
                    Debug.WriteLine("BRIDGE OFF: skipping current instruction.");
                }
                // string mode or not
                else if (stringMode)
                {
                    // push instruction as string
                    if (instruction == '"')
                    {
                        Debug.WriteLine("STRING MODE OFF");
                        stringMode = false;
                    }
                    else
                    {
                        int operand = instruction;
                        Debug.WriteLine($"STRING MODE: PUSH {operand}");
                        Push(operand);
                    }
                }
                else
                {
                    switch (instruction)
                    {
                    //Push this number on the stack
                    case '0':
                    case '1':
                    case '2':
                    case '3':
                    case '4':
                    case '5':
                    case '6':
                    case '7':
                    case '8':
                    case '9':
                        int digit = instruction - 48;
                        Push(digit);
                        Debug.WriteLine($"PUSH DIGIT {digit}");
                        break;

                    //Addition: Pop a and b, then push a+b
                    case '+':
                    //Subtraction: Pop a and b, then push b-a
                    case '-':
                    //Multiplication: Pop a and b, then push a*b
                    case '*':
                    //Integer division: Pop a and b, then push b/a, rounded towards 0.
                    case '/':
                    //Modulo: Pop a and b, then push the remainder of the integer division of b/a.
                    case '%':
                        PerformMathOperation(instruction);
                        break;

                    //Logical NOT: Pop a value. If the value is zero, push 1; otherwise, push zero.
                    case '!':
                    {
                        int operand = Pop();
                        int result  = operand == 0 ? 1 : 0;
                        Debug.WriteLine($"NOT({operand})={result}");
                        Push(result);
                    }
                    break;

                    //Greater than: Pop a and b, then push 1 if b>a, otherwise zero.
                    case '`':
                    {
                        int operand2 = Pop();
                        int operand1 = Pop();
                        int result   = operand1 > operand2 ? 1 : 0;
                        Debug.WriteLine($"GREATER({operand1},{operand2})={result}");
                        Push(result);
                    }
                    break;

                    //Start moving right
                    case '>':
                        direction = Directions.Right;
                        Debug.WriteLine("MOVE RIGHT");
                        break;

                    //Start moving left
                    case '<':
                        direction = Directions.Left;
                        Debug.WriteLine("MOVE LEFT");
                        break;

                    //Start moving up
                    case '^':
                        direction = Directions.Up;
                        Debug.WriteLine("MOVE UP");
                        break;

                    //Start moving down
                    case 'v':
                        direction = Directions.Down;
                        Debug.WriteLine("MOVE DOWN");
                        break;

                    //Start moving in a random cardinal direction
                    case '?':
                        direction = (Directions)random.Next(4);
                        Debug.WriteLine($"MOVE RANDOM={direction}");
                        break;

                    //Pop a value; move right if value=0, left otherwise
                    case '_':
                    {
                        int operand = Pop();
                        direction = operand == 0
                                    ? Directions.Right
                                    : Directions.Left;
                        Debug.WriteLine($"CHANGE HORIZONTAL({operand})={direction}");
                    }
                    break;

                    //Pop a value; move down if value=0, up otherwise
                    case '|':
                    {
                        int operand = Pop();
                        direction = operand == 0
                                    ? Directions.Down
                                    : Directions.Up;
                        Debug.WriteLine($"CHANGE VERTICAL({operand})={direction}");
                    }
                    break;

                    //Start string mode: push each character's ASCII value all the way up to the next "
                    case '\"':
                        stringMode = true;
                        Debug.WriteLine("STRING MODE ON");
                        break;

                    //Duplicate value on top of the stack
                    case ':':
                    {
                        int operand = Pop();
                        Push(operand);
                        Push(operand);
                        Debug.WriteLine($"DUP({operand})");
                    }
                    break;

                    //Swap two values on top of the stack
                    case '\\':
                    {
                        int operand2 = Pop();
                        int operand1 = Pop();
                        Push(operand2);
                        Push(operand1);
                        Debug.WriteLine($"SWAP({operand1},{operand2})");
                    }
                    break;

                    //Pop value from the stack and discard it
                    case '$':
                    {
                        Pop();     // pop and discard
                        Debug.WriteLine("POP");
                    }
                    break;

                    //Pop value and output as an integer followed by a space
                    case '.':
                    {
                        int operand = Pop();
                        Debug.WriteLine($"OUT NUMBER({operand})");
                        OutputAction?.Invoke(operand.ToString());
                    }
                    break;

                    //Pop value and output as ASCII character
                    case ',':
                    {
                        int  outputAsInt = Pop();
                        char operand     = (char)(outputAsInt % 255);
                        OutputAction?.Invoke(operand.ToString());
                        Debug.WriteLine($"OUT CHAR({operand})");
                    }
                    break;

                    //Bridge: Skip next cell
                    case '#':
                        skip = true;
                        Debug.WriteLine("BRIDGE ON: skipping next instruction");
                        break;

                    //A "put" call (a way to store a value for later use). Pop y, x, and v, then change the character at (x,y) in the program to the character with ASCII value v
                    case 'p':
                    {
                        int putY     = Pop();
                        int putX     = Pop();
                        int putValue = Pop();
                        Grid[putY, putX] = (char)putValue;
                        Debug.WriteLine($"PUT({putX},{putY})={putValue}");
                    }
                    break;

                    //A "get" call (a way to retrieve data in storage). Pop y and x, then push ASCII value of the character at that position in the program
                    case 'g':
                    {
                        int getY     = Pop();
                        int getX     = Pop();
                        int getValue = Grid[getY, getX];
                        Push(getValue);
                        Debug.WriteLine($"GET({getX},{getY})={getValue}");
                    }
                    break;

                    //Ask user for a number and push it
                    case '&':
                    {
                        string inputAsString = InputFunc?.Invoke();
                        if (string.IsNullOrWhiteSpace(inputAsString))
                        {
                            Debug.WriteLine("IN NUMBER failed: null or empty input");
                        }
                        else
                        {
                            int operand;
                            if (!int.TryParse(inputAsString, out operand))
                            {
                                Debug.WriteLine($"IN NUMBER failed: invalid input {inputAsString}");
                            }
                            else
                            {
                                Push(operand);
                                Debug.WriteLine($"IN NUMBER({operand})");
                            }
                        }
                    }
                    break;

                    //Ask user for a character and push its ASCII value
                    case '~':
                    {
                        string inputAsString = InputFunc?.Invoke();
                        if (string.IsNullOrEmpty(inputAsString))
                        {
                            Debug.WriteLine("IN CHAR failed: null or empty input");
                        }
                        else
                        {
                            int inputChar = inputAsString[0] % 255;
                            Debug.WriteLine($"IN CHAR({inputChar})");
                            Push(inputChar);
                        }
                    }
                    break;

                    //End program
                    case '@':
                        Debug.WriteLine("END OF PROGRAM");
                        return;

                    //NOP
                    case ' ':
                        Debug.WriteLine("NOP");
                        break;

                    //Unknown instruction
                    default:
                        Debug.WriteLine($"Unknown instruction:{instruction}");
                        break;
                    }
                }
                // Move instruction pointers according to direction
                MoveDirectionUntilInstructionFound(direction, stringMode, ref x, ref y);
            }
        }
 public Vector2ActionChangeEvent(Hand hand, OutputAction action, Vector2 state)
 {
     this.hand   = hand;
     this.action = action;
     this.state  = state;
 }
 public SqlserverActionOutputAction(WorkflowStoreSql store, OutputAction child = null)
     : base(child)
 {
     this._store = store;
 }
 string[] GetBindingNames(OutputAction outputAction, NameType nameType)
 => ActionsController.GetBindingNames(ActionsControllerBindingsLoader.CurrentBindingsController, outputAction, nameType);
 public PushLogOutputAction(OutputAction child = null)
     : base(child)
 {
 }
Esempio n. 21
0
        private void InputGUI()
        {
            Vector2 delta = current.delta;

            switch (current.type)
            {
            case EventType.MouseDown:
                GraphEditor.mouse_down_position = GraphEditor.mouse_position;
                switch (current.button)
                {
                case 0:
                    if (current.alt)
                    {
                        break;
                    }
                    if (GraphEditor.hover_node)
                    {
                        if (current.clickCount >= 2)
                        {
                            if (GraphEditor.hover_node is MacroNode)
                            {
                                SetGraphAsset(((MacroNode)GraphEditor.hover_node).reference);
                                current.Use();
                                return;
                            }
                            else
                            {
                                EditorUtils.OpenScriptByType(GraphEditor.hover_node.type);
                                current.Use();
                            }
                        }
                        if (GraphEditor.hover_port)
                        {
                            if (current.control)
                            {
                                if (GraphEditor.hover_port is OutputAction)
                                {
                                    UndoManager.RecordObject(GraphEditor.asset, string.Format("{0} Add Branch", GraphEditor.asset.name));
                                    set_dirty = true;
                                    QuickPlugPort(GraphEditor.hover_port, AddNode <Branch>(GraphEditor.mouse_position / GraphEditor.zoom - GraphEditor.scroll + new Vector2(60.0f, 0.0f)));
                                }
                            }
                            else
                            {
                                if (current.shift)
                                {
                                    GraphEditor.can_drag_node = false;
                                    GraphEditor.can_drag_port = false;
                                    if (GraphEditor.hover_port is IPlug)
                                    {
                                        UndoManager.RecordObject(GraphEditor.asset, string.Format("{0} > {1}: {2} Unplug", GraphEditor.asset.name, GraphEditor.hover_node.name, GraphEditor.hover_port.name));
                                        set_dirty = true;
                                        ((IPlug)GraphEditor.hover_port).Unplug();
                                    }
                                    current.Use();
                                }
                                else
                                {
                                    GraphEditor.can_drag_node = false;
                                    GraphEditor.can_drag_port = true;
                                    SelectOnlyNode(GraphEditor.hover_node);
                                    current.Use();
                                }
                            }
                        }
                        else
                        {
                            if (current.shift)
                            {
                                if (GraphEditor.hover_node.is_selected)
                                {
                                    GraphEditor.can_drag_node = false;
                                    DeselectNode(GraphEditor.hover_node);
                                    current.Use();
                                }
                                else
                                {
                                    GraphEditor.can_drag_node = true;
                                    SelectNode(GraphEditor.hover_node);
                                    current.Use();
                                }
                            }
                            else
                            {
                                if (GraphEditor.hover_node.is_selected)
                                {
                                    GraphEditor.can_drag_node = true;
                                }
                                else
                                {
                                    GraphEditor.can_drag_node = true;
                                    SelectOnlyNode(GraphEditor.hover_node);
                                    current.Use();
                                }
                            }
                        }
                    }
                    else if (editable_area.Contains(GraphEditor.mouse_position))
                    {
                        GraphEditor.can_select = true;
                    }
                    break;

                case 1:
                    break;

                case 2:
                    break;
                }
                break;

            case EventType.MouseUp:
                switch (current.button)
                {
                case 0:
                    if (GraphEditor.can_select && GraphEditor.is_select)
                    {
                        Rect        select_box_in_scroll = new Rect(select_box.position / target_zoom, select_box.size / target_zoom);
                        List <Node> nodes = GraphEditor.graph.nodes.Where((n) => select_box_in_scroll.Overlaps(n.nodeRect)).ToList();
                        if (current.shift)
                        {
                            foreach (Node node in nodes)
                            {
                                if (node.is_selected)
                                {
                                    DeselectNode(node);
                                }
                                else
                                {
                                    SelectNode(node);
                                }
                            }
                            current.Use();
                        }
                        else
                        {
                            ClearSelection();
                            SelectNodes(nodes);
                            current.Use();
                        }
                    }
                    else
                    {
                        if (GraphEditor.hover_node)
                        {
                            if (GraphEditor.is_drag)
                            {
                                if (GraphEditor.drag_port)
                                {
                                    if (GraphEditor.hover_port)
                                    {
                                        PlugPort(GraphEditor.drag_port, GraphEditor.hover_port);
                                    }
                                    else
                                    {
                                        QuickPlugPort(GraphEditor.drag_port, GraphEditor.hover_node);
                                    }
                                    current.Use();
                                }
                            }
                            else
                            {
                                if (!current.shift)
                                {
                                    if (GraphEditor.selection.Count > 1)
                                    {
                                        SelectOnlyNode(GraphEditor.hover_node);
                                        current.Use();
                                    }
                                }
                            }
                        }
                        else if (!GraphEditor.is_scrolling)
                        {
                            ClearSelection();
                        }
                        if (GraphEditor.drag_port && !GraphEditor.hover_node)
                        {
                            InputAction  in_act    = GraphEditor.drag_port as InputAction;
                            OutputAction out_act   = GraphEditor.drag_port as OutputAction;
                            IInputValue  in_value  = GraphEditor.drag_port as IInputValue;
                            IOutputValue out_value = GraphEditor.drag_port as IOutputValue;
                            if (in_act != null)
                            {
                                GraphEditor.waiting_for_new_node = true;
                                AdvancedSearchWindow.Init(GraphEditor.mouse_position, "#tag:in void");
                            }
                            else if (out_act != null)
                            {
                                GraphEditor.waiting_for_new_node = true;
                                AdvancedSearchWindow.Init(GraphEditor.mouse_position, "#tag:out void");
                            }
                            else if (in_value != null)
                            {
                                GraphEditor.waiting_for_new_node = true;
                                AdvancedSearchWindow.Init(GraphEditor.mouse_position, "#tag:out " + in_value.valueType.GetTypeName(false, true));
                            }
                            else if (out_value != null)
                            {
                                GraphEditor.waiting_for_new_node = true;
                                AdvancedSearchWindow.Init(GraphEditor.mouse_position, "#tag:in " + out_value.valueType.GetTypeName(false, true));
                            }
                        }
                    }
                    GraphEditor.can_select   = false;
                    GraphEditor.is_select    = false;
                    GraphEditor.is_scrolling = false;
                    GraphEditor.hover_node   = null;
                    GraphEditor.drag_node    = null;
                    if (!GraphEditor.waiting_for_new_node)
                    {
                        GraphEditor.is_drag       = false;
                        GraphEditor.drag_port     = null;
                        GraphEditor.can_drag_port = false;
                    }
                    GraphEditor.can_drag_node = false;
                    break;

                case 1:
                    if (!GraphEditor.is_drag)
                    {
                        AdvancedSearchWindow.Init(GraphEditor.mouse_position);
                        current.Use();
                    }
                    GraphEditor.is_drag = false;
                    break;

                case 2:
                    break;
                }
                break;

            case EventType.MouseDrag:
                switch (current.button)
                {
                case 0:
                    if (current.alt)
                    {
                        GraphEditor.is_drag      = true;
                        GraphEditor.is_scrolling = true;
                        GraphEditor.scroll      += delta;
                        break;
                    }
                    if (!GraphEditor.is_drag)
                    {
                        if (GraphEditor.can_drag_port && GraphEditor.hover_port)
                        {
                            GraphEditor.is_drag       = true;
                            GraphEditor.can_drag_node = false;
                            GraphEditor.drag_port     = GraphEditor.hover_port;
                        }
                        if (GraphEditor.can_drag_node && GraphEditor.hover_node)
                        {
                            GraphEditor.is_drag       = true;
                            GraphEditor.can_drag_port = false;
                            GraphEditor.drag_node     = GraphEditor.hover_node;
                        }
                    }
                    // ...
                    if (GraphEditor.is_drag)
                    {
                        if (GraphEditor.drag_node)
                        {
                            foreach (Node node in GraphEditor.selection)
                            {
                                node.position += delta;
                            }
                        }
                    }
                    else
                    {
                        if (GraphEditor.can_select)
                        {
                            GraphEditor.is_select = true;
                        }
                    }
                    break;

                case 1:
                    GraphEditor.is_drag      = true;
                    GraphEditor.is_scrolling = true;
                    GraphEditor.scroll      += delta;
                    break;

                case 2:
                    GraphEditor.is_drag      = true;
                    GraphEditor.is_scrolling = true;
                    GraphEditor.scroll      += delta;
                    break;
                }
                break;

            case EventType.ScrollWheel:
                if (!GraphEditor.is_drag)
                {
                    float zoom_delta = 0.1f;
                    zoom_delta   = current.delta.y < 0.0f ? zoom_delta : -zoom_delta;
                    target_zoom += zoom_delta;
                    target_zoom  = Mathf.Clamp(target_zoom, 0.2f, 1.0f);
                }
                break;

            case EventType.ValidateCommand:
                switch (Event.current.commandName)
                {
                case ("Delete"):
                    DeleteSelectedNodes();
                    current.Use();
                    break;

                case ("Duplicate"):
                    DuplicateSelectedNodes();
                    current.Use();
                    break;

                case ("SelectAll"):
                    if (GraphEditor.selection.Count == GraphEditor.graph.nodeCount)
                    {
                        ClearSelection();
                        current.Use();
                    }
                    else
                    {
                        SelectNodes(GraphEditor.graph.nodes);
                        current.Use();
                    }
                    break;
                }
                break;

            case EventType.DragUpdated:
            case EventType.DragPerform:
                if (DragAndDrop.objectReferences.Length > 0)
                {
                    DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
                    if (current.type == EventType.DragPerform)
                    {
                        DragAndDrop.AcceptDrag();
                        GenericMenu generic_menu = new GenericMenu();
                        Type        type;
                        string      type_name;
                        foreach (UnityObject drag_obj in DragAndDrop.objectReferences)
                        {
                            if (drag_obj == null)
                            {
                                continue;
                            }
                            if (drag_obj is GraphAsset)
                            {
                                GraphAsset m_asset = (GraphAsset)drag_obj;
                                if (m_asset)
                                {
                                    generic_menu.AddItem(new GUIContent(string.Format("Add {0} as Macro", m_asset.title.IsNullOrEmpty() ? m_asset.name : m_asset.title)), false, (obj) => {
                                        AddMacro(m_asset, (Vector2)obj);
                                    }, GraphEditor.mouse_position - GraphEditor.scroll);
                                }
                            }
                            else if (drag_obj is MonoScript)
                            {
                                MonoScript script = (MonoScript)drag_obj;
                                if (script)
                                {
                                    type      = script.GetClass();
                                    type_name = type.GetTypeName();

                                    generic_menu.AddItem(new GUIContent(string.Format("{0}/Expose {0} members", type_name)), false, (obj) => {
                                        AddCustomNode <ReflectedObjectNode>((Vector2)obj, true, type);
                                    }, GraphEditor.mouse_position - GraphEditor.scroll);
                                    generic_menu.AddSeparator(string.Format("{0}/", type_name));

                                    AddTypeMethodsToMenu(generic_menu, type, type_name);

                                    if (type.IsSubclassOf(typeof(Node)) && !type.IsAbstract && !type.IsGenericType)
                                    {
                                        generic_menu.AddItem(new GUIContent(string.Format("Add {0} as Node", type_name)), false, (obj) => {
                                            AddNode(type, (Vector2)obj);
                                        }, GraphEditor.mouse_position - GraphEditor.scroll);
                                    }
                                }
                            }

                            if (drag_obj is GraphAsset || drag_obj is MonoScript)
                            {
                                generic_menu.AddSeparator("");
                            }

                            type      = drag_obj.GetType();
                            type_name = type.GetTypeName();

                            generic_menu.AddItem(new GUIContent(string.Format("Expose {0} members", type_name)), false, (obj) => {
                                AddCustomNode <ReflectedObjectNode>((Vector2)obj, true, type);
                            }, GraphEditor.mouse_position - GraphEditor.scroll);

                            AddTypeMethodsToMenu(generic_menu, type, type_name);
                        }
                        DragAndDrop.PrepareStartDrag();
                        generic_menu.ShowAsContext();
                    }
                }
                break;

            case (EventType.KeyDown):
                switch (current.keyCode)
                {
                case KeyCode.Space:
                    if (!current.control)
                    {
                        AdvancedSearchWindow.Init(position.size / 2.0f);
                        current.Use();
                    }
                    break;

                case KeyCode.Delete:
                    DeleteSelectedNodes();
                    current.Use();
                    break;

                case KeyCode.Home:
                    target_zoom        = 1.0f;
                    GraphEditor.scroll = Vector2.zero;
                    current.Use();
                    break;

                case KeyCode.PageDown:
                    GraphEditor.scroll -= new Vector2(0.0f, position.height);
                    current.Use();
                    break;

                case KeyCode.PageUp:
                    GraphEditor.scroll += new Vector2(0.0f, position.height);
                    current.Use();
                    break;
                }
                break;
            }
        }
Esempio n. 22
0
        /// <summary>
        /// Resolves the output actions for the given output.
        /// </summary>
        /// <param name="loader">The loader containing the map file definition.</param>
        /// <param name="output">The output to resolve actions for.</param>
        /// <returns>An output's actions collection.</returns>
        private static IEnumerable<OutputAction> ResolveOutputActions(MapLoader loader, XmlElement output)
        {
            Dictionary<string, OutputAction> actions = new Dictionary<string, OutputAction>();

            foreach (XmlElement element in loader.Map.SelectNodes("jspack/outputAction[@global='true']"))
            {
                string name = element.Attributes["name"].Value;
                actions[name] = new OutputAction(name, element.Attributes["executable"].Value, element.Attributes["arguments"].Value);
            }

            foreach (XmlElement element in output.SelectNodes("action"))
            {
                string name = element.Attributes["name"].Value;
                string args = element.Attributes["arguments"].Value;

                if (actions.ContainsKey(name))
                {
                    if (!String.IsNullOrEmpty(args))
                    {
                        actions[name].Arguments = args;
                    }
                }
                else
                {
                    XmlElement action = loader.Map.SelectSingleNode("jspack/outputAction[@name='" + name + "']") as XmlElement;

                    if (action != null)
                    {
                        if (String.IsNullOrEmpty(args))
                        {
                            args = action.Attributes["arguments"].Value;
                        }

                        actions[name] = new OutputAction(name, action.Attributes["executable"].Value, args);
                    }
                }
            }

            return (from kvp in actions
                    select kvp.Value).ToArray();
        }
Esempio n. 23
0
        public DiagnosticPipeline(
            IHealthReporter healthReporter,
            IReadOnlyCollection <IObservable <EventData> > inputs,
            IReadOnlyCollection <IFilter> globalFilters,
            IReadOnlyCollection <EventSink> sinks,
            DiagnosticPipelineConfiguration pipelineConfiguration = null,
            bool disposeDependencies = false)
        {
            Requires.NotNull(healthReporter, nameof(healthReporter));
            Requires.NotNull(inputs, nameof(inputs));
            Requires.Argument(inputs.Count > 0, nameof(inputs), "There must be at least one input");
            Requires.NotNull(sinks, nameof(sinks));
            Requires.Argument(sinks.Count > 0, nameof(sinks), "There must be at least one sink");

            this.pipelineConfiguration = pipelineConfiguration ?? new DiagnosticPipelineConfiguration();

            this.Inputs = inputs;
            this.Sinks  = sinks;
            // Just play nice and make sure there is always something to enumerate on
            this.GlobalFilters           = globalFilters ?? new IFilter[0];
            this.HealthReporter          = healthReporter;
            this.cancellationTokenSource = new CancellationTokenSource();
            var propagateCompletion = new DataflowLinkOptions()
            {
                PropagateCompletion = true
            };

            this.pipelineDisposables = new List <IDisposable>();

            var inputBuffer = new BufferBlock <EventData>(
                new DataflowBlockOptions()
            {
                BoundedCapacity   = this.pipelineConfiguration.PipelineBufferSize,
                CancellationToken = this.cancellationTokenSource.Token
            });

            this.pipelineHead = inputBuffer;

            var batcher = new BatchBlock <EventData>(
                this.pipelineConfiguration.MaxEventBatchSize,
                new GroupingDataflowBlockOptions()
            {
                BoundedCapacity   = this.pipelineConfiguration.MaxEventBatchSize,
                CancellationToken = this.cancellationTokenSource.Token
            }
                );

            this.pipelineDisposables.Add(inputBuffer.LinkTo(batcher, propagateCompletion));

            this.pipelineDisposables.Add(new Timer(
                                             (unused) => batcher.TriggerBatch(),
                                             state: null,
                                             dueTime: TimeSpan.FromMilliseconds(this.pipelineConfiguration.MaxBatchDelayMsec),
                                             period: TimeSpan.FromMilliseconds(this.pipelineConfiguration.MaxBatchDelayMsec)));

            ISourceBlock <EventData[]> sinkSource;
            FilterAction filterTransform;

            if (this.GlobalFilters.Count > 0)
            {
                filterTransform = new FilterAction(
                    this.GlobalFilters,
                    this.cancellationTokenSource.Token,
                    this.pipelineConfiguration.MaxEventBatchSize,
                    this.pipelineConfiguration.MaxConcurrency,
                    healthReporter);
                var globalFiltersBlock = filterTransform.GetFilterBlock();
                this.pipelineDisposables.Add(batcher.LinkTo(globalFiltersBlock, propagateCompletion));
                sinkSource = globalFiltersBlock;
            }
            else
            {
                sinkSource = batcher;
            }

            if (sinks.Count > 1)
            {
                var broadcaster = new BroadcastBlock <EventData[]>(
                    (events) => events?.Select((e) => e.DeepClone()).ToArray(),
                    new DataflowBlockOptions()
                {
                    BoundedCapacity   = this.pipelineConfiguration.MaxEventBatchSize,
                    CancellationToken = this.cancellationTokenSource.Token
                });
                this.pipelineDisposables.Add(sinkSource.LinkTo(broadcaster, propagateCompletion));
                sinkSource = broadcaster;
            }

            foreach (var sink in sinks)
            {
                ISourceBlock <EventData[]> outputSource = sinkSource;
                if (sink.Filters != null && sink.Filters.Count > 0)
                {
                    filterTransform = new FilterAction(
                        sink.Filters,
                        this.cancellationTokenSource.Token,
                        this.pipelineConfiguration.MaxEventBatchSize,
                        this.pipelineConfiguration.MaxConcurrency,
                        healthReporter);
                    var filterBlock = filterTransform.GetFilterBlock();
                    this.pipelineDisposables.Add(sinkSource.LinkTo(filterBlock, propagateCompletion));
                    outputSource = filterBlock;
                }

                OutputAction outputAction = new OutputAction(
                    sink.Output,
                    this.cancellationTokenSource.Token,
                    this.pipelineConfiguration.MaxEventBatchSize,
                    this.pipelineConfiguration.MaxConcurrency,
                    healthReporter);
                ActionBlock <EventData[]> outputBlock = outputAction.GetOutputBlock();
                this.pipelineDisposables.Add(outputSource.LinkTo(outputBlock, propagateCompletion));
            }

            IObserver <EventData> inputBufferObserver = new TargetBlockObserver <EventData>(inputBuffer, this.HealthReporter);

            this.inputSubscriptions = new List <IDisposable>(inputs.Count);
            foreach (var input in inputs)
            {
                this.inputSubscriptions.Add(input.Subscribe(inputBufferObserver));
            }

            this.disposed            = false;
            this.disposeDependencies = disposeDependencies;
        }
Esempio n. 24
0
 public OutputAction <TElement> FromAsync <TElement>(Func <Task <TElement> > asyncAction, IObservable <bool> enabledIf = null)
 {
     return(OutputAction <TElement> .FromAsync(asyncAction, schedulerProvider.MainScheduler, enabledIf));
 }
Esempio n. 25
0
        private void GenerateAgent()
        {
            SetUpAgent();


            PortfolioProcess portfolioProcess = new PortfolioProcess(portfolioLayoutPanel, TotalEquityLabel, 100000);

            portfolioProcess.Name = "Portfolio";
            agent.BrainProcessList.Add(portfolioProcess);
            portfolioProcess.ActiveOnStartup = true;



            MyDialogueProcess mainDialogue = new MyDialogueProcess();

            mainDialogue.Name = "MainDialogue";
            agent.BrainProcessList.Add(mainDialogue);
            mainDialogue.ActiveOnStartup = true;
            startButton.Enabled          = true;

            //Main Item 1
            InteractionItem mainDialogueItem1 = new InteractionItem();

            mainDialogueItem1.Name = "MainDialogueItem1";

            ResponseAction mainItem1ToItem2 = new ResponseAction(); //Search for stock path

            mainItem1ToItem2.InputList.Add("Search");
            mainItem1ToItem2.OutputList.Add("Which stock would you like to search for?");
            mainItem1ToItem2.TargetDialogueItemName = "MainDialogueItem2";
            mainDialogueItem1.ActionList.Add(mainItem1ToItem2);

            ResponseAction mainItem1ToPortfolioDialogue = new ResponseAction(); //Modify portfolio path

            mainItem1ToPortfolioDialogue.InputList.Add("Portfolio");
            mainItem1ToPortfolioDialogue.TargetDialogueItemName   = "ModifyPortfolioDialogueItem1";
            mainItem1ToPortfolioDialogue.BrainProcessToDeactivate = "MainDialogue";
            mainItem1ToPortfolioDialogue.BrainProcessToActivate   = "ModifyPortfolioDialogue";
            mainDialogueItem1.ActionList.Add(mainItem1ToPortfolioDialogue);
            mainDialogue.ItemList.Add(mainDialogueItem1);

            //TODO: change name readAction

            InteractionItem mainDialogueItem2 = new InteractionItem();

            mainDialogueItem2.Name = "MainDialogueItem2";
            QueryIDAAction readAction2 = new QueryIDAAction();

            readAction2.InputList.AddRange(DialogueInputStrings.getStockNameList());
            readAction2.InputList.AddRange(DialogueInputStrings.getStockTickerInputs());
            readAction2.TargetDialogueItemName = "MainDialogueItem3";
            mainDialogueItem2.ActionList.Add(readAction2);
            mainDialogue.ItemList.Add(mainDialogueItem2);

            //Main Item 3 : Buy/sell or search for another stock
            InteractionItem mainDialogueItem3 = new InteractionItem();

            mainDialogueItem3.Name = "MainDialogueItem3";

            ResponseAction mainItem3ToItem2 = new ResponseAction(); //search another stock path

            mainItem3ToItem2.InputList.Add("Search");
            mainItem3ToItem2.OutputList.Add("Which stock would you like to search for?");
            mainItem3ToItem2.TargetDialogueItemName = "MainDialogueItem2";
            mainDialogueItem3.ActionList.Add(mainItem3ToItem2);

            ResponseAction mainItem3ToGoLongDialogueAction = new ResponseAction(); //Buy stock path

            mainItem3ToGoLongDialogueAction.InputList.Add("Buy");
            mainItem3ToGoLongDialogueAction.BrainProcessToDeactivate = "MainDialogue";
            mainItem3ToGoLongDialogueAction.BrainProcessToActivate   = "GoLongDialogue";
            mainDialogueItem3.ActionList.Add(mainItem3ToGoLongDialogueAction);

            ResponseAction mainItem3TogoShortDialogueAction = new ResponseAction(); //Skiing path

            mainItem3TogoShortDialogueAction.InputList.Add("Sell");
            mainItem3TogoShortDialogueAction.BrainProcessToDeactivate = "MainDialogue";
            mainItem3TogoShortDialogueAction.BrainProcessToActivate   = "GoShortDialogue";
            mainDialogueItem3.ActionList.Add(mainItem3TogoShortDialogueAction);
            mainDialogue.ItemList.Add(mainDialogueItem3);

            /*
             * Main Dialogue Process end
             */

            /*
             * Modify Portfolio Dialogue Process start
             */

            MyDialogueProcess modifyPortfolioDialogue = new MyDialogueProcess();

            modifyPortfolioDialogue.Name = "ModifyPortfolioDialogue";
            agent.BrainProcessList.Add(modifyPortfolioDialogue);
            modifyPortfolioDialogue.ActiveOnStartup = false;

            //Modify Portfolio Item1 :
            CheckEmptyPortfolioItem modifyPortfolioDialogueItem1 = new CheckEmptyPortfolioItem();

            modifyPortfolioDialogueItem1.Name = "ModifyPortfolioDialogueItem1";

            OutputAction modifyPortfolioItem1ToMainDialogue = new OutputAction(); //There is no portfolio path

            modifyPortfolioItem1ToMainDialogue.InputList.Add("failure");
            modifyPortfolioItem1ToMainDialogue.OutputList.Add("Sorry, but your portfolio is empty, you have nothing to modify");
            modifyPortfolioItem1ToMainDialogue.TargetDialogueItemName   = "MainDialogueItem1";
            modifyPortfolioItem1ToMainDialogue.BrainProcessToDeactivate = "ModifyPortfolioDialogue";
            modifyPortfolioItem1ToMainDialogue.BrainProcessToActivate   = "MainDialogue";
            modifyPortfolioDialogueItem1.ActionList.Add(modifyPortfolioItem1ToMainDialogue);

            OutputAction modifyPortfolioItem1ToItem2 = new OutputAction(); //modify portfolio path

            modifyPortfolioItem1ToItem2.InputList.Add("success");
            modifyPortfolioItem1ToItem2.TargetDialogueItemName = "ModifyPortfolioDialogueItem2";
            modifyPortfolioDialogueItem1.ActionList.Add(modifyPortfolioItem1ToItem2);
            modifyPortfolioDialogue.ItemList.Add(modifyPortfolioDialogueItem1);

            //Modify Portfolio Item2 : Which id to exit question
            InteractionItem modifyPortfolioDialogueItem2 = new InteractionItem();

            modifyPortfolioDialogueItem2.Name             = "ModifyPortfolioDialogueItem2";
            modifyPortfolioDialogueItem2.MillisecondDelay = 500;
            OutputAction modifyPortfolioItem2ToItem3 = new OutputAction();

            modifyPortfolioItem2ToItem3.OutputList.Add("Enter the ID of the position you want to exit");
            modifyPortfolioItem2ToItem3.TargetDialogueItemName = "ModifyPortfolioDialogueItem3";
            modifyPortfolioDialogueItem2.ActionList.Add(modifyPortfolioItem2ToItem3);
            modifyPortfolioDialogue.ItemList.Add(modifyPortfolioDialogueItem2);

            //Modify Portfolio Item3 : which id to exit answer
            ExitOrderItem modifyPortfolioDialogueItem3 = new ExitOrderItem();

            modifyPortfolioDialogueItem3.Name             = "ModifyPortfolioDialogueItem3";
            modifyPortfolioDialogueItem3.MillisecondDelay = 1000;

            ResponseAction modifyPortfolioItem3ToItem4 = new ResponseAction(); //Exited position path

            modifyPortfolioItem3ToItem4.InputList.Add("success");
            modifyPortfolioItem3ToItem4.OutputList.Add("Position exited successfully, do you wish to exit another position?");
            modifyPortfolioItem3ToItem4.TargetDialogueItemName = "ModifyPortfolioDialogueItem4";
            modifyPortfolioDialogueItem3.ActionList.Add(modifyPortfolioItem3ToItem4);

            ResponseAction modifyPortfolioItem3ToItem2 = new ResponseAction(); //No ID path

            modifyPortfolioItem3ToItem2.InputList.Add("failure");
            modifyPortfolioItem3ToItem2.OutputList.Add("The ID doesn't exist, try again.");
            modifyPortfolioItem3ToItem2.TargetDialogueItemName = "ModifyPortfolioDialogueItem2";
            modifyPortfolioDialogueItem3.ActionList.Add(modifyPortfolioItem3ToItem2);
            modifyPortfolioDialogue.ItemList.Add(modifyPortfolioDialogueItem3);

            //Modify Portfolio Item4 : Exit another one answer
            InteractionItem modifyPortfolioDialogueItem4 = new InteractionItem();

            modifyPortfolioDialogueItem4.Name             = "ModifyPortfolioDialogueItem4";
            modifyPortfolioDialogueItem4.MillisecondDelay = 500;

            ResponseAction modifyPortfolioItem4ToMainDialogue = new ResponseAction(); //dont set a stop path

            modifyPortfolioItem4ToMainDialogue.InputList.Add("no");                   //TODO Change to negative answer list
            modifyPortfolioItem4ToMainDialogue.OutputList.Add("Okay, have a nice day!");
            modifyPortfolioItem4ToMainDialogue.TargetDialogueItemName   = "MainDialogueItem1";
            modifyPortfolioItem4ToMainDialogue.BrainProcessToDeactivate = "ModifyPortfolioDialogue";
            modifyPortfolioItem4ToMainDialogue.BrainProcessToActivate   = "MainDialogue";
            modifyPortfolioDialogueItem4.ActionList.Add(modifyPortfolioItem4ToMainDialogue);

            ResponseAction modifyPortfolioItem4ToItem2 = new ResponseAction(); // set a stop path

            modifyPortfolioItem4ToItem2.InputList.Add("yes");
            modifyPortfolioItem4ToItem2.TargetDialogueItemName = "ModifyPortfolioDialogueItem1";
            modifyPortfolioDialogueItem4.ActionList.Add(modifyPortfolioItem4ToItem2);
            modifyPortfolioDialogue.ItemList.Add(modifyPortfolioDialogueItem4);

            /*
             * Modify Portfolio Dialogue Process end
             */

            /*
             * GoLong Dialogue Process start
             */

            MyDialogueProcess goLongDialogue = new MyDialogueProcess();

            goLongDialogue.Name = "GoLongDialogue";
            agent.BrainProcessList.Add(goLongDialogue);
            goLongDialogue.ActiveOnStartup = false;

            InteractionItem goLongDialogueItem1 = new InteractionItem();

            goLongDialogueItem1.Name             = "GoLongDialogueItem1";
            goLongDialogueItem1.MillisecondDelay = 500;
            OutputAction goLongItem1ToItem2 = new OutputAction();

            goLongItem1ToItem2.OutputList.Add("How many stocks would you like to buy?");
            goLongItem1ToItem2.TargetDialogueItemName = "GoLongDialogueItem2";
            goLongDialogueItem1.ActionList.Add(goLongItem1ToItem2);
            goLongDialogue.ItemList.Add(goLongDialogueItem1);

            MarketOrderItem goLongDialogueItem2 = new MarketOrderItem(MarketOrderItem.DIRECTION_LONG);

            goLongDialogueItem2.Name             = "GoLongDialogueItem2";
            goLongDialogueItem2.MillisecondDelay = 500;
            MarketExecutionAction goLongItem2ToItem3 = new MarketExecutionAction();

            goLongItem2ToItem3.InputList.Add("success");
            goLongItem2ToItem3.TargetDialogueItemName = "GoLongDialogueItem3";
            goLongDialogueItem2.ActionList.Add(goLongItem2ToItem3);
            ResponseAction goLongItem2ToItem4 = new ResponseAction();

            goLongItem2ToItem4.InputList.Add("failure");
            goLongItem2ToItem4.OutputList.Add("You have insufficient funds, try again with a smaller size"); //TODO: Change action name
            goLongItem2ToItem4.TargetDialogueItemName = "GoLongDialogueItem1";
            goLongDialogueItem2.ActionList.Add(goLongItem2ToItem4);
            goLongDialogue.ItemList.Add(goLongDialogueItem2);

            //Item3 : set SL or TP question
            InteractionItem goLongDialogueItem3 = new InteractionItem();

            goLongDialogueItem3.Name             = "GoLongDialogueItem3";
            goLongDialogueItem3.MillisecondDelay = 2000;
            OutputAction goLongItem3ToItem5 = new OutputAction();

            goLongItem3ToItem5.OutputList.Add("Would you like to set a Stop Loss?");
            goLongItem3ToItem5.TargetDialogueItemName = "GoLongDialogueItem5";
            goLongDialogueItem3.ActionList.Add(goLongItem3ToItem5);
            goLongDialogue.ItemList.Add(goLongDialogueItem3);

            //Item5 : set SL or TP answer
            InteractionItem goLongDialogueItem5 = new InteractionItem();

            goLongDialogueItem5.Name             = "GoLongDialogueItem5";
            goLongDialogueItem5.MillisecondDelay = 500;

            ResponseAction goLongItem5ToItem9 = new ResponseAction(); //dont set a stop path

            goLongItem5ToItem9.InputList.Add("no");                   //TODO Change to negative answer list
            goLongItem5ToItem9.OutputList.Add("Okay, how about a target profit?");
            goLongItem5ToItem9.TargetDialogueItemName = "GoLongDialogueItem9";
            goLongDialogueItem5.ActionList.Add(goLongItem5ToItem9);

            ResponseAction goLongItem5ToItem6Action = new ResponseAction(); // set a stop path

            goLongItem5ToItem6Action.InputList.Add("yes");
            goLongItem5ToItem6Action.TargetDialogueItemName = "GoLongDialogueItem6";
            goLongDialogueItem5.ActionList.Add(goLongItem5ToItem6Action);
            goLongDialogue.ItemList.Add(goLongDialogueItem5);

            //Item6: where to set stop question
            InteractionItem goLongDialogueItem6 = new InteractionItem();

            goLongDialogueItem6.Name             = "GoLongDialogueItem6";
            goLongDialogueItem6.MillisecondDelay = 500;
            OutputAction goLongItem6ToItem7 = new OutputAction();

            goLongItem6ToItem7.OutputList.Add("At what level would you like to set your stop loss?");
            goLongItem6ToItem7.TargetDialogueItemName = "GoLongDialogueItem7";
            goLongDialogueItem6.ActionList.Add(goLongItem6ToItem7);
            goLongDialogue.ItemList.Add(goLongDialogueItem6);

            //Item7 : where to set stop answer
            SLTPOrderItem goLongDialogueItem7 = new SLTPOrderItem(SLTPOrderItem.SET_STOPP_LOSS, MarketOrderItem.DIRECTION_LONG);

            goLongDialogueItem7.Name             = "GoLongDialogueItem7";
            goLongDialogueItem7.MillisecondDelay = 500;
            LimitExecutionAction goLongItem7ToItem8 = new LimitExecutionAction();

            goLongItem7ToItem8.InputList.Add("success");
            goLongItem7ToItem8.TargetDialogueItemName = "GoLongDialogueItem8";
            goLongDialogueItem7.ActionList.Add(goLongItem7ToItem8);
            ResponseAction goLongItem7ToItem6 = new ResponseAction();

            goLongItem7ToItem6.InputList.Add("failure");
            goLongItem7ToItem6.OutputList.Add("Your limit was on the wrong side of the market, try again");
            goLongItem7ToItem6.TargetDialogueItemName = "GoLongDialogueItem6";
            goLongDialogueItem7.ActionList.Add(goLongItem7ToItem6);
            goLongDialogue.ItemList.Add(goLongDialogueItem7);

            //Item8 : set TP question
            InteractionItem goLongDialogueItem8 = new InteractionItem();

            goLongDialogueItem8.Name             = "GoLongDialogueItem8";
            goLongDialogueItem8.MillisecondDelay = 1500;
            OutputAction goLongItem8ToItem9 = new OutputAction();

            goLongItem8ToItem9.OutputList.Add("Would you also like to set a Target Profit?");
            goLongItem8ToItem9.TargetDialogueItemName = "GoLongDialogueItem9";
            goLongDialogueItem8.ActionList.Add(goLongItem8ToItem9);
            goLongDialogue.ItemList.Add(goLongDialogueItem8);

            //Item9 : set TP answer
            InteractionItem goLongDialogueItem9 = new InteractionItem();

            goLongDialogueItem9.Name             = "GoLongDialogueItem9";
            goLongDialogueItem9.MillisecondDelay = 500;

            ResponseAction goLongItem9ToMainDialogueAction = new ResponseAction(); //dont set a target path

            goLongItem9ToMainDialogueAction.InputList.Add("no");                   //TODO Change to negative answer list
            goLongItem9ToMainDialogueAction.OutputList.Add("Okay, have a nice day");
            goLongItem9ToMainDialogueAction.TargetDialogueItemName   = "MainDialogueItem1";
            goLongItem9ToMainDialogueAction.BrainProcessToDeactivate = "GoLongDialogue";
            goLongItem9ToMainDialogueAction.BrainProcessToActivate   = "MainDialogue";
            goLongDialogueItem9.ActionList.Add(goLongItem9ToMainDialogueAction);

            ResponseAction goLongItem9ToItem10Action = new ResponseAction(); // set a target path

            goLongItem9ToItem10Action.InputList.Add("yes");
            goLongItem9ToItem10Action.TargetDialogueItemName = "GoLongDialogueItem10";
            goLongDialogueItem9.ActionList.Add(goLongItem9ToItem10Action);
            goLongDialogue.ItemList.Add(goLongDialogueItem9);

            //Item10: where to set target question
            InteractionItem goLongDialogueItem10 = new InteractionItem();

            goLongDialogueItem10.Name             = "GoLongDialogueItem10";
            goLongDialogueItem10.MillisecondDelay = 500;
            OutputAction goLongItem10ToItem11 = new OutputAction();

            goLongItem10ToItem11.OutputList.Add("At what level would you like to set your target profit?");
            goLongItem10ToItem11.TargetDialogueItemName = "GoLongDialogueItem11";
            goLongDialogueItem10.ActionList.Add(goLongItem10ToItem11);
            goLongDialogue.ItemList.Add(goLongDialogueItem10);


            //Item11 : where to set target answer
            SLTPOrderItem goLongDialogueItem11 = new SLTPOrderItem(SLTPOrderItem.SET_TARGET_PROFIT, MarketOrderItem.DIRECTION_LONG);

            goLongDialogueItem11.Name             = "GoLongDialogueItem11";
            goLongDialogueItem11.MillisecondDelay = 500;
            LimitExecutionAction goLongItem11ToItem12 = new LimitExecutionAction();

            goLongItem11ToItem12.InputList.Add("success");
            goLongItem11ToItem12.TargetDialogueItemName = "GoLongDialogueItem12";
            goLongDialogueItem11.ActionList.Add(goLongItem11ToItem12);
            ResponseAction goLongItem11ToItem10 = new ResponseAction();

            goLongItem11ToItem10.InputList.Add("failure");
            goLongItem11ToItem10.OutputList.Add("Your limit was on the wrong side of the market, try again");
            goLongItem11ToItem10.TargetDialogueItemName = "GoLongDialogueItem10";
            goLongDialogueItem11.ActionList.Add(goLongItem11ToItem10);
            goLongDialogue.ItemList.Add(goLongDialogueItem11);


            //Item12 : Everything done, return to main dialogue
            InteractionItem goLongDialogueItem12 = new InteractionItem();

            goLongDialogueItem12.Name             = "GoLongDialogueItem12";
            goLongDialogueItem12.MillisecondDelay = 1500;
            OutputAction goLongItem12ToMainDialogue = new OutputAction();

            goLongItem12ToMainDialogue.OutputList.Add("All is set, good luck and have a nice day!");
            goLongItem12ToMainDialogue.TargetDialogueItemName   = "MainDialogueItem1";
            goLongItem12ToMainDialogue.BrainProcessToDeactivate = "GoLongDialogue";
            goLongItem12ToMainDialogue.BrainProcessToActivate   = "MainDialogue";
            goLongDialogueItem12.ActionList.Add(goLongItem12ToMainDialogue);
            goLongDialogue.ItemList.Add(goLongDialogueItem12);

            /*
             * GoLong Dialogue Process end
             */


            /*
             * goShort Dialogue Process start
             */

            MyDialogueProcess goShortDialogue = new MyDialogueProcess();

            goShortDialogue.Name = "GoShortDialogue";
            agent.BrainProcessList.Add(goShortDialogue);
            goShortDialogue.ActiveOnStartup = false;

            InteractionItem goShortDialogueItem1 = new InteractionItem();

            goShortDialogueItem1.Name             = "GoShortDialogueItem1";
            goShortDialogueItem1.MillisecondDelay = 500;
            OutputAction goShortItem1ToItem2 = new OutputAction();

            goShortItem1ToItem2.OutputList.Add("How many stocks would you like to sell?");
            goShortItem1ToItem2.TargetDialogueItemName = "GoShortDialogueItem2";
            goShortDialogueItem1.ActionList.Add(goShortItem1ToItem2);
            goShortDialogue.ItemList.Add(goShortDialogueItem1);

            MarketOrderItem goShortDialogueItem2 = new MarketOrderItem(MarketOrderItem.DIRECTION_SHORT);

            goShortDialogueItem2.Name             = "GoShortDialogueItem2";
            goShortDialogueItem2.MillisecondDelay = 500;
            MarketExecutionAction goShortItem2ToItem3 = new MarketExecutionAction();

            goShortItem2ToItem3.InputList.Add("success");
            goShortItem2ToItem3.TargetDialogueItemName = "GoShortDialogueItem3";
            goShortDialogueItem2.ActionList.Add(goShortItem2ToItem3);
            goShortDialogue.ItemList.Add(goShortDialogueItem2);

            InteractionItem goShortDialogueItem3 = new InteractionItem();

            goShortDialogueItem3.Name             = "GoShortDialogueItem3";
            goShortDialogueItem3.MillisecondDelay = 2000;
            OutputAction goShortItem3ToItem5 = new OutputAction();

            goShortItem3ToItem5.OutputList.Add("Would you like to set a Stop Loss?");
            goShortItem3ToItem5.TargetDialogueItemName = "GoShortDialogueItem5";
            goShortDialogueItem3.ActionList.Add(goShortItem3ToItem5);
            goShortDialogue.ItemList.Add(goShortDialogueItem3);


            //Item5 : set SL or TP answer
            InteractionItem goShortDialogueItem5 = new InteractionItem();

            goShortDialogueItem5.Name             = "GoShortDialogueItem5";
            goShortDialogueItem5.MillisecondDelay = 500;

            ResponseAction goShortItem5ToItem9 = new ResponseAction(); //dont set a stop path

            goShortItem5ToItem9.InputList.Add("no");                   //TODO Change to negative answer list
            goShortItem5ToItem9.OutputList.Add("Okay, how about a target profit?");
            goShortItem5ToItem9.TargetDialogueItemName = "GoShortDialogueItem9";
            goShortDialogueItem5.ActionList.Add(goShortItem5ToItem9);

            ResponseAction goShortItem5ToItem6Action = new ResponseAction(); // set a stop path

            goShortItem5ToItem6Action.InputList.Add("yes");
            goShortItem5ToItem6Action.TargetDialogueItemName = "GoShortDialogueItem6";
            goShortDialogueItem5.ActionList.Add(goShortItem5ToItem6Action);
            goShortDialogue.ItemList.Add(goShortDialogueItem5);

            //Item6: where to set stop question
            InteractionItem goShortDialogueItem6 = new InteractionItem();

            goShortDialogueItem6.Name             = "GoShortDialogueItem6";
            goShortDialogueItem6.MillisecondDelay = 500;
            OutputAction goShortItem6ToItem7 = new OutputAction();

            goShortItem6ToItem7.OutputList.Add("At what level would you like to set your stop loss?");
            goShortItem6ToItem7.TargetDialogueItemName = "GoShortDialogueItem7";
            goShortDialogueItem6.ActionList.Add(goShortItem6ToItem7);
            goShortDialogue.ItemList.Add(goShortDialogueItem6);

            //Item7 : where to set stop answer
            SLTPOrderItem goShortDialogueItem7 = new SLTPOrderItem(SLTPOrderItem.SET_STOPP_LOSS, MarketOrderItem.DIRECTION_SHORT);

            goShortDialogueItem7.Name             = "GoShortDialogueItem7";
            goShortDialogueItem7.MillisecondDelay = 500;
            LimitExecutionAction goShortItem7ToItem8 = new LimitExecutionAction();

            goShortItem7ToItem8.InputList.Add("success");
            goShortItem7ToItem8.TargetDialogueItemName = "GoShortDialogueItem8";
            goShortDialogueItem7.ActionList.Add(goShortItem7ToItem8);
            ResponseAction goShortItem7ToItem6 = new ResponseAction();

            goShortItem7ToItem6.InputList.Add("failure");
            goShortItem7ToItem6.OutputList.Add("Your limit was on the wrong side of the market, try again");
            goShortItem7ToItem6.TargetDialogueItemName = "GoShortDialogueItem6";
            goShortDialogueItem7.ActionList.Add(goShortItem7ToItem6);
            goShortDialogue.ItemList.Add(goShortDialogueItem7);

            //Item8 : set TP question
            InteractionItem goShortDialogueItem8 = new InteractionItem();

            goShortDialogueItem8.Name             = "GoShortDialogueItem8";
            goShortDialogueItem8.MillisecondDelay = 1500;
            OutputAction goShortItem8ToItem9 = new OutputAction();

            goShortItem8ToItem9.OutputList.Add("Would you also like to set a Target Profit?");
            goShortItem8ToItem9.TargetDialogueItemName = "GoShortDialogueItem9";
            goShortDialogueItem8.ActionList.Add(goShortItem8ToItem9);
            goShortDialogue.ItemList.Add(goShortDialogueItem8);

            //Item9 : set TP answer
            InteractionItem goShortDialogueItem9 = new InteractionItem();

            goShortDialogueItem9.Name             = "GoShortDialogueItem9";
            goShortDialogueItem9.MillisecondDelay = 500;

            ResponseAction goShortItem9ToMainDialogueAction = new ResponseAction(); //dont set a target path

            goShortItem9ToMainDialogueAction.InputList.Add("no");                   //TODO Change to negative answer list
            goShortItem9ToMainDialogueAction.OutputList.Add("Okay, have a nice day");
            goShortItem9ToMainDialogueAction.TargetDialogueItemName   = "MainDialogueItem1";
            goShortItem9ToMainDialogueAction.BrainProcessToDeactivate = "GoShortDialogue";
            goShortItem9ToMainDialogueAction.BrainProcessToActivate   = "MainDialogue";
            goShortDialogueItem9.ActionList.Add(goShortItem9ToMainDialogueAction);

            ResponseAction goShortItem9ToItem10Action = new ResponseAction(); // set a target path

            goShortItem9ToItem10Action.InputList.Add("yes");
            goShortItem9ToItem10Action.TargetDialogueItemName = "GoShortDialogueItem10";
            goShortDialogueItem9.ActionList.Add(goShortItem9ToItem10Action);
            goShortDialogue.ItemList.Add(goShortDialogueItem9);

            //Item10: where to set target question
            InteractionItem goShortDialogueItem10 = new InteractionItem();

            goShortDialogueItem10.Name             = "GoShortDialogueItem10";
            goShortDialogueItem10.MillisecondDelay = 500;
            OutputAction goShortItem10ToItem11 = new OutputAction();

            goShortItem10ToItem11.OutputList.Add("At what level would you like to set your target profit?");
            goShortItem10ToItem11.TargetDialogueItemName = "GoShortDialogueItem11";
            goShortDialogueItem10.ActionList.Add(goShortItem10ToItem11);
            goShortDialogue.ItemList.Add(goShortDialogueItem10);


            //Item11 : where to set target answer
            SLTPOrderItem goShortDialogueItem11 = new SLTPOrderItem(SLTPOrderItem.SET_TARGET_PROFIT, MarketOrderItem.DIRECTION_SHORT);

            goShortDialogueItem11.Name             = "GoShortDialogueItem11";
            goShortDialogueItem11.MillisecondDelay = 500;
            LimitExecutionAction goShortItem11ToItem12 = new LimitExecutionAction();

            goShortItem11ToItem12.InputList.Add("success");
            goShortItem11ToItem12.TargetDialogueItemName = "GoShortDialogueItem12";
            goShortDialogueItem11.ActionList.Add(goShortItem11ToItem12);
            ResponseAction goShortItem11ToItem10 = new ResponseAction();

            goShortItem11ToItem10.InputList.Add("failure");
            goShortItem11ToItem10.OutputList.Add("Your limit was on the wrong side of the market, try again");
            goShortItem11ToItem10.TargetDialogueItemName = "GoShortDialogueItem10";
            goShortDialogueItem11.ActionList.Add(goShortItem11ToItem10);
            goShortDialogue.ItemList.Add(goShortDialogueItem11);


            //Item12 : Everything done, return to main dialogue
            InteractionItem goShortDialogueItem12 = new InteractionItem();

            goShortDialogueItem12.Name             = "GoShortDialogueItem12";
            goShortDialogueItem12.MillisecondDelay = 1500;
            OutputAction goShortItem12ToMainDialogue = new OutputAction();

            goShortItem12ToMainDialogue.OutputList.Add("All is set, good luck and have a nice day!");
            goShortItem12ToMainDialogue.TargetDialogueItemName   = "MainDialogueItem1";
            goShortItem12ToMainDialogue.BrainProcessToDeactivate = "GoShortDialogue";
            goShortItem12ToMainDialogue.BrainProcessToActivate   = "MainDialogue";
            goShortDialogueItem12.ActionList.Add(goShortItem12ToMainDialogue);
            goShortDialogue.ItemList.Add(goShortDialogueItem12);


            /*
             * goShort Dialogue Process end
             */

            FinalizeSetup();
        }
Esempio n. 26
0
 public OutputAction <TElement> FromObservable <TElement>(Func <IObservable <TElement> > workFactory, IObservable <bool> enabledIf = null)
 {
     return(OutputAction <TElement> .FromObservable(workFactory, schedulerProvider.MainScheduler, enabledIf));
 }
        private ActionsControllerPressManager AddOutputActionHandler(PressHandlerDelegate <DirectionActionChange> handler, OutputAction outputAction)
        {
            AddHandler(handler,
                       DirectionActionChangeComparator,
                       ActionsController.DirectionActionPressed[outputAction],
                       ActionsController.DirectionActionUnpressed[outputAction]);

            return(this);
        }
Esempio n. 28
0
        public ChristmasAgent()
        {
            Name = "ChristmasAgent";

            DialogueProcess openingDialogue = new DialogueProcess();

            openingDialogue.Name            = "openingDialogue";
            openingDialogue.ActiveOnStartup = true;
            openingDialogue.SetOwnerAgent(this);
            BrainProcessList.Add(openingDialogue);

            InteractionItem openingItem = new InteractionItem();

            //openingItem.MillisecondDelay = 5000; // TODO: Just delays windows opening
            openingDialogue.ItemList.Add(openingItem);
            openingItem.Name = "openingItem";
            OutputAction initialGreetingAction = new OutputAction();

            openingItem.ActionList.Add(initialGreetingAction);

            initialGreetingAction.OutputList.Add("Hello");
            initialGreetingAction.OutputList.Add("Hi");
            initialGreetingAction.OutputList.Add("Hey");

            InteractionItem howWasChristmasItem = new InteractionItem(); //Doesn't work with dialogueitem?

            openingDialogue.ItemList.Add(howWasChristmasItem);
            howWasChristmasItem.Name = "howWasChristmasItem";
            initialGreetingAction.TargetDialogueItemName = howWasChristmasItem.Name;
            ResponseAction howWasChristmasAction = new ResponseAction();

            howWasChristmasAction.InputList.Add("Hello");
            howWasChristmasAction.InputList.Add("Hi");
            howWasChristmasAction.InputList.Add("Hey");
            howWasChristmasAction.OutputList.Add("How was christmas?");
            howWasChristmasAction.OutputList.Add("How was your christmas?");
            //howWasChristmasAction.OutputList.Add("bla");
            howWasChristmasItem.ActionList.Add(howWasChristmasAction);

            DialogueProcess christmasDialogue = new DialogueProcess();

            christmasDialogue.Name            = "christmasDialogue";
            christmasDialogue.ActiveOnStartup = false;
            christmasDialogue.SetOwnerAgent(this);
            BrainProcessList.Add(christmasDialogue);
            howWasChristmasAction.BrainProcessToActivate = christmasDialogue.Name;

            InteractionItem christmasInquiryStartItem = new InteractionItem();

            christmasInquiryStartItem.Name = "christmasInquiryStartItem";
            christmasDialogue.ItemList.Add(christmasInquiryStartItem);
            christmasDialogue.ProcessActivatedOnFailure = openingDialogue.Name;

            ResponseAction ra_good = new ResponseAction();

            christmasInquiryStartItem.ActionList.Add(ra_good);
            ra_good.BrainProcessToDeactivate = christmasDialogue.Name;
            ra_good.InputList.Add("Good");
            ra_good.InputList.Add("Alright");
            ra_good.InputList.Add("Great");
            ra_good.OutputList.Add("I'm very happy to hear that!");
            ra_good.OutputList.Add("Good for you!");
            ra_good.OutputList.Add("Lovely!");

            // ================================================================
            //Good christmas inquiry
            // ================================================================
            DialogueProcess goodChristmasDialogue = new DialogueProcess();

            goodChristmasDialogue.Name            = "goodChristmasDialogue";
            goodChristmasDialogue.ActiveOnStartup = false;
            goodChristmasDialogue.SetOwnerAgent(this);
            BrainProcessList.Add(goodChristmasDialogue);
            ra_good.BrainProcessToActivate = goodChristmasDialogue.Name;

            InteractionItem goodChristmasItem = new InteractionItem();

            goodChristmasItem.Name             = "goodChristmasItem";
            ra_good.TargetDialogueItemName     = goodChristmasItem.Name;
            goodChristmasItem.MillisecondDelay = 500;
            OutputAction anythingElse = new OutputAction();

            anythingElse.OutputList.Add("Did you want to talk about anything else?");
            anythingElse.OutputList.Add("Anything else on your mind?");
            //anythingElse.BrainProcessToDeactivate = christmasDialogue.Name;
            goodChristmasItem.ActionList.Add(anythingElse);
            goodChristmasDialogue.ItemList.Add(goodChristmasItem);

            InteractionItem goodChristmasResponseItem = new InteractionItem();

            goodChristmasResponseItem.Name = "goodChristmasResponseItem";
            //goodChristmasDialogue.ItemList.Add(goodChristmasResponseItem);
            anythingElse.TargetDialogueItemName = goodChristmasResponseItem.Name;

            ResponseAction nothingElse = new ResponseAction();

            nothingElse.InputList.Add("No");
            nothingElse.InputList.Add("That's not it");
            nothingElse.InputList.Add("Nope");
            nothingElse.OutputList.Add("Ok, see you later!");
            nothingElse.OutputList.Add("Good.");
            nothingElse.OutputList.Add("Good bye!");
            goodChristmasResponseItem.ActionList.Add(nothingElse);

            ResponseAction somethingElse = new ResponseAction();

            somethingElse.InputList.Add("Yes");
            somethingElse.InputList.Add("Yeah");
            somethingElse.InputList.Add("Aye");
            somethingElse.OutputList.Add("*Crickets*");
            somethingElse.OutputList.Add("Tell it to someone else.");
            somethingElse.OutputList.Add("I don't want to hear it.");
            goodChristmasResponseItem.ActionList.Add(somethingElse);

            goodChristmasDialogue.ItemList.Add(goodChristmasResponseItem);
            // ================================================================
            // Branch end
            // ================================================================

            ResponseAction ra_bad = new ResponseAction();

            christmasInquiryStartItem.ActionList.Add(ra_bad);
            ra_bad.BrainProcessToDeactivate = openingDialogue.Name;
            ra_bad.InputList.Add("Bad");
            ra_bad.InputList.Add("Awful");
            ra_bad.InputList.Add("Terrible");

            Random random = new Random();
            double r      = random.NextDouble();

            if (r < 0.25)
            {
                ra_bad.OutputList.Add("I'm sorry to hear that, next year will be better.");
                ra_bad.OutputList.Add("Ooh a new UDP packet, gotta go!");
            }
            else
            {
                ra_bad.OutputList.Add("Were you unhappy with your presents?");
                ra_bad.OutputList.Add("Were you disappointed with your presents?");

                DialogueProcess presentsDialogue = new DialogueProcess();
                presentsDialogue.Name            = "presentsDialogue";
                presentsDialogue.ActiveOnStartup = false;
                BrainProcessList.Add(presentsDialogue); //MUST add to list, will show in memory regardless though
                ra_bad.BrainProcessToActivate = presentsDialogue.Name;

                InteractionItem presentsItem = new InteractionItem();
                presentsDialogue.ItemList.Add(presentsItem);

                ResponseAction ra_good_presents = new ResponseAction();
                presentsItem.ActionList.Add(ra_good_presents);
                //ra_good_presents.BrainProcessToDeactivate = helloDialogue.Name;
                ra_good_presents.InputList.Add("No");
                ra_good_presents.InputList.Add("That's not it");
                ra_good_presents.InputList.Add("Nope");
                ra_good_presents.OutputList.Add("Then I can't help you.");
                ra_good_presents.OutputList.Add("In that case, I can't help you.");

                //Branch end

                ResponseAction ra_bad_presents = new ResponseAction();
                presentsItem.ActionList.Add(ra_bad_presents);
                //ra_bad_presents.BrainProcessToDeactivate = helloDialogue.Name;
                ra_bad_presents.InputList.Add("Yes");
                ra_bad_presents.InputList.Add("Yeah");
                ra_bad_presents.InputList.Add("Aye");
                ra_bad_presents.InputList.Add("Yes they were cheap");
                ra_bad_presents.OutputList.Add("Shall I add your friends and family to your list of enemies?");

                InteractionItem enemiesItem = new InteractionItem();
                presentsDialogue.ItemList.Add(enemiesItem);
                enemiesItem.Name = "enemiesItem";
                ra_bad_presents.TargetDialogueItemName = enemiesItem.Name;

                ResponseAction enemiesAction = new ResponseAction();
                enemiesItem.ActionList.Add(enemiesAction);
                enemiesAction.InputList.Add("Yes");
                enemiesAction.InputList.Add("Yes, and their pets");
                enemiesAction.OutputList.Add("They've been added to your list of mortal enemies.");
                enemiesAction.OutputList.Add("Done. You're a terrible person.");

                ResponseAction noEnemiesAction = new ResponseAction();
                enemiesItem.ActionList.Add(noEnemiesAction);
                noEnemiesAction.InputList.Add("No");
                noEnemiesAction.InputList.Add("Don't do that");
                noEnemiesAction.InputList.Add("Nope");
                noEnemiesAction.OutputList.Add("I'm going to do it anyway. Good bye!");
                noEnemiesAction.OutputList.Add("Maybe next year. See you then!");

                /*
                 * MemoryAccessItem readEnemyItem = new MemoryAccessItem();
                 * readEnemyItem.Name = "mai";
                 * enemiesAction.TargetDialogueItemName = readEnemyItem.Name;
                 * ReadByTagAction rbta = new ReadByTagAction();
                 * readEnemyItem.ActionList.Add(rbta);
                 *
                 * MemoryItem mi = new MemoryItem();
                 * mi.Content = "Friends and family and their pets";
                 * mi.Tag = "MortalEnemies";
                 * WorkingMemory.InsertItem(mi);
                 * rbta.Tag = mi.Tag;
                 */
            }
        }
Esempio n. 29
0
        /*
         *       Lightness
         * Hue   0         1           2
         * 0    /         push        pop
         * 1    add       sub         mul
         * 2    div       mod         not
         * 3    greater   pointer     switch
         * 4    dup       roll        in number
         * 5    in char   out number  out char
         */

        private void PerformInstruction(int fromColorIndex, int toColorIndex, int codelCount)
        {
            int hueDiff       = HueDiff(fromColorIndex, toColorIndex);
            int lightnessDiff = LightnessDiff(fromColorIndex, toColorIndex);

            Debug.WriteLine($"PerformInstruction: From{ColorIndexToString(fromColorIndex)} to {ColorIndexToString(toColorIndex)} => Hue:{hueDiff} Lightness:{lightnessDiff}");

            switch (hueDiff)
            {
            case 0:     // NOP, Push, Pop
                switch (lightnessDiff)
                {
                case 0:         // NOP
                    Debug.WriteLine("Action: NOP");
                    break;

                case 1:         // Push
                    Debug.WriteLine($"Action: PUSH {codelCount}");
                    Stack.Push(codelCount);
                    break;

                case 2:         // Pop
                    if (Stack.Count == 0)
                    {
                        Debug.WriteLine("Action: POP failed: stack underflow");
                    }
                    else
                    {
                        Debug.WriteLine("Action: POP");
                        Stack.Pop();         // Pop and discard
                    }
                    break;
                }
                break;

            case 1:     // Add, Sub, Mul
                switch (lightnessDiff)
                {
                case 0:         // Add
                    // Pop 2 values, add them and push back result
                    PerformMathOperation('+');
                    break;

                case 1:         // Sub
                    // Pop 2 values, sub (top from second top) them and push back result
                    PerformMathOperation('-');
                    break;

                case 2:         // Mul
                    // Pop 2 values, multiply them and push back result
                    PerformMathOperation('*');
                    break;
                }
                break;

            case 2:     // Div, Mod, Not
                switch (lightnessDiff)
                {
                case 0:         // Div
                    // Pop 2 values, divide (second top by top) them and push back result
                    PerformMathOperation('/');
                    break;

                case 1:         // Mod
                    // Pop 2 values, mod (second top modulo top) them and push back result
                    PerformMathOperation('%');
                    break;

                case 2:         // Not
                    // Pop 1 value, not (0->1, 0 otherwise) it and push back result
                    if (Stack.Count == 0)
                    {
                        Debug.WriteLine("Action: NOT failed: stack underflow");
                    }
                    else
                    {
                        int operand = Stack.Pop();
                        int result  = operand == 0
                                    ? 1
                                    : 0;
                        Debug.WriteLine($"Action: NOT({operand})={result}");
                        Stack.Push(result);
                    }
                    break;
                }
                break;

            case 3:     // greater, pointer, switch
                switch (lightnessDiff)
                {
                case 0:         // Greater
                    // Pop 2 values, if second top > top push 1, push 0 otherwise
                    if (Stack.Count < 2)
                    {
                        Debug.WriteLine("Action: GREATER failed: stack underflow");
                    }
                    else
                    {
                        int operand2 = Stack.Pop();
                        int operand1 = Stack.Pop();
                        int result   = operand1 > operand2
                                    ? 1
                                    : 0;
                        Debug.WriteLine($"Action: GREATER({operand1},{operand2})={result}");
                        Stack.Push(result);
                    }
                    break;

                case 1:         // Pointer
                    // Pop 1 value, turn DP clockwise if positive, counterclockwise otherwise
                    if (Stack.Count == 0)
                    {
                        Debug.WriteLine("Action: POINTER failed: stack underflow");
                    }
                    else
                    {
                        int operand    = Stack.Pop();
                        int absOperand = operand;
                        Func <PointerDirections, PointerDirections> func;
                        if (absOperand > 0)
                        {
                            func = TurnDirectionPointerClockwise;
                        }
                        else
                        {
                            absOperand = -absOperand;
                            func       = TurnDirectionPointerCounterClockwise;
                        }
                        for (int i = 0; i < absOperand % 4; i++)
                        {
                            DirectionPointer = func(DirectionPointer);
                        }
                        Debug.WriteLine($"Action: POINTER({operand})={DirectionPointer}");
                    }
                    break;

                case 2:         // Switch
                    // Pop 1 value, toggle CC that many times
                    if (Stack.Count == 0)
                    {
                        Debug.WriteLine("Action: SWITCH failed: stack underflow");
                    }
                    else
                    {
                        int operand = Stack.Pop();
                        for (int i = 0; i < operand % 4; i++)
                        {
                            CodelChooser = ToggleCodelChooser(CodelChooser);
                        }
                        Debug.WriteLine($"Action: SWITCH({operand})={CodelChooser}");
                    }
                    break;
                }
                break;

            case 4:     // dup, roll, in number
                switch (lightnessDiff)
                {
                case 0:         // Duplicate
                    // Push a copy of top value
                    if (Stack.Count == 0)
                    {
                        Debug.WriteLine("Action: DUPLICATE failed: stack underflow");
                    }
                    else
                    {
                        int operand = Stack.Peek();
                        Stack.Push(operand);
                        Debug.WriteLine($"Action: DUPLICATE({operand})");
                    }
                    break;

                case 1:         // Roll
                    // Pop 2 values, roll remaining stack entries to a depth equals to the second top by a number of rolls equal to top (see http://www.dangermouse.net/esoteric/piet.html)
                    //  roll of depth k: move top at position k in stack and move up every value above k'th position
                    if (Stack.Count < 2)
                    {
                        Debug.WriteLine("Action: ROLL failed: stack underflow");
                    }
                    else
                    {
                        int roll  = Stack.Pop();
                        int depth = Stack.Pop();
                        if (depth < 0)
                        {
                            Debug.WriteLine($"Action: ROLL failed: negative depth {depth}");
                        }
                        else if (Stack.Count < depth)
                        {
                            Debug.WriteLine($"Action: ROLL failed: stack underflow {depth}");
                        }
                        else
                        {
                            Stack.Roll(roll, depth);
                        }
                    }
                    break;

                case 2:         // In number
                    // Read a number from stdin and push it
                    string inputAsString = InputFunc?.Invoke();
                    int    inputNumber;
                    if (!int.TryParse(inputAsString, out inputNumber))
                    {
                        Debug.WriteLine($"Action: IN NUMBER failed: invalid input {inputAsString}");
                    }
                    else
                    {
                        Debug.WriteLine($"Action: IN NUMBER({inputNumber})");
                        Stack.Push(inputNumber);
                    }
                    break;
                }
                break;

            case 5:     // in char, out number, out char
                switch (lightnessDiff)
                {
                case 0:         // In char
                    // Read a char from stdin and push it
                    string inputAsString = InputFunc?.Invoke();
                    if (string.IsNullOrEmpty(inputAsString))
                    {
                        Debug.WriteLine("Action: IN CHAR failed: null or empty input");
                    }
                    else
                    {
                        int inputChar = inputAsString[0] % 255;
                        Debug.WriteLine($"Action: IN CHAR({inputChar})");
                        Stack.Push(inputChar);
                    }
                    break;

                case 1:         // Out number
                    // Pop 1 value, print it on stdout as number
                    if (Stack.Count == 0)
                    {
                        Debug.WriteLine("Action: OUT NUMBER failed: stack underflow");
                    }
                    else
                    {
                        int operand = Stack.Pop();
                        Debug.WriteLine($"Action: OUT NUMBER({operand})");
                        OutputAction?.Invoke(operand.ToString());
                    }
                    break;

                case 2:         // Out char
                    // Pop 1 value, print it on stdout as char
                    if (Stack.Count == 0)
                    {
                        Debug.WriteLine("Action: OUT CHAR failed: stack underflow");
                    }
                    else
                    {
                        int  outputAsInt = Stack.Pop();
                        char operand     = (char)(outputAsInt % 255);
                        Debug.WriteLine($"Action: OUT CHAR({operand})");
                        OutputAction?.Invoke(operand.ToString());
                    }
                    break;
                }
                break;
            }
        }
 public PushBusActionOutputAction(OutputAction child = null)
     : base(child)
 {
 }
        public DiagnosticPipeline(
            IHealthReporter healthReporter,
            IReadOnlyCollection <IObservable <EventData> > inputs,
            IReadOnlyCollection <IFilter> globalFilters,
            IReadOnlyCollection <EventSink> sinks,
            DiagnosticPipelineConfiguration pipelineConfiguration = null,
            bool disposeDependencies = false)
        {
            Requires.NotNull(healthReporter, nameof(healthReporter));
            Requires.NotNull(inputs, nameof(inputs));
            Requires.Argument(inputs.Count > 0, nameof(inputs), "There must be at least one input");
            Requires.NotNull(sinks, nameof(sinks));
            Requires.Argument(sinks.Count > 0, nameof(sinks), "There must be at least one sink");

            this.eventsInProgress = 0;

            this.pipelineConfiguration = pipelineConfiguration ?? new DiagnosticPipelineConfiguration();

            // An estimatie how many batches of events to allow inside the pipeline.
            // We want to be able to process full buffer of events, but also have enough batches in play in case of high concurrency.
            int MaxNumberOfBatchesInProgress = Math.Max(
                5 * this.pipelineConfiguration.MaxConcurrency,
                this.pipelineConfiguration.PipelineBufferSize / this.pipelineConfiguration.MaxEventBatchSize);

            this.Inputs = inputs;
            this.Sinks  = sinks;

            // Just play nice and make sure there is always something to enumerate on
            this.GlobalFilters = globalFilters ?? new IFilter[0];

            this.HealthReporter          = healthReporter;
            this.cancellationTokenSource = new CancellationTokenSource();
            var propagateCompletion = new DataflowLinkOptions()
            {
                PropagateCompletion = true
            };

            this.pipelineLinkDisposables = new List <IDisposable>();
            this.pipelineCompletionTasks = new List <Task>();

            var inputBuffer = new BufferBlock <EventData>(
                new DataflowBlockOptions()
            {
                BoundedCapacity   = this.pipelineConfiguration.PipelineBufferSize,
                CancellationToken = this.cancellationTokenSource.Token
            });

            this.pipelineHead = inputBuffer;
            this.pipelineCompletionTasks.Add(inputBuffer.Completion);

            var batcher = new BatchBlock <EventData>(
                this.pipelineConfiguration.MaxEventBatchSize,
                new GroupingDataflowBlockOptions()
            {
                BoundedCapacity   = this.pipelineConfiguration.MaxEventBatchSize,
                CancellationToken = this.cancellationTokenSource.Token
            }
                );

            this.pipelineLinkDisposables.Add(inputBuffer.LinkTo(batcher, propagateCompletion));
            this.pipelineCompletionTasks.Add(batcher.Completion);

            this.pipelineLinkDisposables.Add(new Timer(
                                                 (unused) => batcher.TriggerBatch(),
                                                 state: null,
                                                 dueTime: TimeSpan.FromMilliseconds(this.pipelineConfiguration.MaxBatchDelayMsec),
                                                 period: TimeSpan.FromMilliseconds(this.pipelineConfiguration.MaxBatchDelayMsec)));

            ISourceBlock <EventData[]> sinkSource;
            FilterAction filterTransform;

            if (this.GlobalFilters.Count > 0)
            {
                filterTransform = new FilterAction(
                    this.GlobalFilters,
                    this.cancellationTokenSource.Token,
                    MaxNumberOfBatchesInProgress,
                    this.pipelineConfiguration.MaxConcurrency,
                    healthReporter,
                    this.OnEventsFilteredOut);
                var globalFiltersBlock = filterTransform.GetFilterBlock();
                this.pipelineLinkDisposables.Add(batcher.LinkTo(globalFiltersBlock, propagateCompletion));
                this.pipelineCompletionTasks.Add(globalFiltersBlock.Completion);
                sinkSource = globalFiltersBlock;
            }
            else
            {
                sinkSource = batcher;
            }

            if (sinks.Count > 1)
            {
                // After broadcasting we will effectively have (sinks.Count - 1) * batch.Length more events in the pipeline,
                // because the broadcaster is cloning the events for the sake of each sink (filters-output combination).
                var eventCounter = new TransformBlock <EventData[], EventData[]>(
                    (batch) => { Interlocked.Add(ref this.eventsInProgress, (sinks.Count - 1) * batch.Length);  return(batch); },
                    new ExecutionDataflowBlockOptions()
                {
                    BoundedCapacity   = MaxNumberOfBatchesInProgress,
                    CancellationToken = this.cancellationTokenSource.Token
                });
                this.pipelineLinkDisposables.Add(sinkSource.LinkTo(eventCounter, propagateCompletion));
                this.pipelineCompletionTasks.Add(eventCounter.Completion);

                var broadcaster = new BroadcastBlock <EventData[]>(
                    (events) => events?.Select((e) => e.DeepClone()).ToArray(),
                    new DataflowBlockOptions()
                {
                    BoundedCapacity   = MaxNumberOfBatchesInProgress,
                    CancellationToken = this.cancellationTokenSource.Token
                });
                this.pipelineLinkDisposables.Add(eventCounter.LinkTo(broadcaster, propagateCompletion));
                this.pipelineCompletionTasks.Add(broadcaster.Completion);
                sinkSource = broadcaster;
            }

            foreach (var sink in sinks)
            {
                ISourceBlock <EventData[]> outputSource = sinkSource;
                if (sink.Filters != null && sink.Filters.Count > 0)
                {
                    filterTransform = new FilterAction(
                        sink.Filters,
                        this.cancellationTokenSource.Token,
                        MaxNumberOfBatchesInProgress,
                        this.pipelineConfiguration.MaxConcurrency,
                        healthReporter,
                        this.OnEventsFilteredOut);
                    var filterBlock = filterTransform.GetFilterBlock();
                    this.pipelineLinkDisposables.Add(sinkSource.LinkTo(filterBlock, propagateCompletion));
                    this.pipelineCompletionTasks.Add(filterBlock.Completion);
                    outputSource = filterBlock;
                }

                OutputAction outputAction = new OutputAction(
                    sink.Output,
                    this.cancellationTokenSource.Token,
                    MaxNumberOfBatchesInProgress,
                    this.pipelineConfiguration.MaxConcurrency,
                    healthReporter,
                    (eventsSentCount) => Interlocked.Add(ref this.eventsInProgress, -eventsSentCount));
                var outputBlock = outputAction.GetOutputBlock();
                this.pipelineLinkDisposables.Add(outputSource.LinkTo(outputBlock, propagateCompletion));
                this.pipelineCompletionTasks.Add(outputBlock.Completion);
            }

            IObserver <EventData> inputBufferObserver = new TargetBlockObserver <EventData>(
                inputBuffer,
                this.HealthReporter,
                () => Interlocked.Increment(ref this.eventsInProgress));

            this.inputSubscriptions = new List <IDisposable>(inputs.Count);
            foreach (var input in inputs)
            {
                this.inputSubscriptions.Add(input.Subscribe(inputBufferObserver));
            }

            this.disposed            = false;
            this.disposeDependencies = disposeDependencies;
        }