public void Should_GetAllSettingsFromBaseProfile_When_DerivedProfileHasNoSettings() { var go = new GraphOptions(); var lbp = new RoundRobinPolicy(); var sep = new ConstantSpeculativeExecutionPolicy(1000, 1); var rp = new LoggingRetryPolicy(new DefaultRetryPolicy()); var baseProfileBuilder = new ExecutionProfileBuilder(); baseProfileBuilder .WithLoadBalancingPolicy(lbp) .WithSpeculativeExecutionPolicy(sep) .WithSerialConsistencyLevel(ConsistencyLevel.LocalSerial) .WithConsistencyLevel(ConsistencyLevel.Quorum) .WithReadTimeoutMillis(3000) .WithGraphOptions(go) .WithRetryPolicy(rp); var baseProfile = baseProfileBuilder.Build(); var profile = new ExecutionProfile(baseProfile, new ExecutionProfileBuilder().Build()); Assert.AreSame(lbp, profile.LoadBalancingPolicy); Assert.AreSame(sep, profile.SpeculativeExecutionPolicy); Assert.AreSame(rp, profile.RetryPolicy); Assert.AreEqual(3000, profile.ReadTimeoutMillis); Assert.AreEqual(ConsistencyLevel.LocalSerial, profile.SerialConsistencyLevel); Assert.AreEqual(ConsistencyLevel.Quorum, profile.ConsistencyLevel); Assert.AreEqual(go, profile.GraphOptions); }
private ExecutionProfileApiModel ToDetailApiModel(ExecutionProfile execProfile) => new ExecutionProfileApiModel { ClientConfiguration = execProfile.ClientConfiguration, Description = execProfile.ProfileDescription, ExecutionMode = execProfile.ExecutionMode.ToString(), SupportedPriorities = execProfile.SupportedPriorities.ToString().Split(',').Select(sp => sp.Trim()).ToList() };
protected override void OnForked(ForkData data) { ExecutionProfile executionProfile = _defaultExecutionProfile; executionProfile.CurrentWorkingDirectory = data.CurrentWorkingDirectory; executionProfile.EnvironmentVariables = data.Environment; CreateSession(executionProfile); }
public void IsDefaultProfile_ProfileWithoutDefaultName_ShouldBeFalse() { var notDefaultProfile = new ExecutionProfile { ProfileName = "Not Default Profile" }; var isDefaultProfile = notDefaultProfile.IsDefaultProfile(); isDefaultProfile.Should().BeFalse(); }
public void IsDefaultProfile_ProfileWithDefaultName_ShouldBeTrue() { var defaultProfile = new ExecutionProfile { ProfileName = ExecutionProfiles.Default }; var isDefaultProfile = defaultProfile.IsDefaultProfile(); isDefaultProfile.Should().BeTrue(); }
public TerminalSession(TerminalBuffer buffer, ExecutionProfile executionProfile) : this(buffer) { _pty = new WinPty(executionProfile, buffer.Size); _ptyWriter = new StreamWriter(_pty.StandardInput, Encoding.UTF8) { AutoFlush = true }; _ptyStdOut = _pty.StandardOutput; }
/// <summary> /// Checks to see whether or not an execution profile is the default one. /// </summary> /// <param name="execProfile">The execution profile to check</param> /// <returns></returns> public static bool IsDefaultProfile(this ExecutionProfile execProfile) { if (execProfile == null) { throw new ArgumentNullException(nameof(execProfile)); } return(execProfile.ProfileName == ExecutionProfiles.Default); }
private void CreateSession(ExecutionProfile executionProfile) { var session = _sessionMgr.CreateSession(_terminalSize, executionProfile); // session.TitleChanged += OnSessionTitleChanged; session.Finished += OnSessionFinished; ChangeSession(session); }
public static Core.Models.ExecutionProfile ToCoreModel(this ExecutionProfile cosmosModel, string profileName) => new Core.Models.ExecutionProfile { BaseExecutionCost = cosmosModel.BaseExecutionCost, ClientConfiguration = cosmosModel.ClientConfiguration, ExecutionModelName = cosmosModel.ExecutionModelName, ExtensionSettings = cosmosModel.ExtensionSettings, IsActive = cosmosModel.IsActive, ProfileDescription = cosmosModel.ProfileDescription, ObjectProviderName = cosmosModel.ObjectProviderName, ProfileName = profileName, SupportedPriorities = cosmosModel.SupportedPriorities, ExecutionMode = cosmosModel.ExecutionMode, DirectExecutionTokenDuration = cosmosModel.DirectExecutionTokenDuration };
public static ExecutionProfileApiModel ToApiModel(this ExecutionProfile coreModel, string extensionId, string exVersionId) => new ExecutionProfileApiModel { ClientConfiguration = coreModel.ClientConfiguration?.ToObject <Dictionary <string, string> >(), Description = coreModel.ProfileDescription, ExecutionMode = coreModel.ExecutionMode.ToString(), ExecutionModelName = coreModel.ExecutionModelName, ExtensionId = extensionId, ExtensionSettings = coreModel.ExtensionSettings?.ToObject <Dictionary <string, string> >(), ExtensionVersionId = exVersionId, Name = coreModel.ProfileName, ObjectProviderName = coreModel.ObjectProviderName, IsActive = coreModel.IsActive, SupportedPriorities = coreModel.SupportedPriorities.ToString().Split(',').Select(p => p.Trim()).ToList() };
public void Should_GetNoSettingFromBaseProfile_When_DerivedProfileHasAllSettings() { var go = new GraphOptions().SetName("ee"); var goProfile = new GraphOptions().SetName("tt"); var lbp = new RoundRobinPolicy(); var sep = new ConstantSpeculativeExecutionPolicy(1000, 1); var rp = new LoggingRetryPolicy(new DefaultRetryPolicy()); var sepProfile = new ConstantSpeculativeExecutionPolicy(200, 50); var lbpProfile = new TokenAwarePolicy(new DCAwareRoundRobinPolicy()); var rpProfile = new LoggingRetryPolicy(new IdempotenceAwareRetryPolicy(new DefaultRetryPolicy())); var baseProfileBuilder = new ExecutionProfileBuilder(); baseProfileBuilder .WithLoadBalancingPolicy(lbp) .WithSpeculativeExecutionPolicy(sep) .WithSerialConsistencyLevel(ConsistencyLevel.LocalSerial) .WithConsistencyLevel(ConsistencyLevel.Quorum) .WithReadTimeoutMillis(3000) .WithGraphOptions(go) .WithRetryPolicy(rp); var baseProfile = baseProfileBuilder.Build(); var derivedProfileBuilder = new ExecutionProfileBuilder(); derivedProfileBuilder .WithLoadBalancingPolicy(lbpProfile) .WithSpeculativeExecutionPolicy(sepProfile) .WithSerialConsistencyLevel(ConsistencyLevel.Serial) .WithConsistencyLevel(ConsistencyLevel.LocalQuorum) .WithReadTimeoutMillis(5000) .WithGraphOptions(goProfile) .WithRetryPolicy(rpProfile); var derivedProfile = derivedProfileBuilder.Build(); var profile = new ExecutionProfile(baseProfile, derivedProfile); Assert.AreSame(lbpProfile, profile.LoadBalancingPolicy); Assert.AreSame(sepProfile, profile.SpeculativeExecutionPolicy); Assert.AreSame(rpProfile, profile.RetryPolicy); Assert.AreEqual(5000, profile.ReadTimeoutMillis); Assert.AreEqual(ConsistencyLevel.Serial, profile.SerialConsistencyLevel); Assert.AreEqual(ConsistencyLevel.LocalQuorum, profile.ConsistencyLevel); Assert.AreSame(goProfile, profile.GraphOptions); }
public MainWindow() { InitializeComponent(); var size = new TerminalSize(80, 24); var profile = ExecutionProfile.CreateDefaultShell().ExpandVariables(); // var profile = new ExecutionProfile() // { // Arguments = new[] {"-Sy"}, Command = @"c:\SN\tools\msys\usr\bin\pacman.exe", // CurrentWorkingDirectory = @"c:\SN\tools\msys\usr\bin" // }; var b = new TerminalBuffer(size); terminalControl.AutoSizeTerminal = true; // terminalControl.Session = new TerminalSession(b, profile); // terminalControl.Session = new TerminalSession(size, new ExecutionProfile() // { // Arguments = new []{ "-h" }, Command = @"c:\SN\tools\msys\usr\bin\pacman.exe", CurrentWorkingDirectory = @"c:\SN\tools\msys\usr\bin" // }); // var client = new TcpClient(); // client.Connect(IPAddress.Parse("192.168.1.15"), 5001 ); // var stream = client.GetStream(); // terminalControl.Session = new TerminalSession(size, stream, stream); // terminalControl.Session.ImplicitCrForLf = true; // terminalControl.Session.Connect(); int x = 5; void OnSessionOnFinished(object sender, EventArgs args) { if (terminalControl.Session != null) { terminalControl.Session.Finished -= OnSessionOnFinished; terminalControl.Session.Dispose(); } if (x-- > 0) { CreatePermaSession(); } } void CreatePermaSession() { terminalControl.Session = new TerminalSession(b, profile); terminalControl.Session.Finished += OnSessionOnFinished; terminalControl.Session.Connect(); } CreatePermaSession(); bool allowSlider = true; terminalControl.Buffer.ViewportChanged += (sender, args) => { Dispatcher.Invoke(() => { var buffer = terminalControl.Buffer; if (allowSlider) { allowSlider = false; Slider.Minimum = -terminalControl.Buffer.CursorY; Slider.Maximum = buffer.HistoryLength; var value = -buffer.WindowTop; if (value < Slider.Minimum) { value = (int)Slider.Minimum; } if (value > Slider.Maximum) { value = (int)Slider.Maximum; } Slider.Value = value; allowSlider = true; } Debug.Text = buffer.WindowTop.ToString(); Debug1.Text = Slider.Minimum.ToString(); Debug2.Text = Slider.Maximum.ToString(); }); }; Button1.Click += (sender, args) => { terminalControl.Scroll(1); }; Button2.Click += (sender, args) => { terminalControl.Scroll(-1); }; Slider.ValueChanged += (sender, args) => { if (allowSlider) { allowSlider = false; terminalControl.ScrollTo(-(int)args.NewValue); allowSlider = true; } }; var t = new Timer(100); t.Start(); t.Elapsed += (sender, args) => { Dispatcher.Invoke(() => { // Slider.Maximum = terminalControl.Session.Buffer.Size.Rows + terminalControl.Buffer.HistoryLength; // var value = terminalControl.Buffer.HistoryLength + terminalControl.Buffer.WindowTop; // if (value < 0) value = 0; // if (value > Slider.Maximum) value = (int) Slider.Maximum; // Slider.Value = value; // Debug1.Text = Slider.Maximum.ToString(); // Debug2.Text = terminalControl.Buffer.WindowTop.ToString(); }); }; }