Mercurial > pub > Impl
comparison 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 |
comparison
equal
deleted
inserted
replaced
404:9ef75f2029be | 405:cd6c6e61d442 |
---|---|
1 package IMPL::Config::ActivationContext; | 1 package IMPL::Config::ActivationContext; |
2 | |
3 use IMPL::Const qw(:prop); | |
4 use IMPL::Exception(); | |
5 use IMPL::declare { | |
6 require => { | |
7 PropertyBag => 'IMPL::Config::ServicesBag' | |
8 }, | |
9 base => { | |
10 'IMPL::Object' => '@_' | |
11 }, | |
12 props => { | |
13 _services => PROP_RW, | |
14 _cache => PROP_RW, | |
15 _stack => PROP_RW | |
16 } | |
17 }; | |
18 | |
19 sub GetService { | |
20 my ($this,$serviceId) = @_; | |
21 | |
22 $this->_services-> | |
23 } | |
24 | |
25 sub EnterScope { | |
26 my ($this, $name, $localize) = @_; | |
27 | |
28 my $info = { name => $name }; | |
29 | |
30 if ($localize) { | |
31 $info->{services} = $this->_services; | |
32 | |
33 $this->_services(PropertyBag->new($this->_services)); | |
34 } | |
35 | |
36 $this->_stack->Push($info); | |
37 } | |
38 | |
39 sub LeaveScope { | |
40 my ($this) = @_; | |
41 | |
42 my $info = $this->_stack->Pop() | |
43 or die IMPL::InvalidOperationException(); | |
44 | |
45 if ($info->{services}) | |
46 $this->_services($info->{services}); | |
47 } | |
2 | 48 |
3 1; | 49 1; |
4 __END__ | 50 __END__ |
5 | 51 |
6 =pod | 52 =pod |