![]() | Force-FrameworkMark Brennand |
| Description | Class defining the external Dependency API. Dependencies can be injected into an application by their interface or abstract class. Variable and member variable values can also be injected into a class using the variable's class and an action. An optional action argument is supported to allow for the binding of the same interface or class with different implementations. By default, the implementation created when injected will be a singleton. If the binding is required to create a new implementation for each use an application, the implementing class should implement the Prototype interface. If no binding is found and a class named by the interface or class to be injected with Factory appended to it exists, then this class is injected into the registry. The Factory class must implement the TypesV1.Factory interface. If not, an exception is thrown. All bound Types are stored in a registry. Each bound Type must have a BindingCheck implementation associated with it. To associate the Type with the BindingCheck, create and deploy a BindingCheck__mdt metadata record. Any attempt to add a binding to the registry for a Type with no associated BindingCheck will throw an Exception. See README for full details of the Dependency Injection API. Copyright (c) 2025 Mark Brennand, released under MIT License. |
|---|---|
| Author | Mark Brennand |
| Description | Adds a binding to the registry. |
|---|---|
| Parameter | forType: The type to be bound. Must be either an interface or abstract class. |
| Parameter | withImpl: The implementation for the type and action. Must be a concrete class with a no-op constructor. |
| Description | Adds a binding to the registry. |
|---|---|
| Parameter | forType: The type to be bound. Must be either an interface or abstract class. |
| Parameter | action: The action used in combination with the type to uniquely identify the binding. |
| Parameter | withImpl: The implementation for the type and action. Must be a concrete class with a no-op constructor. |
| Description | If the registry contains a binding for the given type, its implementation is returned. Should no binding exist, an exception is thrown. |
|---|---|
| Parameter | forType: The type to be bound. |
| Returns | The implementation of the given type. |
| Description | If the registry contains a binding for the given type and action, its implementation is returned. Should no binding exist, an exception is thrown. |
|---|---|
| Parameter | forType: The type to be bound. |
| Parameter | action: The action specific to the binding to be bound. |
| Returns | The implementation of the given type. |
| Description | Creates a validation result representing failure. |
|---|---|
| Parameter | errorMessage: The validation failure error message. |
| Returns | A validation result representing failure. |
| Description | Returns true if registry contains a binding for the given type and action, false if not. |
|---|---|
| Parameter | forType: The type to be checked. |
| Returns | True if binding exists, false if not. |
| Description | Returns true if registry contains a binding for the given type and action, false if not. |
|---|---|
| Parameter | forType: The type to be checked. |
| Parameter | action: The action specific to the binding to be checked. |
| Returns | True if binding exists, false if not. |
| Description | Forces the custom bindings to be reloaded. |
|---|
| Description | Creates a validation result representing success. |
|---|---|
| Returns | A validation result representing success. |
| Description | Return a validation result based on whether the isOfType parameter indicates that the implementation is of the required type. |
|---|---|
| Parameter | isOfType: True if the implementation is of the required type. |
| Parameter | isForTypeAnInterface: True if the required type is an interface. |
| Parameter | forType: The type the implementation is expected to be of. |
| Parameter | withImpl: The type of the implementation. |
| Returns | The validation result. |
| Description | Exception thrown when a dependency injection operation fails. |
|---|
| Description | A class implementing this interface will have a new instance of itself created each time it is in injected into an application. |
|---|
| Description | Result of a binding validation check. |
|---|
| Description | Returns the error message for a failed validation. |
|---|---|
| Returns | The error message. |
| Description | Is the result of the validation success. |
|---|---|
| Returns | True if success, false if not. |
| Description | Interface to be implemented to check a binding in the registry. Each checker must be defined in a record in the Binding Check custom metadata. |
|---|
| Description | Given a type to be bound, a class implementing this method must check that the given implementation class can be bound to it. If the for type is an interface then an implementation of this method must check that the implementation class implements the interface. If the for type is an abstract class then an implementation of this method must check that the implementation class extends the abstract class. If the for type is a class then an implementation of this method must check that the implementation class is of the same class or a super class of it. |
|---|---|
| Parameter | forType: The type to be bound. |
| Parameter | withImpl: The implementation to bind to the type. |
| Returns | The result of the validation. |