Mercurial > pub > Impl
diff Lib/IMPL/Config/ActivationContext.pm @ 405:cd6c6e61d442 ref20150831
Working on DI container
author | cin |
---|---|
date | Mon, 31 Aug 2015 10:23:42 +0300 |
parents | 9ef75f2029be |
children |
line wrap: on
line diff
--- a/Lib/IMPL/Config/ActivationContext.pm Fri Aug 28 19:54:53 2015 +0300 +++ b/Lib/IMPL/Config/ActivationContext.pm Mon Aug 31 10:23:42 2015 +0300 @@ -1,5 +1,51 @@ package IMPL::Config::ActivationContext; +use IMPL::Const qw(:prop); +use IMPL::Exception(); +use IMPL::declare { + require => { + PropertyBag => 'IMPL::Config::ServicesBag' + }, + base => { + 'IMPL::Object' => '@_' + }, + props => { + _services => PROP_RW, + _cache => PROP_RW, + _stack => PROP_RW + } +}; + +sub GetService { + my ($this,$serviceId) = @_; + + $this->_services-> +} + +sub EnterScope { + my ($this, $name, $localize) = @_; + + my $info = { name => $name }; + + if ($localize) { + $info->{services} = $this->_services; + + $this->_services(PropertyBag->new($this->_services)); + } + + $this->_stack->Push($info); +} + +sub LeaveScope { + my ($this) = @_; + + my $info = $this->_stack->Pop() + or die IMPL::InvalidOperationException(); + + if ($info->{services}) + $this->_services($info->{services}); +} + 1; __END__