1 module hunt.imf.utils.element; 2 import hunt.imf.io.context; 3 4 class Element 5 { 6 this(Context context) 7 { 8 _context = context; 9 } 10 11 Context context() @property 12 { 13 return _context; 14 } 15 16 private: 17 Context _context; 18 19 } 20 21 22 23 unittest 24 { 25 class E1 : Element 26 { 27 this(Context context) 28 { 29 super(context); 30 } 31 } 32 33 class E2 : E1 34 { 35 this(Context context) 36 { 37 super(context); 38 } 39 } 40 41 import hunt.imf.utils.room; 42 import hunt.imf.utils.singleton; 43 auto room = new Room!(size_t , Element)(); 44 auto room1 = new Room!(size_t , E1)(); 45 auto room2 = new Room!(size_t , E2)(); 46 47 import std.stdio; 48 void test(string[] arg...) 49 { 50 51 writeln(arg.length); 52 } 53 54 writeln(Singleton!(Room!(size_t , Element)).instance().length); 55 56 test("test"); 57 test(["test"]); 58 }