public override void Initialize() { CreatableTypes() .Concat(extra.SelectMany(CreatableTypes)) .EndingWith("Service") .AsInterfaces() .RegisterAsLazySingleton(); Mvx.LazyConstructAndRegisterSingleton <IDalContainer, DalContainer>(); Mvx.LazyConstructAndRegisterSingleton <IConfigReader, ConfigContainer>(); Mvx.LazyConstructAndRegisterSingleton <IConfigContainer, ConfigContainer>(); Mvx.LazyConstructAndRegisterSingleton <ILog, EmptyLogger>(); // Mvx.LazyConstructAndRegisterSingleton<ISlackConnector, FakeSlack>(); // ModelContext is injected on a IMiddleware and has a not-so-DI friendly constructor. Mvx.LazyConstructAndRegisterSingleton(() => Mvx.Resolve <IDalContainer>().Context); using (var ioc = new MvxSimpleIocImprovedCreator(CreatableTypes)) { Compose <IMvxImprovedConfig, IMvxImprovedLocatorConfig, IMvxImprovedRegistry, IMvxSimpleContainer> .NoobotCore(ioc.Registry); } RegisterCustomAppStart <MyNavigationAppStart>(); }
public void TestComposition() { base.Setup(); using (var registryScope = new MvxSimpleIocImprovedCreator(a => a.GetTypes().Where(x => x.GetConstructors().Any()))) { var reg = registryScope.Registry; Root <IMvxImprovedConfig, IMvxImprovedLocatorConfig, IMvxImprovedRegistry, IMvxSimpleContainer> .Compose(reg); } }
public void TestDecoration() { base.Setup(); using (var registryScope = new MvxSimpleIocImprovedCreator(a => a.GetTypes().Where(x => x.GetConstructors().Any()))) { var reg = registryScope.Registry; reg.Register <Irt, rt>(); reg.Register <Irt, decrt>().AsDecorator(); var c = reg.GenerateContainer(); Assert.IsInstanceOf <decrt>(c.Resolve <Irt>()); } }
public void OneFromManyImplimintationRegistrations() { base.Setup(); using (var registryScope = new MvxSimpleIocImprovedCreator(a => a.GetTypes().Where(x => x.GetConstructors().Any()))) { var reg = registryScope.Registry; reg.Register <ITesti, t1>().AsSingleton().AsCollection(); reg.Register <ITesti, t1>().AsSingleton(); reg.Register <t1, t1>().AsSingleton(); var c = reg.GenerateContainer(); Assert.AreSame(c.Resolve <ITesti>(), c.Resolve <t1>()); Assert.AreSame(c.Resolve <ITesti[]>()[0], c.Resolve <t1>()); Assert.AreSame(c.Resolve <ITesti>(), c.Resolve <ITesti[]>()[0]); } }
public void TestCollection() { base.Setup(); using (var registryScope = new MvxSimpleIocImprovedCreator(a => a.GetTypes().Where(x => x.GetConstructors().Any()))) { var reg = registryScope.Registry; reg.Register <ITesti, t1>().AsSingleton().AsCollection(); reg.Register <ITesti, t2>().AsCollection(); reg.Register <ITesti, t3>(); var c = reg.GenerateContainer(); var all = c.Resolve <ITesti[]>(); Assert.AreEqual(2, all.Length); } }