1 /** 2 Aedi, a dependency injection library. 3 4 Aedi is a dependency injection library. It does provide a set of containers that do 5 IoC, and an interface to configure application components (structs, objects, etc.) 6 7 $(BIG $(B Aim: )) 8 9 The aim of library is to provide a dependency injection solution that is 10 feature rich, easy to use, easy to learn, and easy to extend up to your needs. 11 12 $(BIG $(B Why should it be used: )) 13 $(UL 14 $(LI Decouples components in your application. ) 15 $(LI Decreases hassle with application components setup (wiring and creation) ) 16 $(LI Increases code reusability (since no dependencies are created in dependent objects.) ) 17 $(LI Allows easier to test code that is dependent on other components ) 18 $(LI Eases the implementation single responsibility principle in components ) 19 ) 20 21 $(BIG $(B When should it be used: )) 22 $(UL 23 $(LI When an application has to be highly configurable. ) 24 $(LI When an application has a high number of interdependent components. ) 25 $(LI When doing unit testing of highly dependent components. ) 26 ) 27 28 $(BIG $(B How should it be used: )) 29 30 It's simple: 31 32 $(UL 33 $(LI Create a container ) 34 $(LI Register an application component. Any data (struct, object, union, etc) is treated as application component. ) 35 $(LI Write a wiring configuration ) 36 $(LI Repeat process for other components. ) 37 $(LI Boot container ) 38 ) 39 40 First of all a container should be created: 41 --------------- 42 SingletonContainer container = new SingletonContainer; 43 --------------- 44 45 Container is responsible for storing, and managing application's components. 46 47 Next, register component into container: 48 --------------- 49 container.register!Color 50 --------------- 51 52 Component is registered by calling .register method on container with type of component. 53 Note, that in example we do not end the statement. That's because component should be 54 configured next: 55 --------------- 56 .set!"r"(cast(ubyte) 250) 57 .set!"g"(cast(ubyte) 210) 58 .set!"b"(cast(ubyte) 255); 59 --------------- 60 61 .set method configures component properties to specific values (setter injection in other words). 62 Note the example ends in `;` which means that it's end of statement and Color registration/configuration. 63 Once components are registered and configured, container needs to be booted (instantiated): 64 --------------- 65 container.instantiate(); 66 --------------- 67 68 Container during boot operation, will do various stuff, including creation and wiring of components 69 between them. It's important to call `container.instantiate()` after all application's components 70 have been registered into container, otherwise it is not guaranteed that application will work correctly. 71 72 Once container is booted, components in it are available for use. 73 To fetch it use locate method like in following example: 74 --------------- 75 container.locate!Color.writeln; 76 --------------- 77 78 Try running the minimal example from examples folder, the output of example will 79 be the Color that was registered in container: 80 --------------- 81 Color is: Color(250, 210, 255) 82 --------------- 83 84 License: 85 Boost Software License - Version 1.0 - August 17th, 2003 86 87 Permission is hereby granted, free of charge, to any person or organization 88 obtaining a copy of the software and accompanying documentation covered by 89 this license (the "Software") to use, reproduce, display, distribute, 90 execute, and transmit the Software, and to prepare derivative works of the 91 Software, and to permit third-parties to whom the Software is furnished to 92 do so, all subject to the following: 93 94 The copyright notices in the Software and this entire statement, including 95 the above license grant, this restriction and the following disclaimer, 96 must be included in all copies of the Software, in whole or in part, and 97 all derivative works of the Software, unless such copies or derivative 98 works are solely in the form of machine-executable object code generated by 99 a source language processor. 100 101 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 102 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 103 FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 104 SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 105 FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 106 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 107 DEALINGS IN THE SOFTWARE. 108 109 Authors: 110 Alexandru Ermicioi 111 **/ 112 module aermicioi.aedi; 113 114 public import aermicioi.aedi.exception; 115 public import aermicioi.aedi.configurer; 116 public import aermicioi.aedi.factory; 117 public import aermicioi.aedi.container; 118 public import aermicioi.aedi.storage;