Esempio n. 1
0
        // Usage: Xamarin.Interactive.Console.exe {IdentifyAgentRequest args}
        // Passing no arguments is supported for debug scenarios.
        public static void RunAgentOnCurrentThread <TAgent> (
            Action <TAgent> integrateWithAgentHandler = null)
            where TAgent : Agent, new ()
        {
            var ctx = new SingleThreadSynchronizationContext();

            SynchronizationContext.SetSynchronizationContext(ctx);

            var agent = new TAgent();

            integrateWithAgentHandler?.Invoke(agent);

            try {
                var request = IdentifyAgentRequest.FromCommandLineArguments(Environment.GetCommandLineArgs());
                if (request != null && request.ProcessId >= 0)
                {
                    if (HostEnvironment.OS == HostOS.macOS)
                    {
                        new Thread(() => {
                            MonoTouch.Hosting.ProcessMonitor.WaitPid(request.ProcessId);
                            Environment.Exit(0);
                        })
                        {
                            IsBackground = true
                        }.Start();
                    }
                    else
                    {
                        var parentProcess = Process.GetProcessById(request.ProcessId);
                        parentProcess.EnableRaisingEvents = true;
                        parentProcess.Exited += (o, e) => Environment.Exit(0);
                    }
                }
            } catch (Exception e) {
                Log.Error("Main", e);
            }

            agent.Start(new AgentStartOptions {
                ClientSessionKind = ClientSessionKind.Workbook
            });

            DebuggingSupport.LaunchClientAppForDebugging(agent);

            ctx.RunOnCurrentThread();
        }
        public void CommandLineRoundTrip(int prependedArgumentCount)
        {
            var original = IdentifyAgentRequest.CreateWithBaseConnectUri(
                new Uri("http://catoverflow.com"));

            var arguments = new List <string> ();

            for (int i = 0; i < prependedArgumentCount; i++)
            {
                arguments.Add(Guid.NewGuid().ToString());
            }

            arguments.AddRange(original.ToCommandLineArguments());

            IdentifyAgentRequest
            .FromCommandLineArguments(arguments.ToArray())
            .ShouldEqual(original);
        }
Esempio n. 3
0
        // Usage: Xamarin.Interactive.Console.exe {IdentifyAgentRequest args}
        // Passing no arguments is supported for debug scenarios.
        public static void Main()
        {
            var ctx = new SingleThreadSynchronizationContext();

            SynchronizationContext.SetSynchronizationContext(ctx);

            var agent = new ConsoleAgent();

            MacIntegration.Integrate(agent);

            try {
                var request = IdentifyAgentRequest.FromCommandLineArguments(Environment.GetCommandLineArgs());
                if (request != null && request.ProcessId >= 0)
                {
                    if (Environment.OSVersion.Platform == PlatformID.Unix)
                    {
                        new Thread(() => {
                            MonoTouch.Hosting.ProcessMonitor.WaitPid(request.ProcessId);
                            Environment.Exit(0);
                        })
                        {
                            IsBackground = true
                        }.Start();
                    }
                    else
                    {
                        var parentProcess = Process.GetProcessById(request.ProcessId);
                        parentProcess.EnableRaisingEvents = true;
                        parentProcess.Exited += (o, e) => Environment.Exit(0);
                    }
                }
            } catch (Exception e) {
                Log.Error("Main", e);
            }

            agent.Start(new AgentStartOptions {
                ClientSessionKind = ClientSessionKind.Workbook
            });

            DebuggingSupport.LaunchClientAppForDebugging(agent);

            ctx.RunOnCurrentThread();
        }
Esempio n. 4
0
        void App_OnStartup(object sender, StartupEventArgs e)
        {
            var agent = new WpfAgent(() => new MainWindow());

            try {
                var request = IdentifyAgentRequest.FromCommandLineArguments(Environment.GetCommandLineArgs());
                if (request.ProcessId >= 0)
                {
                    var parentProcess = Process.GetProcessById(request.ProcessId);
                    parentProcess.EnableRaisingEvents = true;
                    parentProcess.Exited += (o, _) => Environment.Exit(0);
                }
            } catch (Exception ex) {
                Log.Error("App", ex);
            }

            agent.Start(new AgentStartOptions {
                ClientSessionKind = ClientSessionKind.Workbook
            });

            DebuggingSupport.LaunchClientAppForDebugging(agent);
        }
Esempio n. 5
0
 protected override IdentifyAgentRequest GetIdentifyAgentRequest()
 => IdentifyAgentRequest.FromCommandLineArguments(NSProcessInfo.ProcessInfo.Arguments);
Esempio n. 6
0
 protected override IdentifyAgentRequest GetIdentifyAgentRequest()
 => IdentifyAgentRequest.FromCommandLineArguments(Environment.GetCommandLineArgs());