private static void RegisterMultiple(ObjectResolver resolver) { resolver.RegisterCollection <IMulti>(new[] { typeof(Multi1), typeof(Multi2), typeof(Multi3), typeof(Multi4) }); resolver.Register <MultipleObject1, MultipleObject1>(); resolver.Register <MultipleObject2, MultipleObject2>(); resolver.Register <MultipleObject3, MultipleObject3>(); }
#pragma warning disable HAA0101 // rare call, don't account for params allocation public IContainer <TState> Register(Type @interface, Type impl) { var registeredType = @interface; if (typeof(SystemBase <TState>).IsAssignableFrom(impl)) { _resolver.Register(Lifestyle.Singleton, @interface, impl); _registeredSystems.Add(@interface); } else if (typeof(IComponentCollectionStorage).IsAssignableFrom(impl)) { var storeInterface = impl.GetInterfaces() .FirstOrDefault( t => t.GetGenericTypeDefinition() == typeof(IComponentCollection <>)); if (storeInterface == null) { throw new ArgumentException( "Object implements IComponentCollectionStorage but not IComponentCollection<T>"); } var componentType = storeInterface.GetGenericArguments()[0]; registeredType = typeof(IComponentCollection <>).MakeGenericType(componentType); _resolver.Register(Lifestyle.Singleton, registeredType, impl); _registeredComponents.Add(componentType); } else { _resolver.Register(Lifestyle.Singleton, @interface, impl); } _registeredTypes.Add(registeredType); return(this); }
private static void RegisterDummies(ObjectResolver resolver) { resolver.Register <IDummyOne, DummyOne>(); resolver.Register <IDummyTwo, DummyTwo>(); resolver.Register <IDummyThree, DummyThree>(); resolver.Register <IDummyFour, DummyFour>(); resolver.Register <IDummyFive, DummyFive>(); resolver.Register <IDummySix, DummySix>(); resolver.Register <IDummySeven, DummySeven>(); resolver.Register <IDummyEight, DummyEight>(); resolver.Register <IDummyNine, DummyNine>(); resolver.Register <IDummyTen, DummyTen>(); }
private static void RegisterSimple(ObjectResolver r) { r.Register <ISimple1, Simple1>(); r.Register <ISimple2, Simple2>(); r.Register <ISimple3, Simple3>(); r.Register <ISimple4, Simple4>(); r.Register <ISimple5, Simple5>(); r.Register <ISimple6, Simple6>(); r.Register <ISimple7, Simple7>(); r.Register <ISimple8, Simple8>(); r.Register <ISimple9, Simple9>(); r.Register <ISimple10, Simple10>(); }
public void Setup() { _kernel = ObjectResolver.Create(); _kernel.Register <IA, A>(Lifestyle.Transient); _kernel.Register <IB, B>(Lifestyle.Transient); _kernel.Register <IC, C>(Lifestyle.Transient); _kernel.Compile(); _kernel.Resolve <IA>(); _kernel.Resolve <IB>(); _kernel.Resolve <IC>(); }
private static void RegisterMultiple(ObjectResolver resolver) { resolver.RegisterCollection <ISimpleAdapter>(new[] { typeof(SimpleAdapterOne), typeof(SimpleAdapterTwo), typeof(SimpleAdapterThree), typeof(SimpleAdapterFour), typeof(SimpleAdapterFive) }); resolver.Register <ImportMultiple1, ImportMultiple1>(); resolver.Register <ImportMultiple2, ImportMultiple2>(); resolver.Register <ImportMultiple3, ImportMultiple3>(); }
public void Setup() { _kernel = ObjectResolver.Create(); _kernel.Register <IA, A>(Lifestyle.Singleton); _kernel.Register <IB, B>(Lifestyle.Singleton); _kernel.Register <IC, C>(Lifestyle.Singleton); _kernel.Compile(); _kernel.Resolve(typeof(IA)); _kernel.Resolve(typeof(IB)); _kernel.Resolve(typeof(IC)); }
private static void RegisterPropertyInjection(ObjectResolver resolver) { resolver.Register <IServiceA, ServiceA>(Lifestyle.Singleton); resolver.Register <IServiceB, ServiceB>(Lifestyle.Singleton); resolver.Register <IServiceC, ServiceC>(Lifestyle.Singleton); resolver.Register <ISubObjectA, SubObjectA>(); resolver.Register <ISubObjectB, SubObjectB>(); resolver.Register <ISubObjectC, SubObjectC>(); resolver.Register <IComplexPropertyObject1, ComplexPropertyObject1>(); resolver.Register <IComplexPropertyObject2, ComplexPropertyObject2>(); resolver.Register <IComplexPropertyObject3, ComplexPropertyObject3>(); }
private static void RegisterComplex(ObjectResolver resolver) { resolver.Register <IFirstService, FirstService>(Lifestyle.Singleton); resolver.Register <ISecondService, SecondService>(Lifestyle.Singleton); resolver.Register <IThirdService, ThirdService>(Lifestyle.Singleton); resolver.Register <ISubObjectOne, SubObjectOne>(); resolver.Register <ISubObjectTwo, SubObjectTwo>(); resolver.Register <ISubObjectThree, SubObjectThree>(); resolver.Register <IComplex1, Complex1>(); resolver.Register <IComplex2, Complex2>(); resolver.Register <IComplex3, Complex3>(); }
private static void RegisterStandard(ObjectResolver resolver) { resolver.Register <ISingleton1, Singleton1>(Lifestyle.Singleton); resolver.Register <ISingleton2, Singleton2>(Lifestyle.Singleton); resolver.Register <ISingleton3, Singleton3>(Lifestyle.Singleton); resolver.Register <ITransient1, Transient1>(); resolver.Register <ITransient2, Transient2>(); resolver.Register <ITransient3, Transient3>(); resolver.Register <ICombined1, Combined1>(); resolver.Register <ICombined2, Combined2>(); resolver.Register <ICombined3, Combined3>(); }
private static void RegisterPropertyInjection(ObjectResolver r) { r.Register <IPropertyService1, PropertyService1>(Lifestyle.Singleton); r.Register <IPropertyService2, PropertyService2>(Lifestyle.Singleton); r.Register <IPropertyService3, PropertyService3>(Lifestyle.Singleton); r.Register <IStrategy1, Strategy1>(); r.Register <IStrategy2, Strategy2>(); r.Register <IStrategy3, Strategy3>(); r.Register <ICompositeProperyObject1, CompositeProperyObject1>(); r.Register <ICompositeProperyObject2, CompositeProperyObject2>(); r.Register <ICompositeProperyObject3, CompositeProperyObject3>(); }
private static void RegisterComplexObject(ObjectResolver r) { r.Register <IBasicService1, BasicService1>(Lifestyle.Singleton); r.Register <IBasicService2, BasicService2>(Lifestyle.Singleton); r.Register <IBasicService3, BasicService3>(Lifestyle.Singleton); r.Register <INestedService1, NestedService1>(); r.Register <INestedService2, NestedService2>(); r.Register <INestedService3, NestedService3>(); r.Register <IConvolutedService1, ConvolutedService1>(); r.Register <IConvolutedService2, ConvolutedService2>(); r.Register <IConvolutedService3, ConvolutedService3>(); }
public static void Bind(ObjectResolver container) { #region bind code container.Register <IInterface0, Class0>(Lifestyle.Singleton); container.Register <IInterface1, Class1>(Lifestyle.Singleton); container.Register <IInterface2, Class2>(Lifestyle.Singleton); container.Register <IInterface3, Class3>(Lifestyle.Singleton); container.Register <IInterface4, Class4>(Lifestyle.Singleton); container.Register <IInterface5, Class5>(Lifestyle.Singleton); container.Register <IInterface6, Class6>(Lifestyle.Singleton); container.Register <IInterface7, Class7>(Lifestyle.Singleton); container.Register <IInterface8, Class8>(Lifestyle.Singleton); container.Register <IInterface9, Class9>(Lifestyle.Singleton); container.Register <IInterface10, Class10>(Lifestyle.Singleton); container.Register <IInterface11, Class11>(Lifestyle.Singleton); container.Register <IInterface12, Class12>(Lifestyle.Singleton); container.Register <IInterface13, Class13>(Lifestyle.Singleton); container.Register <IInterface14, Class14>(Lifestyle.Singleton); container.Register <IInterface15, Class15>(Lifestyle.Singleton); container.Register <IInterface16, Class16>(Lifestyle.Singleton); container.Register <IInterface17, Class17>(Lifestyle.Singleton); container.Register <IInterface18, Class18>(Lifestyle.Singleton); container.Register <IInterface19, Class19>(Lifestyle.Singleton); container.Register <IInterface20, Class20>(Lifestyle.Singleton); container.Register <IInterface21, Class21>(Lifestyle.Singleton); container.Register <IInterface22, Class22>(Lifestyle.Singleton); container.Register <IInterface23, Class23>(Lifestyle.Singleton); container.Register <IInterface24, Class24>(Lifestyle.Singleton); container.Register <IInterface25, Class25>(Lifestyle.Singleton); container.Register <IInterface26, Class26>(Lifestyle.Singleton); container.Register <IInterface27, Class27>(Lifestyle.Singleton); container.Register <IInterface28, Class28>(Lifestyle.Singleton); container.Register <IInterface29, Class29>(Lifestyle.Singleton); container.Register <IInterface30, Class30>(Lifestyle.Singleton); container.Register <IInterface31, Class31>(Lifestyle.Singleton); container.Register <IInterface32, Class32>(Lifestyle.Singleton); container.Register <IInterface33, Class33>(Lifestyle.Singleton); container.Register <IInterface34, Class34>(Lifestyle.Singleton); container.Register <IInterface35, Class35>(Lifestyle.Singleton); container.Register <IInterface36, Class36>(Lifestyle.Singleton); container.Register <IInterface37, Class37>(Lifestyle.Singleton); container.Register <IInterface38, Class38>(Lifestyle.Singleton); container.Register <IInterface39, Class39>(Lifestyle.Singleton); container.Register <IInterface40, Class40>(Lifestyle.Singleton); container.Register <IInterface41, Class41>(Lifestyle.Singleton); container.Register <IInterface42, Class42>(Lifestyle.Singleton); container.Register <IInterface43, Class43>(Lifestyle.Singleton); container.Register <IInterface44, Class44>(Lifestyle.Singleton); container.Register <IInterface45, Class45>(Lifestyle.Singleton); container.Register <IInterface46, Class46>(Lifestyle.Singleton); container.Register <IInterface47, Class47>(Lifestyle.Singleton); container.Register <IInterface48, Class48>(Lifestyle.Singleton); container.Register <IInterface49, Class49>(Lifestyle.Singleton); ; #endregion }