protected Page CreateAndBindPage(Type viewModelType, object parameter) { try { Type pageType = GetPageTypeForViewModel(viewModelType); if (pageType == null) { throw new Exception($"Mapping type for {viewModelType} is not a page"); } Page page = Activator.CreateInstance(pageType) as Page; PageModelBase viewModel = PageModelLocator.Instance.Resolve(viewModelType) as PageModelBase; page.BindingContext = viewModel; if (page is IPageWithParameters) { ((IPageWithParameters)page).InitializeWith(parameter); } return(page); } catch (Exception e) { throw new Exception(e.Message); } }
/// <summary> /// 收集所有的page之后,再response /// </summary> /// <param name="topic"></param> /// <param name="payload"></param> private async void TagSetupReceived(string topic, byte[] payload) { string strPayload = Encoding.UTF8.GetString(payload); SetupModel setup = JsonSrialize.Desrialize <SetupModel>(strPayload); LogHelper.Debug("TagSetupReceived: " + strPayload); if (!(PageModelBase <GroupRes> .GatherAllPages(setup, 5000, null) is SetupModel pages)) { return; } var task = Setup2Proxys(pages); await task; if (task.Result != null) { LogHelper.Debug("task.Result.code = " + task.Result.code); await MqttMgr.Inst.PublishAsync(topic + "/response", JsonSrialize.Srialize(task.Result)); } }
public static void AfterFeature() { PageModelBase.CloseDownDriver(); }
public static void BeforeFeature() { PageModelBase.InitialiseDriver(); }
public static void BeforeScenario() { //Reset to initial URL PageModelBase.ReturnHome(); }