Exemple #1
0
        public FormSampleRunner()
        {
            this.InitializeComponent();

            var all_types             = typeof(Program).Assembly.GetExportedTypes();
            var public_sample_classes = all_types
                                        .Where(t => t.IsPublic)
                                        .Where(t => t.IsClass)
                                        .Where(t => t.Name.Contains("Sample"))
                                        .OrderBy(t => t.Name)
                                        .ToList();

            var names = new List <string>();

            foreach (var t in public_sample_classes)
            {
                var methods = t.GetMethods()
                              .Where(m => m.IsPublic)
                              .Where(m => m.IsStatic)
                              .Where(m => !m.GetParameters().Any())
                              .OrderBy(m => m.Name);

                foreach (var m in methods)
                {
                    string name = string.Format("{0} / {1}", t.Name, m.Name);
                    names.Add(name);

                    var item = new SampleMethod();
                    item.Name   = name;
                    item.Method = m;

                    this.samplemethods.Add(item);

                    this.dic[name] = item;
                }
            }

            var prev_names = this.GetPreviouslySelectedSamples();

            foreach (var name in names)
            {
                bool ischecked = prev_names.Contains(name);
                this.checkedListBox1.Items.Add(name, ischecked);
            }

            const bool autorun = false;

            if (autorun)
            {
                // this.RunSelectedSamples();
            }
        }
        public FormSampleRunner()
        {
            this.InitializeComponent();

            var all_types = typeof (Program).Assembly.GetExportedTypes();
            var public_sample_classes = all_types
                .Where(t => t.IsPublic)
                .Where(t => t.IsClass)
                .Where(t => t.Name.Contains("Sample"))
                .OrderBy(t => t.Name)
                .ToList();

            var names = new List<string>();
            foreach (var t in public_sample_classes)
            {
                var methods = t.GetMethods()
                    .Where(m => m.IsPublic)
                    .Where(m => m.IsStatic)
                    .Where(m => !m.GetParameters().Any())
                    .OrderBy(m => m.Name);

                foreach (var m in methods)
                {
                    string name = string.Format("{0} / {1}", t.Name, m.Name);
                    names.Add(name);

                    var item = new SampleMethod();
                    item.Name = name;
                    item.Method = m;

                    this.samplemethods.Add(item);

                    this.dic[name] = item;
                }
            }

            var prev_names = this.GetPreviouslySelectedSamples();

            foreach (var name in names)
            {
                bool ischecked = prev_names.Contains(name);
                this.checkedListBox1.Items.Add(name, ischecked);
            }

            const bool autorun = false;
            if (autorun)
            {
            // this.RunSelectedSamples();
            }
        }