/// <summary> /// Callback function when files are selected from the ShowOpenDialog function. /// </summary> /// <param name="files">File(s) selected</param> /// <returns>null</returns> async Task openFileCallback(ICallbackResult ar) { // See if we have any file(s) selected var fileNames = ar.CallbackState as object[]; if (fileNames == null || fileNames.Length == 0) { return; } // Grab the first file name specified var fileName = (string)fileNames[0]; // Open and read the file asynchronously. byte[] result; using (FileStream SourceStream = File.Open(fileName, FileMode.Open)) { result = new byte[SourceStream.Length]; await SourceStream.ReadAsync(result, 0, (int)SourceStream.Length); } // When the file has been read get a reference to the "editor" HtmlElement var editor = await document.GetElementById("editor"); // and set it's "value" property to the text that was read from the file await editor.SetProperty("value", System.Text.Encoding.ASCII.GetString(result)); }
public MoqCallbackResultWrapper( LambdaExpression expression, ICallbackResult callbackResult, IVerifiedMock testeroidsMock) { this.wrappedCallbackResult = callbackResult; this.Expression = expression; this.TesteroidsMock = testeroidsMock; }
async Task MenuItemClicked(ICallbackResult result) { try { var state = (object[])result.CallbackState; var menuItemSelected = (MenuItem)state[0]; await console.Log($"MenuItem: {await menuItemSelected.GetLabel()} was selected and the item is checked {await menuItemSelected.GetChecked()}"); } catch (Exception exc) { System.Console.WriteLine(exc); } }
async Task saveFileCallback(ICallbackResult ar) { var fileName = ar.CallbackState; if (fileName == null || string.IsNullOrEmpty((string)fileName)) { return; } // Get a reference to the "editor" HtmlElement var editor = await document.GetElementById("editor"); // and get it's "value" property to be written out ASCIIEncoding encoding = new ASCIIEncoding(); byte[] result = encoding.GetBytes(await editor.GetProperty <string>("value")); try { using (FileStream SourceStream = File.Open((string)fileName, FileMode.OpenOrCreate)) { SourceStream.Seek(0, SeekOrigin.End); await SourceStream.WriteAsync(result, 0, result.Length); var messageBoxOptions = new MessageBoxOptions() { MessageBoxType = MessageBoxType.Info, Title = "Text Editor", Message = "The file has been saved!!", Buttons = new string[] { "OK" } }; await dialog.ShowMessageBox(messageBoxOptions); }; } catch (Exception exc) { await dialog.ShowErrorBox("There was an error saving the file.", exc.Message); } }
protected override void SetupVerifiableWrapper(ICallbackResult wrappedReturn, ICallbackResult verifiableWrapperReturn) { mockVerifiableWrapper.Setup(m => m.WrapCallbackResultForVerification(wrappedReturn)).Returns(verifiableWrapperReturn); }
protected override void SetupWrappedCallback(Mock <ISetup <IToMock> > mockWrapped, Delegate del, ICallbackResult wrappedReturn) { mockWrapped.Setup(m => m.Callback(del)).Returns(wrappedReturn); }
public WillDownloadResult(ICallbackResult result) : this(result.CallbackState) { }
public PermissionRequestResult(ICallbackResult result) : this(result.CallbackState) { }
public CertificateVerifyProcResult(ICallbackResult result) : this(result.CallbackState) { }
public ICallbackResult WrapCallbackResultForVerification(ICallbackResult wrap) { return(new VerifiableCallbackResult(wrap, this)); }