예제 #1
0
        protected override void OnObjectReceived(object o)
        {
            CommandLineArgumentsDefinition def = new CommandLineArgumentsDefinition(typeof(FilterAction));

            def.FindMatchingArgument("FilterTarget").RevivedValueOverride = o;
            Args.InvokeMain(def, CmdLineArgs.ToArray());
        }
예제 #2
0
        public static void Main()
        {
            try
            {
                EnableLogging();
                OpenWcfHost();
                CommandLineArgs = Environment.GetCommandLineArgs().OfType <string>().ToList();
                var cmdArgs = new CmdLineArgs(Environment.GetCommandLineArgs());
                //LogWriter.Info("CommandLine" + cmdArgs.ToString());

                if (CommandLineArgs.Contains(AppConstant.installCmd) || CommandLineArgs.Contains(AppConstant.installCmdDefault))
                {
                    LogWriter.Info("Contains install cmd");
                    CreateShortcut();
                    RunOnStartUp(true);
                    System.Windows.Application.Current.Shutdown();
                }
                if (CommandLineArgs.Contains("--afterinstall"))
                {
                    string url = BuildLaunchUrl();
                    Process.Start(url);
                }
                LogWriter.Info("Time to start App");
                App app = new App();
                app.InitializeComponent();
                app.Run();
            }
            catch (Exception ex)
            {
                LogWriter.Error("Error while starting an app " + ex.Message);
            }
        }
예제 #3
0
        public FormMain(CmdLineArgs cmdLineArgs)
        {
            InitializeComponent();

            Text = ProgramTitle;
            if (!cmdLineArgs.FindArg(CmdArgNoVersion))
            {
                FormMain formMain = this;
                formMain.Text += ProgramVersion;
            }

            SharedObjects.MainWin     = this;
            SharedObjects.ProgramName = ProgramName;

            comPortTreeForm                 = new ComPortTreeForm();
            comPortTreeForm.TopLevel        = false;
            comPortTreeForm.Parent          = plComPortTree;
            comPortTreeForm.Visible         = true;
            comPortTreeForm.Dock            = DockStyle.Fill;
            comPortTreeForm.ControlBox      = false;
            comPortTreeForm.ShowIcon        = false;
            comPortTreeForm.FormBorderStyle = FormBorderStyle.None;
            comPortTreeForm.StartPosition   = FormStartPosition.Manual;
            comPortTreeForm.Show();
            comPortTreeForm.GetActiveDeviceFormCallback = new GetActiveDeviceFormDelegate(GetActiveDeviceForm);
        }
예제 #4
0
        static void Main(string[] args)
        {
            CmdLineArgs cmdLineArgs = new CmdLineArgs(args);

            string srcPath = cmdLineArgs.GetFirstSwitchArgument(""); //direct after call

            if (srcPath == null)
            {
                Console.WriteLine("ERROR: No Input File (Tbs-Definition was given");
                DumpHelp();
                return;
            }

            Console.WriteLine($"Reading Tbs-Definition in File {srcPath}...");
            var srcCode = File.ReadAllText(srcPath);

            Console.WriteLine("Parsing Tbs-Definition...");
            var parseResult = new ParseResult(srcCode);

            Console.WriteLine("Analsing Tbs-Definition...");
            var analysisResult = new AnalysisResult(parseResult);

            Console.WriteLine(analysisResult.AnalysisLog.ToString());

            if (analysisResult.AnalysisLog.ContainsErrors)
            {
                Console.WriteLine("ERROR: Errors Occured during Tbs Analysis - aborting");
                return;
            }

            Console.WriteLine("Generating Output...");

            if (cmdLineArgs.HasSwitch("cpp"))
            {
                string nmespce = cmdLineArgs.GetFirstSwitchArgument("namespace", "TinybuffersGenerated");

                IOutputGenerator generator = new CppGenerator(nmespce);

                string outputPath = GetDefaultPath(srcPath, generator);
                outputPath = cmdLineArgs.GetFirstSwitchArgument("cpp", outputPath);

                GenerateAndSave(generator, outputPath, analysisResult);
            }

            if (cmdLineArgs.HasSwitch("cs"))
            {
                string nmespce  = cmdLineArgs.GetFirstSwitchArgument("namespace", "TinybuffersGenerated");
                bool   isPublic = cmdLineArgs.HasSwitch("public");

                IOutputGenerator generator = new CsGenerator(nmespce, isPublic);

                string outputPath = GetDefaultPath(srcPath, generator);
                outputPath = cmdLineArgs.GetFirstSwitchArgument("cs", outputPath);

                GenerateAndSave(generator, outputPath, analysisResult);
            }

            Console.WriteLine("DONE");
        }
