diff _test/temp.pl @ 417:3ed0c58e9da3 ref20150831

working on di container, tests
author cin
date Mon, 02 Nov 2015 01:56:53 +0300
parents 3d24b10dd0d5
children 3f38dabaf5cc
line wrap: on
line diff
--- a/_test/temp.pl	Thu Oct 29 03:50:25 2015 +0300
+++ b/_test/temp.pl	Mon Nov 02 01:56:53 2015 +0300
@@ -5,9 +5,45 @@
 use Scalar::Util qw(blessed refaddr);
 use YAML::XS qw(Dump);
 
-print Dump {
-	services => [
-	   { role => 'db', type => 'My::Data::Context', params => { '-ref' => 'some-role' } }
+my $t = [gettimeofday];
+
+use IMPL::require {
+	Container => 'IMPL::Config::Container',
+	Service => 'IMPL::Config::ServiceDescriptor',
+	Reference => 'IMPL::Config::ReferenceDescriptor',
+	Value => 'IMPL::Config::ValueDescriptor'
+};
+
+my $c1 = Container->new();
+
+$c1->Register('db', Service->new(
+    type => 'Foo::Data',
+    norequire => 1,
+    activation => 'container'
+) );
+
+$c1->Register(['sec', 'ldap'], Reference->new('db') );
+
+$c1->Register('mixed', Value->new([
+    Reference->new('db'),
+    Reference->new('sec'),
+    Reference->new('ldap')
+]));
+
+my $c2 = Container->new($c1);
+
+my $data = [ $c1->Resolve('mixed')] ;
+
+print "Activated: ",tv_interval($t,[gettimeofday]),"\n";
+
+print Dump($data);
+
+
+package Foo::Data;
+use IMPL::declare {
+	base => [
+	   'IMPL::Object' => undef
 	]
 };
+
 1;