public void Setup() { if (Isolate) { AppSetup.BeginIsolate(); } else { AppSetup.EnsureMemory(); AppSetup.EnsureConnection(); } AppSetup.NavigateToIssue(GetType(), RunningApp); }
public void TestConfigWithFileNotExists() { IAppModule appModule = new TestAppModule(); AppSetup setup = new AppSetup("./abc.json"); var app = setup.Start(appModule); IComponentContainer componentContainer = app.GetAppContainer <IComponentContainer>(); using (var scope = componentContainer.BeginScope("test")) { TestConfig config1 = scope.CreateComponent <TestConfig>(); TestConfig config2 = scope.CreateComponent <TestConfig>(); Assert.AreEqual("Mode", config1.Mode); Assert.AreEqual(config1, config2); } }
public void InvokePluginsWhenStart() { var setup = new AppSetup(); setup.AddPlugin(new TestPlugs()); var app = setup.Start(new ThisAppModule()); List <Type> builderTypeList = (List <Type>)setup.Context[CONTEXT_KEY_BUILDER_TYPES]; Assert.AreEqual(3, builderTypeList.Count); List <Type> moduleTypeList = (List <Type>)setup.Context[CONTEXT_KEY_MODULE_TYPES]; Assert.AreEqual(4, moduleTypeList.Count); }
public static void SetupContainer(AppSetup appSetup) { appSetup.ContainerBuilder.RegisterType <MainPageViewModel>().AsSelf(); appSetup.ContainerBuilder.RegisterType <LoginViewModel>().AsSelf(); appSetup.ContainerBuilder.RegisterType <HomeTabbedPageViewModel>().AsSelf(); appSetup.ContainerBuilder.RegisterType <HostManagerPageViewModel>().AsSelf(); appSetup.ContainerBuilder.RegisterType <ShellPageViewModel>().AsSelf(); appSetup.ContainerBuilder.RegisterType <SettingsPageViewModel>().AsSelf(); appSetup.ContainerBuilder.RegisterType <WelcomeStartPageViewModel>().AsSelf(); appSetup.ContainerBuilder.RegisterType <Database>().As <IDatabase>().SingleInstance(); appSetup.ContainerBuilder.RegisterType <RepositoryBase>().As <IRepository>(); appSetup.ContainerBuilder.RegisterType <SshService>().As <ISshService>().SingleInstance(); appSetup.ContainerBuilder.RegisterType <SQLiteFactory>().As <ISQLiteFactory>().SingleInstance(); var container = appSetup.Build(); }
public void GetServiceThatRegistedByTestAppModule() { IAppModule appModule = new TestAppModule(); AppSetup setup = new AppSetup(); var app = setup.Start(appModule); IComponentContainer componentContainer = app.GetAppContainer <IComponentContainer>(); using (var scope = componentContainer.BeginScope("test")) { ServiceRegistedByAppModule service = scope.CreateComponent <ServiceRegistedByAppModule>(); Assert.IsNotNull(service); Assert.IsInstanceOfType(service, typeof(DefaultServiceRegistedByAppModule)); } }
public App(AppSetup setup) { InitializeComponent(); // AppDomain.CurrentDomain.UnhandledException += (sender, args) => { // System.Exception ex = (System.Exception)args.ExceptionObject; // Console.WriteLine(ex); // }; AppContainer.Container = setup.CreateContainer(); //MainPage = new MainPage(); //MainPage = new NavigationPage(new ItemsPage()); //MainPage = new ValidationPage(); //MainPage = new NavigationPage (new FirstPage()); //MainPage = new AppShell(); MainPage = new TemperaturePage(); }
public void DoNotTriggerNoComponentRegisted() { IAppModule appModule = new TestAppModule(); AppSetup setup = new AppSetup(); var app = setup.Start(appModule); var container = app.GetAppContainer <IComponentContainer>(); container.NoComponentRegisted += (sender, e) => { Assert.Fail(); }; using (var scope = container.BeginScope("TEST")) { var t = scope.CreateComponent <ILifetimeScope>(); } }
public void BeginWork() { var app = new AppSetup().Start(new TestAppModule()); IIdService t1, t2, t3; using (var work = app.BeginWork("t1")) { t1 = work.CreateComponent <IIdService>(); t2 = work.CreateComponent <IIdService>(); Assert.AreEqual(t1.Id, t2.Id); } using (var work = app.BeginWork("t2")) { t3 = work.CreateComponent <IIdService>(); Assert.AreNotEqual(t1.Id, t3.Id); } }
public static void SetupContainer(AppSetup appSetup) { appSetup.ContainerBuilder.RegisterType <HomeMasterDetailPageMasterViewModel2>().AsSelf(); appSetup.ContainerBuilder.RegisterType <AboutPageViewModel>().AsSelf(); appSetup.ContainerBuilder.RegisterType <SettingsPageViewModel>().AsSelf(); appSetup.ContainerBuilder.RegisterType <WelcomeStartPageViewModel>().AsSelf(); appSetup.ContainerBuilder.RegisterType <CategoryBuilder>().AsSelf(); appSetup.ContainerBuilder.RegisterType <YggClientCodePcl.YggClient>().AsSelf(); //appSetup.ContainerBuilder.RegisterType<Database>().As<IDatabase>().SingleInstance(); //appSetup.ContainerBuilder.RegisterType<RepositoryBase>().As<IRepository>(); //appSetup.ContainerBuilder.RegisterType<SQLiteFactory>().As<ISQLiteFactory>().SingleInstance(); appSetup.ContainerBuilder.RegisterType <NavigationService>().As <INavigationService>().SingleInstance(); var container = appSetup.Build(); }
public void ChangeInstance() { var app = AppSetup.Start <TestAppModule>(); IComponentContainer container = app.GetAppContainer <IComponentContainer>(); container.ComponentCreating += (sender, e) => { if (e.CreatedObject is IIdService) { e.Replace(new EmptyIdService()); } }; using (IWork work = app.BeginWork("Test")) { IIdService service = work.CreateComponent <IIdService>(); Assert.IsInstanceOfType(service, typeof(EmptyIdService)); } }
protected override void handleRequest() { if (string.IsNullOrEmpty(operationCode)) { input = new SearchPendingOperationsInput() { ida = StorageUtils.getIDA(), appVersion = AppSetup.getAppVersion(), tda = TDA.getEvolvedTDA(), messageCode = RequestCodes.REQ024, messageVersion = int.Parse(RequestCodes.REQ024Version) }; // In case of TDA retrieving error, do not make the request if (((SearchPendingOperationsInput)input).tda == null) { handleResponse("Error getting evolved TDA"); return; } } else { input = new SearchPendingOperationsInputWithOc() { ida = StorageUtils.getIDA(), appVersion = AppSetup.getAppVersion(), tda = TDA.getEvolvedTDA(), messageCode = RequestCodes.REQ024, messageVersion = int.Parse(RequestCodes.REQ024Version), operationCode = operationCode }; // In case of TDA retrieving error, do not make the request if (((SearchPendingOperationsInputWithOc)input).tda == null) { handleResponse("Error getting evolved TDA"); return; } } // TODO postRequest(); }
public override void OnAppModuleBeforeUsing(AppSetup setup, AppModuleUsingArguments arguments) { if (!(arguments.UsingAppModule is INamespaceFilter)) { return; } INamespaceFilter filter = (INamespaceFilter)arguments.UsingAppModule; IEnumerable <AttributeAndTypeInfo> infos = arguments.ScannedAttributeAndTypeInfos; if (filter.IncludeNamespaces != null && filter.IncludeNamespaces.Length > 0) { infos = infos.Where(info => { string fullNameOfType = info.Type.FullName; foreach (var ns in filter.IncludeNamespaces) { if (fullNameOfType.StartsWith(ns)) { return(true); } } return(false); }); } if (filter.ExcludeNamespaces != null && filter.ExcludeNamespaces.Length > 0) { infos = infos.Where(info => { string fullNameOfType = info.Type.FullName; foreach (var ns in filter.ExcludeNamespaces) { if (fullNameOfType.StartsWith(ns)) { return(false); } } return(true); }); } arguments.ScannedAttributeAndTypeInfos = infos.ToList(); }
public App(AppSetup appSetup) { try { IsUserLoggedIn = false; IsFormsAdded = false; string checkSettings = String.Empty; // Create the Autofac IOC container. AppContainer.Container = appSetup.CreateContainer(); // Determine if we have settings and / or if the user is logged in. if (checkSettings != "true") { MainPage = new NavigationPage(new SettingsView()) { BarBackgroundColor = Color.FromHex(AppStyle.BarBackGroundColor), BarTextColor = Color.FromHex(AppStyle.BarTextColor) }; return; } if (!IsUserLoggedIn) { MainPage = new NavigationPage(new LogViewMasters()) { BarBackgroundColor = Color.FromHex(AppStyle.BarBackGroundColor), BarTextColor = Color.White }; } else { MainPage = new NavigationPage(new MainViewsMasters()); } } catch (Exception esx) { Debug.WriteLine(esx); } }
public void WorkInWork() { var app = new AppSetup().Start(new TestAppModule()); IIdService t1, t2, t3, t4 ; using (var w = app.BeginWork("t")) { t1 = w.CreateComponent <IIdService>(); using (var w1 = w.BeginWork("t1")) { t2 = w1.CreateComponent <IIdService>(); t3 = w1.CreateComponent <IIdService>(); Assert.AreEqual(t2.Id, t3.Id); Assert.AreNotEqual(t1.Id, t2.Id); } t4 = w.CreateComponent <IIdService>(); Assert.AreEqual(t1.Id, t4.Id); } }
public override void OnAppModuleUsed(AppSetup setup, OnAppModuleUsedArguments arguments) { foreach (var method in arguments.AppModule.GetType().GetMethods()) { IEnumerable <AppModuleMethodAttribute> attrs = method.GetCustomAttributes <AppModuleMethodAttribute>(); foreach (var attr in attrs) { IAppModuleMethodHandler handler; if (!attrToHandlerMap.TryGetValue(attr.GetType(), out handler)) { handler = Activator.CreateInstance(attr.AppModuleMethodHandlerType) as IAppModuleMethodHandler; if (handler == null) { throw new InvalidCastException($"无法将 {attr.AppModuleMethodHandlerType} 转换为 {typeof(IAppModuleMethodHandler)}"); } attrToHandlerMap[attr.GetType()] = handler; } handler.Handle(setup, arguments.AppModule, method, attr); } } }
public App() { InitializeComponent(); //To initialize Containers.. AppSetup appSetup = new AppSetup(); _container = appSetup.CreateContainer(); if (!string.IsNullOrEmpty(Helpers.LocalStorage.GeneralProfileToken)) { MainPage = new Views.Currencies.CurrencyPage(); } else { MainPage = new Views.Introduction.IntroductionPage(); } #region Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("OTMyNDlAMzEzNzJlMzEyZTMwWVAxejJTOFhSaUswQm1MUGJoWC93K3pyRWpkdkNVM0oyemhkK1ZzY0pNbz0="); #endregion }
public static void SetupContainer(AppSetup appSetup) { appSetup.ContainerBuilder.RegisterType <MainPageViewModel>().AsSelf(); appSetup.ContainerBuilder.RegisterType <LoginViewModel>().AsSelf(); appSetup.ContainerBuilder.RegisterType <HomeTabbedPageViewModel>().AsSelf(); appSetup.ContainerBuilder.RegisterType <HostManagerPageViewModel>().AsSelf(); appSetup.ContainerBuilder.RegisterType <ShellPageViewModel>().AsSelf(); appSetup.ContainerBuilder.RegisterType <SettingsPageViewModel>().AsSelf(); appSetup.ContainerBuilder.RegisterType <WelcomeStartPageViewModel>().AsSelf(); appSetup.ContainerBuilder.RegisterType <AddCommandPageViewModel>().AsSelf(); appSetup.ContainerBuilder.RegisterType <CommandListViewPageViewModel>().AsSelf(); appSetup.ContainerBuilder.RegisterType <UpgradableListViewPageViewModel>().AsSelf(); appSetup.ContainerBuilder.RegisterType <RootMasterDetailPageMasterViewModel>().AsSelf(); appSetup.ContainerBuilder.RegisterType <Database>().As <IDatabase>().SingleInstance(); appSetup.ContainerBuilder.RegisterType <RepositoryBase>().As <IRepository>(); appSetup.ContainerBuilder.RegisterType <SshService>().As <ISshService>().SingleInstance(); appSetup.ContainerBuilder.RegisterType <SQLiteFactory>().As <ISQLiteFactory>().SingleInstance(); appSetup.ContainerBuilder.RegisterType <NavigationService>().As <INavigationService>().SingleInstance(); var container = appSetup.Build(); }
/// <summary> /// Initializes the app. /// </summary> private void InitializeApp() { // Initialize SVG XamSvg.Setup.InitSvgLib(); //Tells XamSvg in which assembly to search for svg when "res:" is used XamSvg.Shared.Config.ResourceAssembly = typeof(SVGImages).GetTypeInfo().Assembly; // If not required for your application you can safely delete this method var setup = new AppSetup(); AppContainer.Container = setup.CreateContainer(); setup.InitObjectMapping(); Window = new UIWindow(UIScreen.MainScreen.Bounds); var viewController = new LoginViewController(); // Add the Navigation Controller and initialize it var navController = new UINavigationController(viewController); Window.RootViewController = navController; Window.MakeKeyAndVisible(); }
public App(AppSetup setup) { InitializeComponent(); DependencyService.Register <MockDataStore>(); AppContainer.Container = setup.CreateContainer(); Application.Current.Properties["id"] = ""; NavigationService.Configure("MainPage", typeof(Views.MainPage)); NavigationService.Configure("AboutPage", typeof(Views.AboutPage)); NavigationService.Configure("ItemDetailPage", typeof(Views.ItemDetailPage)); NavigationService.Configure("ItemsPage", typeof(Views.ItemsPage)); NavigationService.Configure("LoginPage", typeof(Views.LoginPage)); NavigationService.Configure("MenuPage", typeof(Views.MenuPage)); NavigationService.Configure("NewItemPage", typeof(Views.NewItemPage)); NavigationService.Configure("SignUpPage", typeof(Views.SignUpPage)); NavigationService.Configure("WelcomePage", typeof(Views.WelcomePage)); var mainPage = ((NavigationService)NavigationService).SetRootPage("MainPage"); MainPage = new MainPage(); }
// // This method is invoked when the application has loaded and is ready to run. In this // method you should instantiate the window, load the UI into it and then make the window // visible. // // You have 17 seconds to return from this method, or iOS will terminate your application. // public override bool FinishedLaunching(UIApplication app, NSDictionary options) { // create a new window instance based on the screen size window = new UIWindow(UIScreen.MainScreen.Bounds); runner = new TouchRunner(window); // Initialize Automapper var setup = new AppSetup(); setup.InitObjectMapping(); // register every tests included in the main application/assembly runner.Add(System.Reflection.Assembly.GetExecutingAssembly()); window.RootViewController = new UINavigationController(runner.GetViewController()); // make the window visible window.MakeKeyAndVisible(); return(true); }
public void Handle(AppSetup appSetup, IAppModule appModule, MethodInfo method, Attribute attribute) { AutofacContainerBuilder autofacContainerBuilder = appSetup.GetAppContainerBuilder <AutofacContainerBuilder>(); autofacContainerBuilder.RegisterByCreator(cm => { ParameterInfo[] ps = method.GetParameters(); if (ps.Length == 0) { return(method.Invoke(appModule, null)); } object[] values = new object[ps.Length]; for (int i = 0; i < ps.Length; i++) { Type pType = ps[i].ParameterType; object value = cm.CreateComponent(pType); values[i] = value; } return(method.Invoke(appModule, values)); }, method.ReturnType); }
public App(AppSetup setup) { InitializeComponent(); var page = new MainPageView(); var navPage = new NavigationPage(page); _container = setup.CreateContainer(cb => { cb.RegisterInstance(navPage as Page); cb.RegisterInstance(this as Application); }); _container.BeginLifetimeScope(); setup.RegisterViewModelMappings(); var vm = _container.Resolve <MainViewModelFactory>().Create(); page.BindingContext = vm; MainPage = navPage; }
public async static void CleanResetApplicationStorage() { storeFlagState(kIsAppActivated, false); IDA = null; storeDataToFile(kCardsList, null); await ApplicationData.Current.ClearAsync(); string deviceModel = AppSetup.getDeviceModel(); storeData(kDeviceModel, deviceModel); string deviceOS = AppSetup.getDeviceOS(); storeData(kDeviceOS, deviceOS); string deviceSerial = AppSetup.getDeviceSerial(); storeData(kDeviceSerial, deviceSerial); }
static void Main(string[] args) { AppSetup appSetup = new AppSetup(); var app = appSetup.Start(new TestAppModule()); var container = app.GetAppContainer <IComponentContainer>(); for (int i = 0; i < 10; i++) { var t = new Thread(new ThreadStart(() => { Console.WriteLine($"{Thread.CurrentThread.Name} Started"); for (int j = 0; j < 10; j++) { using (var scope = container.BeginScope($"TEST_{Thread.CurrentThread.Name}_{j}")) { var task = scope.CreateComponent <ITask>(); task.Do(); } } })); StringBuilder sb = new StringBuilder(); for (int k = 0; k < 10; k++) { if (k == i) { sb.Append(i.ToString()); } else { sb.Append(" "); } } t.Name = sb.ToString(); t.Start(); } Console.ReadLine(); }
public void Cleanup() { _appSetup = null; }
public void Init() { _appSetup = new AppSetup(); }
public void Handle(AppSetup appSetup, IAppModule appModule, MethodInfo method, Attribute attribute) { var replaceBuilder = appSetup.GetAppContainerBuilder <ReplaceServiceContainerBuilder>(); replaceBuilder.TryRegister(appModule, method); }
public override void OnAppModuleUsed(AppSetup setup, OnAppModuleUsedArguments arguments) { List <Type> list = setup.Context.GetOrCreate(CONTEXT_KEY_MODULE_TYPES, key => new List <Type>()); list.Add(arguments.AppModule.GetType()); }
public override void OnAppContainerBuilderCreated(AppSetup setup, OnAppContainerBuilderCreatedArguments arguments) { List <Type> builderTypeList = setup.Context.GetOrCreate(CONTEXT_KEY_BUILDER_TYPES, key => new List <Type>()); builderTypeList.Add(arguments.AppContainerBuilder.GetType()); }
public void Prepare(AppSetup setup) { }