예제 #5
0
        protected override void OnObjectReceived(object o)
        {
            CommandLineArgumentsDefinition def = new CommandLineArgumentsDefinition(typeof(FilterAction));
            var arg = def.FindMatchingArgument("FilterTarget");

            def.Metadata.Add(new ArgumentOverrideHook(arg, o));
            Args.InvokeMain(def, CmdLineArgs.ToArray());
        }
예제 #6
0
        public string GetQuotedCommandLineArgs()
        {
            if (CmdLineArgs == null)
            {
                return(null);
            }

            return(string.Join(" ", CmdLineArgs.Select(a => GetQuotedArg(a))));
        }
예제 #7
0
 public WmiPresenter(CmdLineArgs args)
 {
     Args = args;
     WmiClassList.Instance.IncludeClasses.Add("Win32_Desktop");
     WmiClassList.Instance.IncludeClasses.Add("Win32_DesktopMonitor");
     WmiClassList.Instance.IncludeClasses.Add("Win32_DiskDrive");
     WmiClassList.Instance.IncludeClasses.Add("Win32_BIOS");
     WmiClassList.Instance.IncludeClasses.Add("Win32_Processor");
     WmiClassList.Instance.IncludeClasses.Add("Win32_PhysicalMemory");
 }
예제 #8
0
 public MethodForm(WmiPresenter presenter)
 {
     if (presenter == null)
     {
         throw new ArgumentNullException("presenter");
     }
     m_Presenter = presenter;
     m_Args      = m_Presenter.Args;
     InitializeComponent();
     Icon = Resources.WMIViewer16;
 }
예제 #9
0
        public void Parse_BaselineDeploy()
        {
            string[]    args   = new[] { "deploy", "--destination", "001", "--db", "SqlServer", "db connection string", "--scripts", @"C:\Temp\scripts" };
            CmdLineArgs result = CmdLineArgs.Parse(args);

            Assert.IsNotNull(result, "result");
            Assert.AreEqual("deploy", result.Mode, "Mode");
            Assert.AreEqual("001", result.Destination, "Destination");
            Assert.AreEqual("SqlServer", result.DbType, "DbType");
            Assert.AreEqual("db connection string", result.DbConnectionString, "DbConnectionString");
            Assert.AreEqual(@"C:\Temp\scripts", result.ScriptLocation, "ScriptLocation");
        }
예제 #10
0
        public void Parse_ArgNamesNotCaseSensitiveDeploy()
        {
            string[]    args   = new[] { "DEploY", "--DestINAtion", "aBcDEf", "--Db", "sQLseRVEr", "db connection string", "--SCRipTS", @"C:\Temp\scripts" };
            CmdLineArgs result = CmdLineArgs.Parse(args);

            Assert.IsNotNull(result, "result");
            Assert.AreEqual("DEploY", result.Mode, "Mode");
            Assert.AreEqual("aBcDEf", result.Destination, "Destination");
            Assert.AreEqual("sQLseRVEr", result.DbType, "DbType");
            Assert.AreEqual("db connection string", result.DbConnectionString, "DbConnectionString");
            Assert.AreEqual(@"C:\Temp\scripts", result.ScriptLocation, "ScriptLocation");
        }
