/// <summary> /// It makes no sense to use any other "Autosampler" than our fake coffee machine here. /// </summary> /// <param name="yourDevice"></param> protected void CheckForCoffeeMachine(IDevice yourDevice) { mDevice = yourDevice as MockDevice; if (mDevice == null && yourDevice != null) { throw new ArgumentException(String.Format("Device type {0} is not usable for a {1}.", yourDevice.DisplayedTypeName, GetType().Name)); } if (yourDevice == null) { throw new ArgumentException("This kind of task needs an autosampler."); } }
public void RegisterRenderableObject() { if (!StackTraceExtensions.IsStartedFromNCrunch()) { return; } using (var device = new MockDevice(new MockWindow())) { device.Clear(); device.Present(); resolver.Register(device); resolver.RegisterSingleton <Drawing>(); resolver.Register(new Line2D(Vector2D.One, Vector2D.Zero, Color.Red)); } }
private static void github_issue_131() { MockDevice device = new MockDevice(); REngine.SetEnvironmentVariables(); var engine = REngine.GetInstance(dll: null, initialize: true, parameter: null, device: device); engine.Evaluate("rm(list=ls())"); device.Initialize(); Console.WriteLine("Before calling engine.evaluate with console write actions"); engine.Evaluate("print(NULL)"); engine.Evaluate("cat(123123123)"); Console.WriteLine("After calling engine.evaluate with console write actions"); var s = device.GetString(); Console.WriteLine("My device has the string '{0}'", s); }
public void InitializeDevice() { device = new MockDevice(); }
/// <summary> /// The method editor informs us about changed values. /// </summary> /// <param name="propName"></param> /// <param name="propValue"></param> /// <remarks> /// It is possible that the given propValue can not be converted to our /// property type - for example, if there is a calculation or a reference /// to a different task's property in the method editor field. /// </remarks> public void PropertyEdited(string propName, object propValue) { if (propName == nameof(Volume)) { // the uint32 converter can't convert from uint32 to uint32 but throws an exception. if (propValue is uint) { Volume = (uint)propValue; } else { var conv = TypeDescriptor.GetConverter(Volume, true); if (conv.IsValid(propValue)) { Volume = (uint)conv.ConvertFrom(null, System.Globalization.CultureInfo.InvariantCulture, propValue); } } } else if (propName == "Autosampler") { mDevInEditor = MockDevice.Instances.FirstOrDefault(someDev => someDev.Name == propValue?.ToString()); if (mComposition != null) { mComposition.DevInEditor = mDevInEditor; } } }