private void OnWindowTextChanged(object sender, TextUpdatedEventArgs e) { SynchronizationContext syncContext = SynchronizationContext.Current; Task.Run(async() => { mutex.WaitOne(); if (lastContext != null && waitTask.IsCompleted == false) { if (waitTask.IsCompleted == false) { lastContext.InternalCancellationProvider.Cancel(); waitTask.Wait(); } lastContext.Dispose(); } Command command = new Command(e.Value); IInternalContext context = new QuickContext(command); AppDelegate app = appBuilder.Build(); await app(context); lastContext = context; syncContext.Send(s => waitTask = lastContext.WaitResults(actions).ContinueWith(tsk => { if (tsk.Status == TaskStatus.RanToCompletion) { syncContext.Send(st => window.OnActionUpdateCompleted(), null); } }), null); mutex.Set(); }); }
public void works_with_httpcontext() { var req = new HttpRequest("", "http://server/app/start/end.wiki.quick?param", "x=1&y=2"); var ctx = new HttpContext(req,new HttpResponse(null)); var context = new QuickContext(ctx); Assert.AreEqual("start.end",context.Command); Assert.AreEqual("wiki", context.Type); Assert.AreEqual("1",context.Parameters["x"]); Assert.AreEqual("2", context.Parameters["y"]); }
public QuickMainWindowHandler(object comObject, QuickModel model, QuickContext context, IntPtr hostPtr) { m_comObject = comObject; m_model = model; m_hostPtr = hostPtr; m_context = context; m_utilities = new Utilities(comObject); m_defaultIcon = null; m_bitmapSourceCache = null; m_isGlobalModel = true; m_locked = false; }
public static void Init(QuickContext quickContext) { if (!!!quickContext.HelloModels.Any()) { for (var i = 0; i < 100; i++) { quickContext.HelloModels.Add(new Model.HelloModel { Text = $"Hello World {(i + 1)}" }); quickContext.SaveChanges(); } } }
private async Task CreatingAContext() { _contextCommand = FightingFantasyContext.FightingFantasyContextCommand; var quickContextCommand = new QuickContext { Context = _contextCommand, CharacterTypes = _characterTypes, ItemTypes = _itemTypes }; var response = await _mediator.Send(quickContextCommand); response.Should().NotBeNull(); response.Result.Should().NotBeEmpty(); _contextId = response.Result; }
public QuickMainWindowHandler(object comObject, QuickModel model, QuickContext context, IntPtr hostPtr, bool isGlobalModel, Process currentProcess) : this(comObject, model, context, hostPtr) { m_isGlobalModel = isGlobalModel; if (!isGlobalModel) { try { var icon = Icon.ExtractAssociatedIcon(currentProcess.MainModule.FileName); //获得主线程图标 if (icon != null) { SetDefaultIcon(icon); } } catch { } } }
public Repository(IQuickContext context) { _context = context as QuickContext; _dbSet = _context.Set <T>(); _connStr = _context.Database.GetDbConnection().ConnectionString; }