internal async Task <T> CreateAndStartAsyncInternal <T>(Type type, object arg = null, IControllerFactory factory = null, CancellationToken token = default, IViewContext viewContext = null) where T : ControllerBase { _cancelToken.ThrowIfCancellationRequested(); factory = factory ?? ControllerFactory; var controller = factory.Create <T>(type); controller.WithViewContext(viewContext ?? ViewContext); controller.Initialize(arg, token); AddChild(controller); try { await controller.StartAsync(); } catch { await StopAndRemoveController(controller); throw; } return(controller); }
Controller INavigationResult.GetController(IControllerFactory controllerFactory, Stack <Controller> controllerHistory) { var controller = controllerFactory.Create <TController>(); controllerHistory.Push(_currentController); return(controller); }
private void NewRequested() { using (var worldVariableController = _controllerFactory.Create <IWorldVariableController>()) { WorldVariableViewModel viewModel = null; while (true) { viewModel = worldVariableController.ShowNewView(View, viewModel, View.CategoryFilter); if (viewModel == null) { return; } if (!IsVariableNameUnique(viewModel.Name)) { continue; } View.AddVariable(viewModel); return; } } }
public object Create(string controllerPrefix) { var controllerTypes = _registeredControllerTypes .Where(ct => ct.Name.Replace("Controller", string.Empty) == controllerPrefix) .ToArray(); if (controllerTypes.Count() > 1) { throw new InvalidOperationException(string.Format("Ambiguous controller name {0}", controllerPrefix)); } var controllerType = controllerTypes.Single(); Log.Information("Creating controller {controllerType}", controllerType); var instance = _controllerFactory.Create(controllerType); return(instance); }
Controller INavigationResult.GetController(IControllerFactory controllerFactory, Stack <Controller> controllerHistory) { return(controllerFactory.Create <TController>()); }