문제

Is it possible to inject method using parsley framework in flex application ?

I am able to inject the class itself but is it possible for method to be injected.

올바른 솔루션이 없습니다

다른 팁

You can place [Inject] metadata tags on any number of methods:

package com.bookstore.actions 
{

class LoginAction 
    {
    private var service:LoginService;
    private var manager:UserManager;

    [Inject]
    public function init (service:LoginService, manager:UserManager = null) : void        
        {
        this.service = service;
        this.manager = manager;    
        }

    }
}

As with Constructor Injection Parsley will recognize whether a method parameter is optional or not and accordingly treat the dependency as optional or required. The object to be injected will be selected by type, so you should make sure to include at most one object with a matching type into your configuration. For Method Injection there are no restrictions on MXML configuration, so in contrast to Constructor Injection you could also use simple MXML tags for adding the objects to the container.

References

Parsley Manual: Method Injection

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top