Exemple #1
0
        private void LoadToolWindows()
        {
            RegistryUtil.ForEachPackage(this, "ToolWindows", (packageId, key) =>
            {
                foreach (string toolWindowId in key.GetSubKeyNames())
                {
                    using (var subKey = key.OpenSubKey(toolWindowId))
                    {
                        Log.InfoFormat("Loading tool window {0}", toolWindowId);

                        try
                        {
                            _registrations.Add(new ToolWindowRegistration(
                                                   packageId,
                                                   Guid.Parse(toolWindowId),
                                                   RegistryUtil.GetBool(subKey.GetValue("MultipleInstances")),
                                                   Enum <NiToolWindowOrientation> .Parse((string)subKey.GetValue("Orientation")),
                                                   Enum <NiDockStyle> .Parse((string)subKey.GetValue("Style")),
                                                   RegistryUtil.GetBool(subKey.GetValue("Transient"))
                                                   ));
                        }
                        catch (Exception ex)
                        {
                            Log.Error("Could not load tool window", ex);
                        }
                    }
                }
            });
        }
Exemple #2
0
        public NiCommandLine(IServiceProvider serviceProvider, string[] args)
            : base(serviceProvider)
        {
            _switches["RuntimeUpdate"] = false;

            RegistryUtil.ForEachPackage(this, "CommandLine", (packageId, key) =>
            {
                foreach (string name in key.GetSubKeyNames())
                {
                    using (var switchKey = key.OpenSubKey(name))
                    {
                        Log.InfoFormat("Loading switch '{0}'", switchKey);

                        try
                        {
                            _switches[name] = RegistryUtil.GetBool(switchKey.GetValue("ExpectArgument"));
                        }
                        catch (Exception ex)
                        {
                            Log.Warn("Could not load switch", ex);
                        }
                    }
                }
            });

            string failedArgument = null;

            if (args != null)
            {
                for (int i = 0; i < args.Length; i++)
                {
                    string arg = args[i];

                    if (arg.StartsWith("/"))
                    {
                        bool expectArgument;
                        if (!_switches.TryGetValue(arg.Substring(1), out expectArgument))
                        {
                            failedArgument = arg;
                            break;
                        }

                        string value = null;

                        if (expectArgument)
                        {
                            if (i >= args.Length - 1)
                            {
                                failedArgument = arg;
                                break;
                            }

                            value = args[++i];
                        }

                        if (!_arguments.ContainsKey(arg))
                        {
                            _arguments.Add(arg, value);
                        }
                    }
                    else
                    {
                        _remainingArguments.Add(arg);
                    }
                }
            }

            if (failedArgument != null)
            {
                MessageBox.Show(
                    String.Format(Labels.CannotProcessSwitch, failedArgument),
                    Labels.NetIde,
                    System.Windows.Forms.MessageBoxButtons.OK,
                    System.Windows.Forms.MessageBoxIcon.Error
                    );

                Environment.Exit(0);
            }
        }