Example #1
0
        private UIElement CreateRadioButton(KeyValuePair<string, Func<Map>> sample)
        {
            var radioButton = new RadioButton
            {
                FontSize = 16,
                Content = sample.Key,
                Margin = new Thickness(4)
            };

            radioButton.Click += (s, a) =>
            {
                MapControl.Map.Layers.Clear();
                MapControl.Map = sample.Value();
                LayerList.Initialize(MapControl.Map.Layers);
                MapControl.Refresh();
            };
            return radioButton;
        }
Example #2
0
 private static void AddMenuItem(KeyValuePair<string, ModMenuItemClickedCallback> modMenuItem, MenuItem modsGroup)
 {
     var item = new MenuItem(modMenuItem.Key);
     item.Click += (sender, args) => modMenuItem.Value();
     modsGroup.Items.Add(item);
 }
        private IList<TestCaseData> BuildTestCasesForThens(IList<Context> parentContexts)
        {
            var testCases = new List<TestCaseData>();

            if (!thens.Any()) return testCases;

            var setupText = new StringBuilder();

            setupText.AppendLine(parentContexts.First().Description + ":"); // start with the spec method's name

            var first = true;
            foreach (var context in parentContexts.Skip(1).Where(c => c.IsNamedContext))
            {
                setupText.AppendLine(context.Conjunction(first) + context.Description);
                first = false;
            }

            setupText.AppendLine("when " + when.Key);

            const string thenText = "then ";

            foreach (var spec in thens)
            {
                var parentContextsCapture = new List<Context>(parentContexts);
                var whenCapture = new KeyValuePair<string, Func<Task>>(when.Key, when.Value);

                Func<Task> executeTest = async () =>
                {
                    BeforeIfNotAlreadyRun();

                    try
                    {
                        var exceptionThrownAndAsserted = false;

                        await InitializeContext(parentContextsCapture).ConfigureAwait(false);

                        try
                        {
                            thrownException = null;
                            await whenCapture.Value().ConfigureAwait(false);
                        }
                        catch (Exception ex)
                        {
                            thrownException = ex;
                        }

                        try
                        {
                            exceptionAsserted = false;
                            await spec.Value().ConfigureAwait(false);
                        }
                        catch (Exception)
                        {
                            if (thrownException == null || exceptionAsserted)
                                throw;
                        }

                        if (thrownException != null)
                        {
                            throw thrownException;
                        }

                        exceptionThrownAndAsserted = true;

                        if (!exceptionThrownAndAsserted)
                        {
                            await spec.Value().ConfigureAwait(false);
                        }
                    }
                    finally
                    {
                        After();
                    }
                };

                var description = setupText + thenText + spec.Key + Environment.NewLine;
                testCases.Add(new TestCaseData(executeTest).SetName(description));
            }

            return testCases;
        }
 BootstrapResult ExecuteEntrypoint(KeyValuePair<Type, Func<IDictionary<string, object>, int>> entryPoint, IEnumerable<Assembly> assemblies, IEnumerable<string> consumedArgs)
 {
     var info = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase)
     {
             { "openwrap.syspath", _systemRootPath },
             { "openwrap.cd", Environment.CurrentDirectory },
             { "openwrap.shell.commandline", GetCommandLine() },
             { "openwrap.shell.assemblies", assemblies.Select(x=>x.Location).ToList() },
             { "openwrap.shell.version", _shellVersion},
             { "openwrap.shell.args", consumedArgs.ToList() }
     };
     return (BootstrapResult)entryPoint.Value(info);
 }
 BootstrapResult ExecuteEntrypoint(string[] args, KeyValuePair<Type, Func<string[], int>> entryPoint)
 {
     return (BootstrapResult)entryPoint.Value(args);
 }
 private static void addMenuItem(KeyValuePair<string, ModMenuItemClickedCallback> mod_kvp, Game.GUI.Controls.MenuItem modsGroup)
 {
     var item = new Game.GUI.Controls.MenuItem(mod_kvp.Key);
     item.Click += new Game.GUI.Controls.EventHandler((sender, args) =>
     {
         mod_kvp.Value();
     });
     modsGroup.Items.Add(item);
 }