StrangeIOC framework experience

Let’s talk about Binder first. The most common framework for this framework is Binder. It is also a place that many people can’t understand when they first come into contact with it. The Chinese meaning is adhesive. There are several main Binders, they are all inherited from Binder, Binder is actually an advanced table. It stores an object with typeof(T) as the key. It is distinguished by name (usually enumeration) under the same key. , the value exists in the binding.



1. CrossContextInjectionBinder (cross-context injection)

The core meaning is to inject ()


Indicates that the value that has been bound in the injectionBinder with typeof(IInstanceProvider) and typeof(IInectionBinder) as the key is the injectionBinder.

This situation of Binder<>().To<>() indicates the following inactionBinder.GetInstance<>(). The object of GetInstance is the injectionBinder.

How to achieve this?




2. SignalCommandBinder (signal command)

After understanding Binder, it is much simpler to look at SignalCommandBinder. Mainly through the difference to discover his function.




commander.Binder<signal>().To<command>();

Signal.Dispatcher() is command.Execute();

3. MediationBinder

The starting point for all mediators


It is to add a mediator to all views.

mediataionBinder.Bind<view>()To<mediator>().

表示view.gameObject.AddComponent<mediator>().

4, ReflectionBinder (reflection)


It mainly serves the Inject() method of the injector in the injectionBinder. Get(type), is to find all [Inject], [PostConstruct], and ctor.

There is also an ImplicitBinder that doesn't know what it means

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324672867&siteId=291194637