protected override void Assemble(Assembler assembler) { assembler.NewService().AsFunctionAggregator <Type, TestFunction>() .MapServiceMethodToFunctionMethod( typeof(TestFunctionServiceSPI).LoadMethodWithParamTypesOrThrow("Validate", new Type[] { typeof(TestData1), typeof(TestData2), typeof(IDictionary <TestData1, Result>) }), typeof(TestFunction).LoadMethodOrThrow("Validate", null), FunctionAssemblerUtils.TypeBasedFunctionLookUp(1), args => new Object[] { args[2] }, null, null ).MapServiceMethodToFunctionMethod( typeof(TestFunctionServiceSPI).LoadMethodWithParamTypesOrThrow("Validate", new Type[] { typeof(TestData1), typeof(TestData3), typeof(IDictionary <TestData1, Result>) }), typeof(TestFunction).LoadMethodOrThrow("Validate", null), FunctionAssemblerUtils.TypeBasedFunctionLookUp(1), args => new Object[] { args[2] }, null, null ).WithDefaultFunctions( Tuple.Create <Type[], Func <StructureServiceProvider, TestFunction> >(new Type[] { typeof(TestData2Impl) }, ssp => ssp.NewPlainCompositeBuilder <TestFunction1Impl>().Instantiate()), Tuple.Create <Type[], Func <StructureServiceProvider, TestFunction> >(new Type[] { typeof(TestData3Impl) }, ssp => ssp.NewPlainCompositeBuilder <TestFunction2Impl>().Instantiate()) ).Done() .WithMixins(typeof(TestFunctionServiceMixin)).Done() .OfTypes(typeof(TestFunctionServiceSPI)); assembler.NewPlainComposite() .OfTypes(typeof(TestData1Impl)); assembler.NewPlainComposite() .OfTypes(typeof(TestData2Impl)); assembler.NewPlainComposite() .OfTypes(typeof(TestData3Impl)); assembler.NewPlainComposite() .OfTypes(typeof(TestFunction1Impl)); assembler.NewPlainComposite() .OfTypes(typeof(TestFunction2Impl)); }
protected override void Assemble(Qi4CS.Core.Bootstrap.Assembling.Assembler assembler) { assembler.NewService().AsFunctionAggregator <Type, TestFunction>() .WithFunctionType( FunctionAssemblerUtils.TypeBasedFunctionLookUp(0) ) .WithDefaultFunctions( Tuple.Create <Type[], Func <StructureServiceProvider, TestFunction> >(new Type[] { typeof(MyData) }, ssp => ssp.NewPlainCompositeBuilder <MyFunction>().Instantiate()) ).Done() .OfTypes(typeof(TestService)); assembler.NewPlainComposite().OfTypes(typeof(MyData)); assembler.NewPlainComposite().OfTypes(typeof(MyFunction)); }
private void Dummy(Assembler assembler) { #region FunctionAggregatorDeclarationCode2 // Assume 'assembler' is variable of type Qi4CS.Core.Bootstrap.Assembling.Assembler assembler .NewService() .AsFunctionAggregator <Type, MyFunctionality>() // Specify that Type is used as key type when deciding which aggregated object to use. See extension method of E_Qi4CS_Functional in this assembly for more information. .WithFunctionType(FunctionAssemblerUtils.TypeBasedFunctionLookUp(0)) // FunctionAssemblerUtils is utility class in this namespace, and this method returns lambda to extract a type using Object.GetType() method from parameter at index 0 of method arguments .WithDefaultFunctions( // Add information about FunctionalityForType : only one key which is type of System.Type, and creation process instantiates FunctionalityForType as Qi4CS composite Tuple.Create <Type[], Func <StructureServiceProvider, MyFunctionality> >(new Type[] { typeof(Type) }, ssp => ssp.NewPlainCompositeBuilder <FunctionalityForType>().Instantiate()), // Add information about FunctionalityForString : only one key which is type of System.String, and creation process instantiates FunctionalityForString as Qi4CS composite Tuple.Create <Type[], Func <StructureServiceProvider, MyFunctionality> >(new Type[] { typeof(String) }, ssp => ssp.NewPlainCompositeBuilder <FunctionalityForString>().Instantiate()) ) .Done(); // No need to do assembler.OfTypes( typeof( MyFunctionality ) ) - "WithFunctionType" method already did that. // Remember add composites being aggregated // This is not required if FunctionalityForType and FunctionalityForString are not composites but rather normal C# objects. assembler.NewPlainComposite().OfTypes(typeof(FunctionalityForType)); assembler.NewPlainComposite().OfTypes(typeof(FunctionalityForString)); #endregion }