Ejemplo n.º 1
0
        private void ParseHostsLine(int lineNumber, string line)
        {
            var match = Regex.Match(line, Constants.HostLineRegEx);

            if (match.Success)
            {
                var address  = match.Groups[1].Value;
                var name     = match.Groups[2].Value;
                var comment  = match.Groups[3].Value.Trim();
                var favorite = (comment.StartsWith(Constants.FavoriteTag));
                if (favorite)
                {
                    comment = comment.Substring(Constants.FavoriteTag.Length);
                }

                if (string.IsNullOrWhiteSpace(address) || string.IsNullOrWhiteSpace(name))
                { //just parse the comment
                    if (comment.StartsWith(Constants.TargetTag))
                    {
                        comment = comment.Substring(Constants.TargetTag.Length);
                        ParseTarget(lineNumber, comment);
                    }
                }
                else
                { //add this to the list
                    HostItems.Add(new HostItem()
                    {
                        Address = address, Name = name, Comment = comment, Favorite = favorite, LineNumber = lineNumber
                    });
                }
            }
        }
        public Task LoadAndRunBatch(string[] args)
        {
            Load();
            BenchmarkItem[] activeBenchmarks = BenchmarkItem.GetActive(benchmarks, args);
            var             dispatcher       = this.GetRequiredService <IDispatcherService>();
            var             awaiter          = this.GetService <IUIAwaiter>();

            this.batchTotal = activeBenchmarks.Length;
            return(Task.Factory.StartNew(() =>
            {
                int total = 0;
                for (int i = 0; i < activeBenchmarks.Length; i++)
                {
                    this.batchIndex = i + 1;
                    var current = activeBenchmarks[i];
                    total = UIOperation <int>(dispatcher, () =>
                    {
                        ActiveHostItem = HostItems.FirstOrDefault(host => BenchmarkItem.IsBenchmarkFor(current.Type, host.Name));
                        if (ActiveHostItem != null)
                        {
                            ActiveBenchmarkItem = current;
                        }
                        return total + ((ActiveHostItem != null) ? 1 : 0);
                    }).ContinueWith(tSelectItem =>
                    {
                        Run().Wait();
                        return tSelectItem.Result;
                    }).Result;
                }
                this.batchTotal = null;
                this.batchIndex = null;
                dispatcher.BeginInvoke(() =>
                                       OnBatchRunComplete(total));
            }));
        }
Ejemplo n.º 3
0
 private void DiscoverTags()
 {
     //get all the tags of the target
     TargetTags = Targets.SelectMany(t => t.Tags).Distinct().ToArray();
     ItemTags   =
         HostItems.Join(Targets, item => item.Address, target => target.Address, (item, target) => target)
         .SelectMany(t => t.Tags)
         .Distinct()
         .ToArray();
 }
Ejemplo n.º 4
0
 private void ClearData()
 {
     HostItems.Clear();
     Targets.Clear();
 }