Automated dependency injector class that works by inspecting constructor arguments.
Ahora está siguiendo esta publicación
- Verá actualizaciones en las notificaciones de contenido en seguimiento.
- Podrá recibir correos electrónicos, en función de las preferencias de comunicación que haya establecido.
Please read the full documentation at https://github.com/fschwaiger/matlab-dependency-injector.
This class automates the wiring of dependencies that are exposed in class constructors. It inspects the constructor argument names and finds appropriate dependencies via lookup files that you can define with each package. At any time, you can override dependencies, as shown in the example below.
% file +package/MyClass.m
classdef MyClass < handle
methods
function MyClass(firstDep, secondDep)
....
end
end
end
% file +package/InjectorConfig.m
classdef (Abstract, Hidden) InjectorConfig
properties (Constant)
firstDep = 'FirstDependencyClass'
end
methods (Static)
function value = secondDep()
value = 42;
end
end
end
% file application.m
instance = Injector().get(?package.MyClass);
% file unittest.m
firstDep = Mock(?package.FirstDependencyClass)
instance = Injector(firstDep).get(?package.MyClass);
Installation is really simple, you only need to copy a single file (Injector.m) to your project.
This class has been tested using newer versions of Matlab only (R2014b+), but it uses mostly standard tools that should be backwards compatible till R2009a. Please, if you find compatibility issues, notify me.
Citar como
Florian Schwaiger (2026). Automated Dependency Injector (https://github.com/fschwaiger/matlab-dependency-injector), GitHub. Recuperado .
Categorías
Más información sobre Construct and Work with Object Arrays en Help Center y MATLAB Answers.
Información general
- Versión 1.0.0.0 (15,1 KB)
-
Ver licencia en GitHub
Compatibilidad con la versión de MATLAB
- Compatible con cualquier versión
Compatibilidad con las plataformas
- Windows
- macOS
- Linux
No se pueden descargar versiones que utilicen la rama predeterminada de GitHub
| Versión | Publicado | Notas de la versión | Action |
|---|---|---|---|
| 1.0.0.0 | - updated description |
