/// <summary> /// This is a javascript application. /// </summary> /// <param name="page">HTML document rendered by the web server which can now be enhanced.</param> public Application(IApp page) { // Native.window.history.pushState( // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2014/201405/20140517 // and the problem was. 'function' should not be used with dynamic!!! page.State2.onclick += e => { e.preventDefault(); //Native.window.history.pushState( HistoryExtensions.pushState( Native.window.history, new { foo = "foo" }, scope => { Console.WriteLine("enter State2"); Native.css.style.backgroundColor = "yellow"; scope.TaskCompletionSource.Task.ContinueWith( delegate { Console.WriteLine("exit State2"); Native.css.style.backgroundColor = "cyan"; } ); } ); }; page.State1.Historic( async scope => { Native.css.style.backgroundColor = "yellow"; await scope; Native.css.style.backgroundColor = "cyan"; } ); }
/// <summary> /// Initializes a new instance of the <see cref="Context"/> class with specified options. /// </summary> /// <param name="options">The options.</param> public Context(DbContextOptions <Context> options) : base(options) { this.CreationTime = HistoryExtensions.GetUniqueDateTime(); }
public int Execute(string argString, IDictionary <string, string> envp, TextReader inReader, TextWriter outWriter, TextWriter errorWriter) { Logger.Current.OutWriter = errorWriter; FileSystem.SetConsoleInput(inReader); FileSystem.SetConsoleOutput(outWriter); FileSystem.SetConsoleError(errorWriter); var args = CommandLine.PreprocessSingleQuotes(argString); int status = 1; GlobalScope.HandleDebugOptions(args); // initialize_memory_tracing - not implemented Logger.Info(LedgerStarting); // ::textdomain("ledger"); - not implemented GlobalScope globalScope = null; try { // Create the session object, which maintains nearly all state relating to // this invocation of Ledger; and register all known journal parsers. globalScope = new GlobalScope(envp); globalScope.Session.FlushOnNextDataFile = true; // Look for options and a command verb in the command-line arguments BindScope boundScope = new BindScope(globalScope, globalScope.Report); args = globalScope.ReadCommandArguments(boundScope, args); if (globalScope.ScriptHandler.Handled) { // Ledger is being invoked as a script command interpreter globalScope.Session.ReadJournalFiles(); status = 0; using (StreamReader sr = FileSystem.GetStreamReader(globalScope.ScriptHandler.Str())) { while (status == 0 && !sr.EndOfStream) { string line = sr.ReadLine().Trim(); if (!line.StartsWith("#")) { status = globalScope.ExecuteCommandWrapper(StringExtensions.SplitArguments(line), true); } } } } else if (args.Any()) { // User has invoke a verb at the interactive command-line status = globalScope.ExecuteCommandWrapper(args, false); } else { // Commence the REPL by displaying the current Ledger version FileSystem.ConsoleOutput.WriteLine(globalScope.ShowVersionInfo()); globalScope.Session.ReadJournalFiles(); bool exitLoop = false; // rl_readline_name - TODO string p; while ((p = FileSystem.ReadLine(globalScope.PromptString())) != null) { string expansion = null; int result = HistoryExtensions.HistoryExpand(p.Trim(), ref expansion); if (result < 0 || result == 2) { throw new LogicError(String.Format(LogicError.ErrorMessageFailedToExpandHistoryReference, p)); } else if (expansion != null) { HistoryExtensions.AddHistory(expansion); } // CheckForSignal(); - TODO (most likely, not required) if (!String.IsNullOrWhiteSpace(p) && p != "#") { if (String.Compare(p, "quit", true) == 0) { exitLoop = true; } else { globalScope.ExecuteCommandWrapper(StringExtensions.SplitArguments(p), true); } } if (exitLoop) { break; } } status = 0; // report success } } catch (CountError errors) { // used for a "quick" exit, and is used only if help text (such as // --help) was displayed status = errors.Count; } catch (Exception err) { if (globalScope != null) { globalScope.ReportError(err); } else { FileSystem.ConsoleError.WriteLine(String.Format(ExceptionDuringInitialization, err.Message)); } } if (globalScope != null) { globalScope.QuickClose(); globalScope.Dispose(); // {DM] It is the most appropriate place to call Dispose for the global scope. } Logger.Info(LedgerEnded); // let global_scope leak! // Return the final status to the operating system, either 1 for error or 0 // for a successful completion. return(status); }