public IDefinitionClass CreateInstance(UiController controller, object context) { IDefinitionClass obj = (IDefinitionClass)Activator.CreateInstance(Class); if (obj.Init(controller, context, this)) { return(obj); } return(null); }
internal void NavigateTo(DefinitionFile def, InvokeParameters parameters) { if (def == null) { AddPage(null); return; } Type controllerType = def["PageController"] as Type; UiController controller = Controller; bool attachController = false; if (controllerType != null) { var newController = Activator.CreateInstance(controllerType) as UiController; if (newController != null) { newController.Parent = Controller; controller = newController; attachController = true; } } IDefinitionClass obj = (IDefinitionClass)Activator.CreateInstance(def.Class); if (!(obj is UiPage)) { throw new Exception("Error while navigating to page. The given file doesn't define UiPage."); } if (controller is UiNavigationController) { (controller as UiNavigationController).InitPage(parameters); } if (attachController) { (obj as UiView).Controller = controller; } if (!obj.Init(controller, Binding, def)) { throw new Exception("Error while navigating to page."); } AddPage(obj as UiPage); _history.Add(new Tuple <DefinitionFile, InvokeParameters>(def, parameters)); }