예제 #11
0
        public void Test1()
        {
            var tstArgs = new CmdLineArgs("testfile.c -o out.asm -opt1 -settings f1.set f2.set f3.set");

            Assert.AreEqual(true, tstArgs.HasSwitch("o"));
            Assert.AreEqual(false, tstArgs.HasSwitch("notPresent"));
            Assert.AreEqual("out.asm", tstArgs.GetFirstSwitchArgument("o"));
            Assert.AreEqual("default", tstArgs.GetFirstSwitchArgument("notPresent", "default"));
            Assert.AreEqual("default", tstArgs.GetFirstSwitchArgument("opt1", "default"));
            Assert.AreEqual("f1.set", tstArgs.GetFirstSwitchArgument("settings"));
            Assert.AreEqual(null, tstArgs.GetSwitchArguments("notPresent"));
            Assert.AreEqual(new string[] { "f1.set", "f2.set", "f3.set" }, tstArgs.GetSwitchArguments("settings"));
        }
예제 #12
0
 public EditPropertyForm(WmiPresenter presenter)
 {
     if (presenter == null)
     {
         throw new ArgumentNullException("presenter");
     }
     m_Presenter = presenter;
     m_Args      = presenter.Args;
     InitializeComponent();
     UpdateTitle();
     SetArgsToControls();
     Icon = Resources.WMIViewer16;
 }
예제 #13
0
        public string GetEscapedArguments()
        {
            if (CmdLineArgs == null)
            {
                return(null);
            }

            var result = string.Join(" ", CmdLineArgs.Select(a => EscapeArgument(a)));

            if (IsBatchScript)
            {
                result = ShellEscape(result);
            }

            return(result);
        }
예제 #14
0
        public MainForm(WmiPresenter presenter)
        {
            if (presenter == null)
            {
                throw new ArgumentNullException("presenter");
            }
            m_Presenter      = presenter;
            m_Presenter.View = this;
            m_Args           = m_Presenter.Args;
            InitializeComponent();
            // Enable double buffer for ListView
            var mi = typeof(Control).GetMethod("SetStyle", BindingFlags.Instance | BindingFlags.NonPublic);

            mi.Invoke(lvInstances, new object[] { ControlStyles.DoubleBuffer | ControlStyles.OptimizedDoubleBuffer, true });

            FocusedItemChanged += lvInstances_FocusedItemChanged;
            UpdateTitle();
            ShowStat(WmiClassList.Instance.ClassCount, WmiClassList.Instance.PropCount, WmiClassList.Instance.MethodCount);
            Icon = Resources.WMIViewer16;
        }
예제 #15
0
        static void Main(string[] args)
        {
            CmdLineArgs wmiArgs = null;

            try
            {
                wmiArgs = CmdLineArgs.ParseFromCmdLine(args);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, GetProgramTitle(), MessageBoxButtons.OK, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
            }
            using (var presenter = new WmiPresenter(wmiArgs))
                if (wmiArgs != null && presenter.ConnectToComputer())
                {
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);
                    switch (wmiArgs.StartCmd)
                    {
                    case CmdLineCommand.EditProperty:
                        using (var propForm = new EditPropertyForm(presenter))
                            propForm.ShowDialog();
                        break;

                    case CmdLineCommand.ExecuteMethod:
                        using (var methodForm = new MethodForm(presenter))
                        {
                            methodForm.PrepareForm();
                            methodForm.ShowDialog();
                        }
                        break;

                    default:
                        WmiClassList.Instance.EnumLocalMachineClasses();
                        Application.Run(new MainForm(presenter));
                        break;
                    }
                }
        }
