Automated Dependency Injector

버전 1.0.0.0 (15.1 KB) 작성자: Florian Schwaiger
Automated dependency injector class that works by inspecting constructor arguments.
다운로드 수: 31
업데이트 날짜: 2018/6/22

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.

인용 양식

Florian Schwaiger (2024). Automated Dependency Injector (https://github.com/fschwaiger/matlab-dependency-injector), GitHub. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2009a
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Construct and Work with Object Arrays에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

example/+basic

example/+cascade

example/+direct

example/+interface

example/+provider

example/+singleton

example/+varargs

example/no_namespace

test

GitHub 디폴트 브랜치를 사용하는 버전은 다운로드할 수 없음

버전 게시됨 릴리스 정보
1.0.0.0

- updated description

이 GitHub 애드온의 문제를 보거나 보고하려면 GitHub 리포지토리로 가십시오.
이 GitHub 애드온의 문제를 보거나 보고하려면 GitHub 리포지토리로 가십시오.