Esempio n. 1
0
        public void cannot_resolve_concrete_types_not_registered()
        {
            var sut = new IocContainer();

            sut.CanResolve <ConcreteObjectWithOneConcreteConstructor>().ShouldBe(false);
            sut.CanResolve <Dependency1>().ShouldBe(false);
        }
Esempio n. 2
0
        public void can_register_service_implementation()
        {
            var sut = new IocContainer();

            sut.Register <IDependency1, Dependency1>();
            sut.CanResolve <IDependency1>().ShouldBe(true);
        }
        /// <summary>
        ///     Loads the current module.
        /// </summary>
        protected override bool LoadInternal()
        {
            //NOTE: You can use the custom extension methods in bindings.
            BindingServiceProvider
            .ResourceResolver
            .AddType(typeof(CustomExtensionMethods).Name, typeof(CustomExtensionMethods));

            if (Mode == LoadMode.Design)
            {
                var localizationManager = new LocalizationManager();
                if (IocContainer != null)
                {
                    IocContainer.BindToConstant <ILocalizationManager>(localizationManager);
                }
            }
            else
            {
                if (!IocContainer.CanResolve <ILocalizationManager>())
                {
                    IocContainer.Bind <ILocalizationManager, LocalizationManager>(DependencyLifecycle.SingleInstance);
                }
            }

            if (IocContainer != null)
            {
                IocContainer.Bind <IResourceMonitor, ResourceMonitor>(DependencyLifecycle.SingleInstance);
            }
            return(true);
        }
        /// <summary>
        ///     Initializes the current bootstraper.
        /// </summary>
        protected virtual void OnInitialize()
        {
            LoadModules();
            IViewModelSettings settings = CreateViewModelSettings();

            if (!IocContainer.CanResolve <IViewModelSettings>())
            {
                IocContainer.BindToConstant(settings);
            }
            ServiceProvider.Initialize(IocContainer, Platform);
        }
Esempio n. 5
0
 /// <summary>
 ///     Initializes the current unit-test.
 /// </summary>
 protected void Initialize([NotNull] IIocContainer iocContainer, PlatformInfo platform, params IModule[] modules)
 {
     Should.NotBeNull(iocContainer, "iocContainer");
     ServiceProvider.DesignTimeManager = new DesignTimeManagerImpl(platform);
     if (modules != null)
     {
         CreateModuleContext(iocContainer).LoadModules(modules);
     }
     _iocContainer = iocContainer;
     if (ViewModelProvider == null)
     {
         ViewModelProvider = IocContainer.CanResolve <IViewModelProvider>()
             ? IocContainer.Get <IViewModelProvider>()
             : new ViewModelProvider(IocContainer);
     }
     ServiceProvider.Initialize(iocContainer, platform ?? PlatformInfo.UnitTest);
 }
Esempio n. 6
0
 public bool CanResolve <T>() where T : class
 {
     return(_container.CanResolve <T>());
 }
Esempio n. 7
0
        public void cannot_resolve_service_implementations_that_are_not_registered()
        {
            var sut = new IocContainer();

            sut.CanResolve <ConcreteObjectWithOneInterfaceConstructor>().ShouldBe(false);
        }
Esempio n. 8
0
 public bool CanResolve(Type service, string name = null)
 {
     return(IocContainer.CanResolve(service, name));
 }
Esempio n. 9
0
 public bool CanResolve <TType>() where TType : class
 {
     return(_baseContainer.CanResolve <TType>());
 }
Esempio n. 10
0
 // enumerate
 public bool HasRegistered <TService>()
 {
     return(_container.CanResolve(null, typeof(TService)));
 }