예제 #16
0
        public static int Main()
        {
            var cmdArgs = new CmdLineArgs(Environment.GetCommandLineArgs());


            Trace.Listeners.Add(new TextWriterTraceListener(Path.Combine(Path.GetTempPath(), "XrInstaller.log")));
            Trace.AutoFlush = true;


            // note partner and campaign for further reporting
            //var cmdline = String.Format("Starting installer {0} with: {1}, Run as admin: {2}", CommunicationUtils.DataCollector.Version, String.Join(" ", Environment.GetCommandLineArgs()), IsAdministrator());


            if (!cmdArgs.CheckArg("uninstall"))
            {
                try
                {
                    var random = new Random((int)DateTime.Now.Ticks);
                    // no need to update installer for uninstall. It knows how to uninstall the current version
                    var tmpFolder = Path.Combine(Path.GetTempPath(), "wctmp_" + random.Next());
                }
                catch (System.Exception ex)
                {
                    var msg = "Internet connectivity problem.";
                    if (cmdArgs.CheckArg("silent"))
                    {
                        Console.WriteLine(msg);
                        return(-1);
                    }

                    ErrorMessage = msg;
                }
            }

            // run scenario detection to override install by update
            if (cmdArgs.CheckArg("silent") || cmdArgs.CheckArg("update"))
            {
                // run installation without gui
                if (cmdArgs.CheckArg("uninstall"))
                {
                    Controller.RunUninstall(() => false, Environment.GetCommandLineArgs());
                    MessageBox.Show("UnInstallation Complete");
                }
                else if (cmdArgs.CheckArg("update"))
                {
                    Controller.RunUpdate(() => false, Environment.GetCommandLineArgs());
                }
                else
                {
                    //InstallerProcesses();
                    Controller.RunInstallation(() => false, Environment.GetCommandLineArgs());
                    //MessageBox.Show("Installation Complete");
                }
            }
            else
            {
                var app = new App();
                app.InitializeComponent();
                app.Run();
            }

            return(0);
        }
예제 #17
0
 public void Parse_DoubleScripts()
 {
     string[] args = new[] { "deploy", "--destination", "001", "--db", "SqlServer", "db connection string", "--scripts", @"C:\Temp\scripts", "--scripts", @"C:\Temp\scripts2" };
     CmdLineArgs.Parse(args);
 }
예제 #18
0
 public void Parse_DbNotSpecified()
 {
     string[] args = new[] { "deploy", "--destination", "001", "--scripts", @"C:\Temp\scripts" };
     CmdLineArgs.Parse(args);
 }
예제 #19
0
 public void Parse_ScriptsNotSpecified()
 {
     string[] args = new[] { "deploy", "--destination", "001", "--db", "SqlServer", "db connection string" };
     CmdLineArgs.Parse(args);
 }
예제 #20
0
 public void Parse_MissingDbTypeArgument()
 {
     string[] args = new[] { "deploy", "--destination", "001", "--db", "db connection string", "--scripts", @"C:\Temp\scripts" };
     CmdLineArgs.Parse(args);
 }
예제 #21
0
파일: Program.cs 프로젝트: Kampbell/asn1scc
        static void exportCustomStg(CmdLineArgs.CmdLineArguments cmdArgs, String customStg, String cmdLingName, Action<string, string> backendInvocation)
        {
            var files = customStg.Split(':');
            if (files.Length != 2)
            {
                files = customStg.Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries);
                if (files.Length != 2)
                {
                    Console.Error.WriteLine("Invalid usage of {0} argument. Please use ':' to seperate the stg file with output file", cmdLingName);
                    Console.Error.WriteLine("E.g. -{0} mystg.stg:output.txt ", cmdLingName);
                    Console.Error.WriteLine("Under windows, you may user double :: to separate the stg file with output file");
                    Console.Error.WriteLine("E.g. -{0} c:\\mystg.stg::c:\\output.txt ", cmdLingName);
                    Environment.Exit(4);
                }
            }
            var stgFileName = files.First();
            var outFileName = files.Last();
            if (!File.Exists(stgFileName))
            {
                Console.Error.WriteLine("Custom stg file '{0}' does not exist", stgFileName);
                Environment.Exit(4);
            }

            backendInvocation(stgFileName, outFileName);
        }
