/// <summary> /// Starts normal execution of the strategy /// </summary> /// <param name="ctrArgs">Arguments to be used to execute strategy</param> private void RunStrategy(object[] ctrArgs) { // Create new object to use with Event Aggregator InitializeStrategy initializeStrategy = new InitializeStrategy(_strategyType, ctrArgs); // Publish Event to Notify Listeners EventSystem.Publish <InitializeStrategy>(initializeStrategy); }
/// <summary> /// Sets up the strategy to be executed /// </summary> /// <param name="initializeStrategy">Holds info to initialize the given strategy</param> private void InitializeUserStrategy(InitializeStrategy initializeStrategy) { try { if (_asyncClassLogger.IsInfoEnabled) { _asyncClassLogger.Info("Setting up user strategy to run: " + initializeStrategy.StrategyType.FullName, _type.FullName, "InitializeUserStrategy"); } // Get new Key. string key = ApplicationIdGenerator.NextId(); // Save Strategy details in new Strategy Executor object StrategyExecutor strategyExecutor = new StrategyExecutor(key, initializeStrategy.StrategyType, initializeStrategy.CtorArguments); // Add to local map _strategiesCollection.AddOrUpdate(key, strategyExecutor, (ky, value) => strategyExecutor); //Register Event strategyExecutor.StatusChanged += OnStatusChanged; strategyExecutor.ExecutionReceived += OnExecutionArrived; // Save Brief info of constructor parameters StringBuilder briefInfo = new StringBuilder(); // Add Strategy Description briefInfo.Append(LoadCustomStrategy.GetCustomClassSummary(initializeStrategy.StrategyType)); briefInfo.Append(" :: "); // Add Parameters Description foreach (object ctorArgument in initializeStrategy.CtorArguments) { briefInfo.Append(ctorArgument.ToString()); briefInfo.Append("|"); } // Create object to add to AddStrattegy.cs object SelectedStrategy selectedStrategy = new SelectedStrategy { Key = key, Symbol = initializeStrategy.CtorArguments[3].ToString(), BriefInfo = briefInfo.ToString() }; // Create object to pass to event aggregator. AddStrategy addStrategy = new AddStrategy(selectedStrategy); // Publish event to notify listeners. EventSystem.Publish <AddStrategy>(addStrategy); } catch (Exception exception) { _asyncClassLogger.Error(exception, _type.FullName, "InitializeUserStrategy"); } }