Esempio n. 1
0
 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));
 }
Esempio n. 2
0
 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);
 }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
            public void Resolve()
            {
                DiSetup.Tests();
                DiManager.GetInstance().RegisterInstance <INavigationPresenter>(new DummyNavigationPresenter());

                var navigationService = DiHelper.GetService <INavigationService>();

                Assert.IsNotNull(navigationService);
            }
Esempio n. 5
0
 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);
 }
Esempio n. 6
0
            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);
            }
Esempio n. 7
0
 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;
 }
Esempio n. 8
0
 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")
     });
 }
Esempio n. 9
0
        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
        }
Esempio n. 10
0
            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);
            }
Esempio n. 11
0
 public static void AdminApp()
 {
     DiSetup.@base();
     DiManager.GetInstance().RegisterType <IViewModelLocator, ViewModelLocator>(Lifetime.Singleton);
     DiManager.GetInstance().RegisterType <INavigationService, NavigationService>(Lifetime.Singleton);
 }
Esempio n. 12
0
 public static void InMemoryDataServiceTests()
 {
     DiSetup.Tests();
     DiManager.GetInstance().RegisterType <IDataService, NET.efilnukefesin.Implementations.Services.DataService.InMemoryDataService.InMemoryDataService>();  //TODO: switch per test
 }
Esempio n. 13
0
 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();
 }
Esempio n. 14
0
        public MainWindow()
        {
            InitializeComponent();

            DiManager.GetInstance().Resolve <INavigationPresenter>().RegisterPresenter(this.mainFrame);
        }
Esempio n. 15
0
        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
        }
Esempio n. 16
0
 public static void Tests()
 {
     DiSetup.@base();
     DiManager.GetInstance().AddTypeTranslation("HttpMessageHandlerProxy", typeof(HttpMessageHandler));
 }
Esempio n. 17
0
 /// <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>());
 }
Esempio n. 18
0
 protected void RegisterDependencies()
 {
     DiManager.GetInstance().RegisterInstance <INodeManager <INode <string>, string> >(new SimpleNodeManager <INode <string>, string>(new SimpleNode <string>(string.Empty, null)));
 }
Esempio n. 19
0
 protected void Application_Start()
 {
     DiManager.InitDependencies();
     AreaRegistration.RegisterAllAreas();
     RouteConfig.RegisterRoutes(RouteTable.Routes);
 }
Esempio n. 20
0
 public static void Register <TFrom, TTo>(Lifetime Lifetime = Lifetime.NewInstanceEveryTime) where TFrom : class where TTo : class, TFrom
 {
     DiManager.GetInstance().RegisterType <TFrom, TTo>(Lifetime);
 }
Esempio n. 21
0
 /// <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));
 }
Esempio n. 22
0
 private object GenerateNativeModule([NotNull] IDiModule diModule)
 {
     diModule.Init(_serviceRegistrationBuilder);
     return(DiManager.GenerateNativeModule(diModule));
 }
 protected void Application_Start(object sender, EventArgs e)
 {
     MyRouteManager.RegisterRoutes();
     DiManager.InitDependencies();
 }