public override void ViewDidLoad() { base.ViewDidLoad(); liveInspectionRadioButton.State = NSCellStateValue.On; connectButton.KeyEquivalent = "\r"; locationTextField.Changed += (sender, e) => { if (ClientSessionUri.TryParse(locationTextField?.StringValue, out clientSessionUri)) { clientSessionUriTextField.StringValue = clientSessionUri.ToString(); } else { clientSessionUriTextField.StringValue = "Invalid Location"; } ValidateUserInterface(); }; ValidateUserInterface(); locationTextField.BecomeFirstResponder(); }
static async Task <int> MainAsync(string [] args) { if (args.Length == 0 || args [0] == null) { System.Console.Error.WriteLine("usage: WORKBOOK_PATH"); return(1); } var path = new FilePath(args [0]); Uri.TryCreate("file://" + path.FullPath, UriKind.Absolute, out var fileUri); if (!ClientSessionUri.TryParse(fileUri.AbsoluteUri, out var uri)) { System.Console.Error.WriteLine("Invalid URI"); return(1); } new ConsoleClientApp().Initialize( logProvider: new LogProvider(LogLevel.Info, null)); var session = new ClientSession(uri); session.InitializeViewControllers(new ConsoleClientSessionViewControllers()); await session.InitializeAsync(new ConsoleWorkbookPageHost()); await session.WorkbookPageViewModel.EvaluateAllAsync(); return(0); }
public void TryParse( string uriString, bool expectedResult, string host, int port, ClientSessionKind clientSessionKind) { ClientSessionUri uri; ClientSessionUri.TryParse(uriString, out uri).ShouldEqual(expectedResult); if (!expectedResult) { return; } uri.Host.ShouldEqual(host); uri.Port.ShouldEqual((ushort)port); uri.SessionKind.ShouldEqual(clientSessionKind); Assert.DoesNotThrow(() => uri.ToString()); }
static async Task <int> MainAsync(string [] args) { ClientSessionUri sessionUri = null; TextWriter logWriter = null; var showHelp = false; var options = new OptionSet { { "usage: xic [OPTIONS]+ [URI]" }, { "" }, { "Options:" }, { "" }, { "l|log=", "Write debugging log to file", v => logWriter = new StreamWriter(v) }, { "h|help", "Show this help", v => showHelp = true } }; try { args = options.Parse(args).ToArray(); } catch (Exception e) { Error.WriteLine($"Invalid option: {e.Message}"); showHelp = true; } if (showHelp) { options.WriteOptionDescriptions(Out); return(1); } if (args.Length > 0) { if (!ClientSessionUri.TryParse(args [0], out sessionUri)) { Error.WriteLine($"Invalid URI: {args [0]}"); return(1); } } // set up the very basic global services/environment var clientApp = new ConsoleClientApp(); clientApp.Initialize( logProvider: new LogProvider(LogLevel.Info, logWriter)); // Now create and get ready to deal with the session; a more complete // client should handle more than just OnNext from the observer. var session = new InteractiveSession(agentUri: sessionUri); session.Events.Subscribe(new Observer <InteractiveSessionEvent> (OnSessionEvent)); if (sessionUri?.WorkbookPath != null) { await WorkbookPlayerMain(session, sessionUri); } else { await ReplPlayerMain(session); } // Nevermind this... it'll get fixed! await Task.Delay(Timeout.Infinite); return(0); }
public int Run() { var workbooksApp = Path.Combine( Environment.CurrentDirectory, InteractiveInstallation.Default.LocateClientApplication( ClientSessionKind.Workbook)); var launchUris = new List <ClientSessionUri> (); foreach (var uriString in ClientLaunchUris) { ClientSessionUri uri = null; if (File.Exists(uriString) || Directory.Exists(uriString)) { try { var fileUri = new Uri( Path.Combine(Environment.CurrentDirectory, uriString)); uri = new ClientSessionUri(fileUri); } catch { } } if (uri == null && !ClientSessionUri.TryParse(uriString, out uri)) { AgentType agentType; if (String.Equals(uriString, "mac", StringComparison.OrdinalIgnoreCase)) { agentType = AgentType.MacNet45; } else if (!Enum.TryParse(uriString, true, out agentType)) { throw new Exception($"Invalid URI or platform '{uriString}'"); } uri = new ClientSessionUri(agentType, ClientSessionKind.Workbook); } launchUris.Add(uri); } if (launchUris.Count == 0) { launchUris.Add(new ClientSessionUri(AgentType.Console, ClientSessionKind.Workbook)); } var workingDirectory = Environment.CurrentDirectory; var arguments = new List <string> (); foreach (var launchUri in launchUris) { var uri = launchUri; if (uri.WorkbookPath == null) { uri = uri.WithWorkingDirectory(workingDirectory); } arguments.Add($"\"{uri}\""); } if (InteractiveInstallation.Default.IsMac) { arguments.Insert(0, $"\"{workbooksApp}\""); arguments.Insert(0, "-a"); Exec("open", arguments); } else { Exec(workbooksApp, arguments); } return(0); }
public int Run() { var isMac = Environment.OSVersion.Platform == PlatformID.Unix; string workbooksApp; var driverLocation = Assembly.GetExecutingAssembly().Location; if (isMac) { workbooksApp = new FilePath(Path.GetDirectoryName(driverLocation)).Combine( "..", "..").FullPath; } else { workbooksApp = Assembly.GetExecutingAssembly().Location; } var launchUris = new List <ClientSessionUri> (); foreach (var uriString in ClientLaunchUris) { ClientSessionUri uri = null; if (File.Exists(uriString) || Directory.Exists(uriString)) { try { var fileUri = new Uri( Path.Combine(Environment.CurrentDirectory, uriString)); uri = new ClientSessionUri(fileUri); } catch { } } if (uri == null && !ClientSessionUri.TryParse(uriString, out uri)) { AgentType agentType; if (String.Equals(uriString, "mac", StringComparison.OrdinalIgnoreCase)) { agentType = AgentType.MacNet45; } else if (!Enum.TryParse(uriString, true, out agentType)) { throw new Exception($"Invalid URI or platform '{uriString}'"); } uri = new ClientSessionUri(agentType, ClientSessionKind.Workbook); } launchUris.Add(uri); } if (launchUris.Count == 0) { launchUris.Add(new ClientSessionUri(AgentType.Console, ClientSessionKind.Workbook)); } var workingDirectory = Environment.CurrentDirectory; var arguments = new List <string> (); foreach (var launchUri in launchUris) { var uri = launchUri; if (uri.WorkbookPath == null) { uri = uri.WithWorkingDirectory(workingDirectory); } arguments.Add($"\"{uri}\""); } if (isMac) { arguments.Insert(0, $"\"{workbooksApp}\""); arguments.Insert(0, "-a"); Exec("open", arguments); } else { Exec(workbooksApp, arguments); } return(0); }