Ejemplo n.º 1
0
        public ViewModelLocator()
        {
            _container = new UnityContainer();

            _container.RegisterType <MainPageViewModel>();

            _container.RegisterType <ILoaderService, LoaderService>(new ContainerControlledLifetimeManager());
            _container.RegisterType <INotaService, NotaService>(new ContainerControlledLifetimeManager());
            _container.RegisterType <IDialogService, DialogService>(new ContainerControlledLifetimeManager());
            _container.RegisterType <INavigationService, NavigationService>(new ContainerControlledLifetimeManager());
        }
Ejemplo n.º 2
0
 void IRegionViewRegistry.Register <TInterface, TClass>(string key)
 {
     if (string.IsNullOrEmpty(key))
     {
         Container.RegisterType <TInterface, TClass>();
     }
     else
     {
         Container.RegisterType <TInterface, TClass>(key);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Registers the type mappings with the Unity container.
        /// </summary>
        /// <param name="container">The unity container to configure.</param>
        /// <remarks>
        /// There is no need to register concrete types such as controllers or
        /// API controllers (unless you want to change the defaults), as Unity
        /// allows resolving a concrete type even if it was not previously
        /// registered.
        /// </remarks>
        public static void RegisterTypes(Unity.IUnityContainer container)
        {
            // NOTE: To load from web.config uncomment the line below.
            // Make sure to add a Unity.Configuration to the using statements.
            // container.LoadConfiguration();

            // TODO: Register your type's mappings here.
            container.RegisterType <IHubActivator, UnityHubActivator>(new ContainerControlledLifetimeManager());
            container.RegisterType <ITodoService, TodoService>(new PerResolveLifetimeManager());
            container.RegisterType <IToDoDbContext, GreenSlate.Database.ToDoTaskDbContext>(new PerResolveLifetimeManager());
            container.RegisterType <IToDoTasksHub, ToDoTasksHub>(new PerResolveLifetimeManager());

            // container.RegisterType<AccountController>(new InjectionConstructor());
            // container.RegisterType<ManageController>(new InjectionConstructor());
        }
Ejemplo n.º 4
0
        public static void RegisterInheritedTypes(this Unity.IUnityContainer container, Assembly assembly, System.Type baseType)
        {
            var allTypes       = assembly.GetTypes();
            var baseInterfaces = baseType.GetInterfaces();

            foreach (var type in allTypes)
            {
                var test = type.BaseType;
                if (type.BaseType != null && type.BaseType.GenericEq(baseType))
                {
                    var typeInterface = type.GetInterfaces().FirstOrDefault(x => !baseInterfaces.Any(bi => bi.GenericEq(x)));
                    if (typeInterface == null)
                    {
                        continue;
                    }
                    container.RegisterType(typeInterface, type);
                    //container.RegisterSingleton(typeInterface, type);
                }
            }

            var ok = assembly.GetTypes();
        }