1 /** 2 License: 3 Boost Software License - Version 1.0 - August 17th, 2003 4 5 Permission is hereby granted, free of charge, to any person or organization 6 obtaining a copy of the software and accompanying documentation covered by 7 this license (the "Software") to use, reproduce, display, distribute, 8 execute, and transmit the Software, and to prepare derivative works of the 9 Software, and to permit third-parties to whom the Software is furnished to 10 do so, all subject to the following: 11 12 The copyright notices in the Software and this entire statement, including 13 the above license grant, this restriction and the following disclaimer, 14 must be included in all copies of the Software, in whole or in part, and 15 all derivative works of the Software, unless such copies or derivative 16 works are solely in the form of machine-executable object code generated by 17 a source language processor. 18 19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 22 SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 23 FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 24 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 25 DEALINGS IN THE SOFTWARE. 26 27 Authors: 28 aermicioi 29 **/ 30 module aermicioi.aedi_property_reader.core.config; 31 32 import aermicioi.aedi.configurer.annotation.annotation; 33 import aermicioi.aedi_property_reader.convertor.chaining_convertor; 34 import aermicioi.aedi_property_reader.convertor.convertor; 35 import std.typecons : Yes, No; 36 37 @component 38 auto force() { 39 return Yes.force; 40 } 41 42 @component 43 auto conversion() { 44 return Yes.conversion; 45 } 46 47 @component 48 auto skip() { 49 return Yes.skip; 50 } 51 52 @component 53 @qualifier!Convertor 54 auto defaultConvertor(PricingStrategy strategy) { 55 import aermicioi.aedi_property_reader.convertor.chaining_convertor; 56 return new ChainingConvertor(strategy); 57 } 58 59 @component 60 @qualifier!PricingStrategy 61 auto pricingStrategy( 62 DefaultPricingStrategy first, 63 NumericPricingStrategy second, 64 IdenticalTypePriceStrategy third, 65 ByTypePricingStrategy fourth 66 ) { 67 return new MinimalBidPricingStrategy( 68 first, 69 second, 70 third, 71 fourth 72 ); 73 } 74 75 @component 76 auto defaultPricingStrategy(@qualifier("pricing_strategy.default.price") size_t price = 1000) { 77 return new DefaultPricingStrategy(price); 78 } 79 80 @component 81 auto numericPricingStrategy() { 82 return new NumericPricingStrategy(); 83 } 84 85 @component 86 auto identicalTypePriceStrategy() { 87 return new IdenticalTypePriceStrategy(); 88 } 89 90 @component 91 auto byTypePricingStrategy() { 92 return new ByTypePricingStrategy(); 93 } 94 95 @component 96 auto stringGuesser() { 97 import aermicioi.aedi_property_reader.convertor.type_guesser : StdConvTypeGuesser; 98 import aermicioi.aedi_property_reader.convertor.convertor : DefaultConvertibleTypes; 99 return new StdConvTypeGuesser!(string, DefaultConvertibleTypes); 100 } 101 102 @component 103 auto stringMapInspector() { 104 import aermicioi.aedi_property_reader.convertor.inspector : AssociativeArrayInspector; 105 return new AssociativeArrayInspector!string; 106 } 107 108 // import std.traits; 109 // import aermicioi.aedi_property_reader.convertor.inspector : Inspector; 110 111 // debug pragma(msg, ReturnType!stringMapInspector, is(ReturnType!stringMapInspector : Inspector!(string[string], string))); 112 // static if (is(ReturnType!stringMapInspector : Inspector!(C, W), C, W)) { 113 // debug pragma(msg, C, " key ", W); 114 // } 115 116 @component 117 auto stringMapSetter() { 118 import aermicioi.aedi_property_reader.convertor.setter : AssociativeArraySetter; 119 return new AssociativeArraySetter!string; 120 }