static void Main(string[] args)
        {
            string instanceName = string.Empty;

            Imi.Framework.Shared.CommandLineParser parser = new Imi.Framework.Shared.CommandLineParser(args);

            instanceName = parser.GetParameterValue("Instance");

            if (string.IsNullOrEmpty(instanceName))
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                SelectInstance instansSelector = new SelectInstance();
                Application.Run(instansSelector);

                if (!string.IsNullOrEmpty(instansSelector.SelectedInstance))
                {
                    instanceName = instansSelector.SelectedInstance;
                }
            }

            if (!string.IsNullOrEmpty(instanceName))
            {
                try
                {
                    Cdc.MetaManager.GUI.MetaManagerInstance instance = InstanceFactory.CreateInstance <Cdc.MetaManager.GUI.MetaManagerInstance>("Cdc.MetaManager.GUI.MetaManagerGUI", "Cdc.MetaManager.GUI.MetaManagerInstance", instanceName);
                    instance.Run();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(string.Format("Failed to start instance \"{0}\":\n\n{1}", instanceName, ex.ToString()), "Error");
                }
            }
        }
        static int Main(string[] args)
        {
            if (args.Length > 0)
            {
                try
                {
                    Console.Clear();
                }
                catch
                {
                }

                Imi.Framework.Shared.CommandLineParser parser = new Imi.Framework.Shared.CommandLineParser(args);

                string action = parser.GetParameterValue(CommandLineParameters.ACTION);

                if (!string.IsNullOrEmpty(action))
                {
                    ActionImplemetation actionImplementation = new ActionImplemetation();
                    actionImplementation.StatusChanged += new ActionImplemetation.StatusChangedDelegate(actionImplementation_StatusChanged);
                    try
                    {
                        switch (action)
                        {
                        case ActionParameters.IMPORT:
                            string kitfile  = parser.GetParameterValue(CommandLineParameters.KITFILE);
                            string instance = parser.GetParameterValue(CommandLineParameters.INSTANCE);
                            if (!string.IsNullOrEmpty(kitfile) && !string.IsNullOrEmpty(instance))
                            {
                                actionImplementation.Import(kitfile, instance);
                            }
                            break;
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                        return(1);
                    }
                }
            }

            return(0);
        }
        static int Main(string[] args)
        {
            if (args.Length > 0)
            {
                try
                {
                    Console.Clear();
                }
                catch
                {
                }

                string instanceName = string.Empty;


                Imi.Framework.Shared.CommandLineParser parser = new Imi.Framework.Shared.CommandLineParser(args);

                instanceName = parser.GetParameterValue(CommandLineParameters.INSTANCE);

                List <string> frontendParameters = new List <string>();
                List <string> backendParameters  = new List <string>();

                frontendParameters = parser.GetNamedParameterValues(CommandLineParameters.FRONTEND);
                backendParameters  = parser.GetNamedParameterValues(CommandLineParameters.BACKEND);

                List <string> frontendApplications = new List <string>();
                List <string> backendApplications  = new List <string>();

                if (frontendParameters != null)
                {
                    foreach (string parameter in frontendParameters)
                    {
                        foreach (string splitParam in parameter.Split(','))
                        {
                            if (!frontendApplications.Contains(splitParam) && !string.IsNullOrEmpty(splitParam))
                            {
                                frontendApplications.Add(splitParam);
                            }
                        }
                    }
                }

                if (backendParameters != null)
                {
                    foreach (string parameter in backendParameters)
                    {
                        foreach (string splitParam in parameter.Split(','))
                        {
                            if (!backendApplications.Contains(splitParam) && !string.IsNullOrEmpty(splitParam))
                            {
                                backendApplications.Add(splitParam);
                            }
                        }
                    }
                }

                string action = parser.GetParameterValue(CommandLineParameters.ACTION);

                Dictionary <string, string> options = new Dictionary <string, string>();

                foreach (string optionParameter in ConsoleInstance.CommandLineOptionParameters.GetAllOptionParameters())
                {
                    if (!string.IsNullOrEmpty(parser.GetParameterValue(optionParameter)))
                    {
                        options.Add(optionParameter, parser.GetParameterValue(optionParameter));
                    }
                }

                if (!string.IsNullOrEmpty(instanceName) && !string.IsNullOrEmpty(action))
                {
                    ConsoleInstance instance = InstanceFactory.CreateInstance <ConsoleInstance>("MetaManager.CLI", "Cdc.MetaManager.CLI.ConsoleInstance", instanceName);

                    return(instance.Run(action, frontendApplications, backendApplications, options));
                }
                else
                {
                    Console.WriteLine("No instance or action specified");

                    return(1);
                }
            }

            return(0);
        }