예제 #22
0
파일: Program.cs 프로젝트: Kampbell/asn1scc
        public static ParameterizedAsn1Ast.EnumRenamePolicy getRenamePolicy(CmdLineArgs.CmdLineArguments cmdArgs, ParameterizedAsn1Ast.EnumRenamePolicy defaultValue)
        {
            var renamePolicyStr = cmdArgs.GetOptionalArgument("renamePolicy", "xxx");
            var renamePolicy = defaultValue;
            if (renamePolicyStr == "0")
                renamePolicy = ParameterizedAsn1Ast.EnumRenamePolicy.NoRenamePolicy;
            else if (renamePolicyStr == "1")
                renamePolicy = ParameterizedAsn1Ast.EnumRenamePolicy.SelectiveEnumerants;
            else if (renamePolicyStr == "2")
                renamePolicy = ParameterizedAsn1Ast.EnumRenamePolicy.AllEnumerants;
            else if (renamePolicyStr!="xxx")
            {
                Console.Error.WriteLine("Invalid value for argument 'renamePolicy'\nValid values are 0,1,2");
                Environment.Exit(Usage());
            }

            return renamePolicy;
        }
예제 #23
0
 public void Parse_MissingDbConnectionStringArgument()
 {
     string[] args = new[] { "deploy", "--destination", "001", "--db", "SqlServer", "--scripts", @"C:\Temp\scripts" };
     CmdLineArgs.Parse(args);
 }
예제 #24
0
 public void Parse_MissingScriptLocationArgument()
 {
     string[] args = new[] { "deploy", "--destination", "001", "--db", "SqlServer", "db connection string", "--scripts" };
     CmdLineArgs.Parse(args);
 }
예제 #25
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            var cmdArgs = new CmdLineArgs(Environment.GetCommandLineArgs());

            //Check if an instance is already running. If it is the case, warn the user and don't start the program.
            if ((System.Diagnostics.Process.GetProcessesByName(System.IO.Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetEntryAssembly().Location)).Length > 1) && !cmdArgs.CheckArg("uninstall"))
            {
                System.Threading.Thread.Sleep(TimeSpan.FromSeconds(5)); // retry in case of restart with update installer version
                if ((System.Diagnostics.Process.GetProcessesByName(System.IO.Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetEntryAssembly().Location)).Length > 1) && !cmdArgs.CheckArg("uninstall"))
                {
                    //We don't need a pop-up twice or in silent mode. Just close it then.
                    if (System.Diagnostics.Process.GetProcessesByName(System.IO.Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetEntryAssembly().Location)).Length > 2 || cmdArgs.CheckArg("silent"))
                    {
                        System.Environment.Exit(0);
                    }
                    else
                    {
                        string    originalFileName = string.Empty;
                        Process[] processes        = Process.GetProcessesByName(System.IO.Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetEntryAssembly().Location));

                        foreach (Process process in processes)
                        {
                            if (process.Modules[0].FileVersionInfo.OriginalFilename == System.IO.Path.GetFileName(System.Reflection.Assembly.GetEntryAssembly().Location))
                            {
                                //We don't need a pop-up twice or in silent mode. Just close it then.
                                MainWindow mainView = new MainWindow();
                                //var page = new MultipleInstanceError();
                                //mainView.Content = page;
                                mainView.Show();
                                break;
                            }
                        }
                    }
                }
            }
            else
            {
                if (String.IsNullOrEmpty(ErrorMessage))
                {
                    if (cmdArgs.CheckArg("uninstall"))
                    {
                        //UninstallMainWindow unMainWin = new UninstallMainWindow();
                        //unMainWin.Show();
                    }
                    else
                    {
                        MainWindow mainView = new MainWindow();
                        mainView.Show();
                    }
                }
                else
                {
                    if (!cmdArgs.CheckArg("uninstall"))
                    {
                        MainWindow mainView = new MainWindow();
                        //var page = new CustomErrorView(ErrorType.InternetError);
                        //mainView.Content = page;
                        mainView.Show();
                    }
                }
            }
        }
        public UpdatePrerequisiteStep(string[] args)
        {
            var cmd = new CmdLineArgs(args);

            PlatformRequired = !(cmd.CheckArg("internal") || cmd.CheckArg("prod"));
        }