private async void AddStrategy(object param)
        {
            if (param == null ||
                string.IsNullOrEmpty(param.ToString()))
            {
                return;
            }

            var strategyName = param.ToString();

            if (Strategies.Any(s => s.Name.Equals(strategyName)))
            {
                ShowMessage(new Message {
                    MessageType = MessageType.Info, Text = $"A strategy with the name {strategyName} already exists."
                });
                return;
            }

            try
            {
                var strategy = new Strategy {
                    Name = strategyName
                };
                await strategyService.SaveStrategy(strategy);

                Strategies.Add(strategy);
                Module.AddStrategy(strategy.Name);
            }
            catch (Exception ex)
            {
                ShowMessage(new Message {
                    MessageType = MessageType.Error, Text = ex.Message
                });
            }
        }
Exemplo n.º 2
0
        private async void AddStrategy(object param)
        {
            if (param == null ||
                string.IsNullOrEmpty(param.ToString()))
            {
                return;
            }

            var strategyName = param.ToString();

            if (Strategies.Any(s => s.Name.Equals(strategyName, StringComparison.Ordinal)))
            {
                ShowMessage(new Message {
                    MessageType = MessageType.Info, Text = $"A strategy with the name {strategyName} already exists."
                });
                return;
            }

            try
            {
                IsLoading = true;

                var strategy = new Strategy {
                    Name = strategyName
                };
                await strategyService.SaveStrategy(strategy).ConfigureAwait(true);

                Strategies.Add(strategy);
                ConfigurationModule.AddStrategy(strategy.Name);
            }
            catch (Exception ex)
            {
                ShowMessage(new Message {
                    MessageType = MessageType.Error, Text = ex.Message
                });
            }
            finally
            {
                IsLoading = false;
            }
        }
 private bool ProjectFilter(string path)
 {
     return(Strategies.Any(strategy => strategy.ProjectFilter(path)));
 }