public static void Tests() { DiSetup.@base(); DiManager.GetInstance().AddTypeTranslation("HttpMessageHandlerProxy", typeof(HttpMessageHandler)); DiManager.GetInstance().AddTypeTranslation("Microsoft.AspNetCore.Mvc.Testing.Handlers.RedirectHandler", typeof(HttpMessageHandler)); DiManager.GetInstance().AddTypeTranslation("RedirectHandler", typeof(HttpMessageHandler)); }
private static void @base() { DiManager.GetInstance().RegisterType <IEndpointRegister, NET.efilnukefesin.Implementations.Services.DataService.EndpointRegister.EndpointRegister>(Lifetime.Singleton); //where is all the data coming from? DiManager.GetInstance().RegisterType <IFeatureToggleManager, FeatureToggleManager>(Lifetime.Singleton); DiManager.GetInstance().RegisterType <ILogger, SerilogLogger>(); DiManager.GetInstance().RegisterType <INavigationService, NavigationService>(Lifetime.Singleton); DiManager.GetInstance().RegisterType <ITimeService, StandardTimeService>(Lifetime.Singleton); }
private static void @base(bool isInMemory = false, HttpMessageHandler overrideHttpMessageHandler = null) { DiManager.GetInstance().RegisterType <IToastService, Win10ToastService>(Lifetime.Singleton); DiManager.GetInstance().RegisterType <ILogger, SerilogLogger>(Lifetime.Singleton); DiManager.GetInstance().RegisterType <INavigationPresenter, WpfNavigationPresenter>(Lifetime.Singleton); DiManager.GetInstance().RegisterType <IViewModelLocator, ViewModelLocator>(Lifetime.Singleton); DiManager.GetInstance().RegisterType <INavigationService, NavigationService>(Lifetime.Singleton); }
public void Resolve() { DiSetup.Tests(); DiManager.GetInstance().RegisterInstance <INavigationPresenter>(new DummyNavigationPresenter()); var navigationService = DiHelper.GetService <INavigationService>(); Assert.IsNotNull(navigationService); }
public void AddRoot() { this.RegisterDependencies(); INode <string> node = new SimpleNode <string>("Somestring", null); INodeManager <INode <string>, string> nodeManager = DiManager.GetInstance().Resolve <INodeManager <INode <string>, string> >(); nodeManager.AddRoot(node); Assert.IsNotNull(nodeManager.Root); Assert.AreEqual(node.Id, nodeManager.Root.Id); }
public static void RegisterDependencies() { DiManager.GetInstance().RegisterType <ISnackbarMessageQueue, SnackbarMessageQueue>(Lifetime.Singleton); DiManager.GetInstance().RegisterType <IUserService, DemoUserService>(Lifetime.Singleton); DiManager.GetInstance().RegisterType <IToastService, ToastService>(Lifetime.Singleton); DiManager.GetInstance().RegisterType <IDesignModeService, WpfDesignModeService>(Lifetime.Singleton); DiManager.GetInstance().RegisterType <IVersionService, VersionService>(Lifetime.Singleton); DiManager.GetInstance().RegisterType <INavigationPresenter, WpfNavigationPresenter>(Lifetime.Singleton); DiManager.GetInstance().RegisterType <IViewModelLocator, ViewModelLocator>(Lifetime.Singleton); DiManager.GetInstance().RegisterType <INavigationService, NavigationService>(Lifetime.Singleton); }
private void findAndAddViewModelInstances() { this.IsBusy = true; this.logger?.Log($"ViewModelLocator.findAndAddViewModelInstances(): entered"); Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly currentAssembly in assemblies) { if (currentAssembly.FullName.Contains("System.Runtime")) { this.logger?.Log($"ViewModelLocator.findAndAddViewModelInstances(): skipped Assembly '{currentAssembly.FullName}'"); } else { foreach (Type currentType in currentAssembly.GetTypes()) { try { foreach (object customAttribute in currentType.GetCustomAttributes(true)) { try { LocatorAttribute locatorAttribute = customAttribute as LocatorAttribute; if (locatorAttribute != null) { if (!this.registeredInstances.ContainsKey(locatorAttribute.Name)) { this.logger?.Log($"ViewModelLocator.findAndAddViewModelInstances(): adding new instance '{locatorAttribute.Name}'"); object instance = DiManager.GetInstance().Resolve(currentType); //TODO: just add type, let resolving be done by using app this.registeredInstances.Add(locatorAttribute.Name, instance); } else { this.logger?.Log($"ViewModelLocator.findAndAddViewModelInstances(): skipping '{locatorAttribute.Name}' as already registered"); } } } catch (Exception ex) { this.logger?.Log($"ViewModelLocator.findAndAddViewModelInstances(): Exception caught with Attributes: '{ex.Message}'", Contracts.Logger.Enums.LogLevel.Warning); } } } catch (Exception ex) { this.logger?.Log($"ViewModelLocator.findAndAddViewModelInstances(): Exception caught with Types: '{ex.Message}'", Contracts.Logger.Enums.LogLevel.Warning); } } } } this.logger?.Log($"ViewModelLocator.findAndAddViewModelInstances(): exited"); this.IsBusy = false; }
public MenuUserControlViewModel() { if (DiManager.GetInstance().IsRegistered <INavigationService>()) { this.navigationService = DiManager.GetInstance().Resolve <INavigationService>(); //TODO: clean up, catch exception } else { this.navigationService = null; } this.SearchInfo = new SearchBoxUserControlViewModel() { DelayingTextInputUserControlViewModel = new DelayingTextInputUserControlViewModel() { Text = "Something2!", Hint = "Search" } }; this.VersionInfo = new VersionInfoUserControlViewModel() { Version = new VersionModel(new Version(1, 1), new DateTimeOffset(2019, 03, 04, 23, 59, 59, new TimeSpan(-1, 0, 0))) }; this.UserInfo = new UserInfoUserControlViewModel() { User = new UserModel() { Firstname = "Nigel", Lastname = "Lotze", Nickname = "Lotzinator", CurrentLevel = new LevelModel() { MinExperience = 100, MaxExperience = 102, Title = "Grand Geek" }, Experience = 101 } }; this.MenuItems = new MenuItemsUserControlViewModel(this.navigationService) { Items = new ObservableCollection <BaseMenuItemUserControlViewModel>() { } }; this.MenuItems.Items.Add(new BaseMenuItemUserControlViewModel(this.navigationService, this.MenuItems) { Item = new Apps.UXDemo.Models.MenuItem("Demo1", "DemoPageViewModel") }); this.MenuItems.Items.Add(new BaseMenuItemUserControlViewModel(this.navigationService, this.MenuItems) { Item = new Apps.UXDemo.Models.MenuItem("Demo2", "DemoPage2ViewModel") }); this.MenuItems.Items.Add(new BaseMenuItemUserControlViewModel(this.navigationService, this.MenuItems) { Item = new Apps.UXDemo.Models.MenuItem("Demo3", "DemoPage3ViewModel") }); }
private static void @base() { DiManager.GetInstance().RegisterType <IEndpointRegister, EndpointRegister>(NET.efilnukefesin.Contracts.DependencyInjection.Enums.Lifetime.Singleton); //where is all the data coming from? DiManager.GetInstance().RegisterType <IDataService, RestDataService>(); //where is all the data coming from? DiManager.GetInstance().RegisterType <IDataService, FileDataService>(); //where is all the data coming from? DiManager.GetInstance().RegisterType <ILogger, SerilogLogger>(); DiManager.GetInstance().RegisterType <IConfigurationService, StaticConfigurationService>(); DiManager.GetInstance().RegisterType <IIdentityService, IdentityService>(); DiManager.GetInstance().RegisterType <IRoleService, RoleService>(); DiManager.GetInstance().RegisterType <IPermissionService, PermissionService>(); DiManager.GetInstance().RegisterType <IMessageBroker, SimpleMessageBroker>(Lifetime.Singleton); DiManager.GetInstance().RegisterType <IUserService, UserService>(Lifetime.Singleton); DiManager.GetInstance().RegisterType <ISessionService, SessionService>(Lifetime.Singleton); DiManager.GetInstance().RegisterType <IFeatureToggleManager, FeatureToggleManager>(Lifetime.Singleton); DiManager.GetInstance().RegisterTarget <PermissionServer.SDK.Client>(Lifetime.Singleton, new List <ParameterInfoObject>() { new DynamicParameterInfoObject(typeof(IDataService), typeof(RestDataService), new Uri("http://localhost:6008")) }); DiManager.GetInstance().RegisterTarget <SuperHotFeatureServer.SDK.Client>(Lifetime.Singleton, new List <ParameterInfoObject>() { new DynamicParameterInfoObject(typeof(IDataService), typeof(RestDataService), new Uri("http://localhost:6010")) }); DiManager.GetInstance().RegisterTarget <SuperHotOtherFeatureServer.SDK.Client>(Lifetime.Singleton, new List <ParameterInfoObject>() { new DynamicParameterInfoObject(typeof(IDataService), typeof(RestDataService), new Uri("http://localhost:6012")) }); DiManager.GetInstance().RegisterTarget <IUserService, UserService>(Lifetime.Singleton, new List <ParameterInfoObject>() { new DynamicParameterInfoObject(typeof(IDataService), typeof(FileDataService), "Data") }); DiManager.GetInstance().RegisterTarget <IRoleService, RoleService>(Lifetime.Singleton, new List <ParameterInfoObject>() { new DynamicParameterInfoObject(typeof(IDataService), typeof(FileDataService), "Data") }); DiManager.GetInstance().RegisterTarget <IPermissionService, PermissionService>(Lifetime.Singleton, new List <ParameterInfoObject>() { new DynamicParameterInfoObject(typeof(IDataService), typeof(FileDataService), "Data") }); DiManager.GetInstance().RegisterTarget <AuthenticationService>(Lifetime.Singleton); //*** //TODO: use config values }
public void SetCurrentNode() { this.RegisterDependencies(); INodeManager <INode <string>, string> nodeManager = DiManager.GetInstance().Resolve <INodeManager <INode <string>, string> >(); INode <string> node = new SimpleNode <string>("Somestring", null); node.AddChild(new SimpleNode <string>("Somestring2", node)); node.AddChild(new SimpleNode <string>("Somestring3", node)); node.AddChild(new SimpleNode <string>("Somestring4", node)); nodeManager.AddRoot(node); INode <string> currentNode = nodeManager.ActiveNode; nodeManager.Traverse(1); INode <string> currentNodeNew = nodeManager.ActiveNode; Assert.IsNotNull(currentNodeNew); Assert.AreEqual(node.Children.ToList()[1].Id, currentNodeNew.Id); }
public static void Tests() { DiSetup.@base(); DiManager.GetInstance().AddTypeTranslation("HttpMessageHandlerProxy", typeof(HttpMessageHandler)); }
/// <summary> /// gets a service implementation from the DI Container /// </summary> /// <typeparam name="I">the interface you need the implementation for</typeparam> /// <returns>the service implementation</returns> public static I GetService <I>() { return(DiManager.GetInstance().Resolve <I>()); }
public static void InMemoryDataServiceTests() { DiSetup.Tests(); DiManager.GetInstance().RegisterType <IDataService, NET.efilnukefesin.Implementations.Services.DataService.InMemoryDataService.InMemoryDataService>(); //TODO: switch per test }
public static void AddToAspNetCore(IServiceCollection services) { DiManager.GetInstance().RegisterType <IEndpointRegister, NET.efilnukefesin.Implementations.Services.DataService.EndpointRegister.EndpointRegister>(Lifetime.Singleton); //where is all the data coming from? services.AddSingleton <IDataService>(s => DiHelper.GetService <InMemoryDataService>("Data")); DiSetup.Initialize(); }
public MainWindow() { InitializeComponent(); DiManager.GetInstance().Resolve <INavigationPresenter>().RegisterPresenter(this.mainFrame); }
public MainWindow() { InitializeComponent(); DiManager.GetInstance().Resolve <INavigationPresenter>().RegisterPresenter(this.mainFrame); //must be done initially to register the frame in which the pages are to be shown }
protected void RegisterDependencies() { DiManager.GetInstance().RegisterInstance <INodeManager <INode <string>, string> >(new SimpleNodeManager <INode <string>, string>(new SimpleNode <string>(string.Empty, null))); }
public static void AdminApp() { DiSetup.@base(); DiManager.GetInstance().RegisterType <IViewModelLocator, ViewModelLocator>(Lifetime.Singleton); DiManager.GetInstance().RegisterType <INavigationService, NavigationService>(Lifetime.Singleton); }
/// <summary> /// gets a service implementation from the DI Container /// </summary> /// <typeparam name="I">the interface you need the implementation for</typeparam> /// <param name="Parameters">C'tor Params</param> /// <returns>the service implementation</returns> public static I GetService <I>(params object[] Parameters) { return(DiManager.GetInstance().Resolve <I>(Parameters)); }
public static void Register <TFrom, TTo>(Lifetime Lifetime = Lifetime.NewInstanceEveryTime) where TFrom : class where TTo : class, TFrom { DiManager.GetInstance().RegisterType <TFrom, TTo>(Lifetime); }