The small library for configuring the depedency injector design pattern
Project description
Library for creating Dependency Injection Pattern
Usage
from nttinjector import dependency_inject, Injector
class Model:
count = 0
def __init__(self, strName: str = "") -> None:
self._strName = strName
self.CreateNewModel()
def __repr__(self) -> str:
return f"<Model name=\"{self._strName}\" />"
@classmethod
def CreateNewModel(cls):
cls.count += 1
@classmethod
def GetModelInstances(cls):
return cls.count
@dependency_inject(Model)
class ViewModel:
count = 0
def __init__(self, mModel: Model, strName: str = "") -> None:
self._mModel = mModel
self._strName = strName
self.CreateNewModel()
@classmethod
def CreateNewModel(cls):
cls.count += 1
@classmethod
def GetModelInstances(cls):
return cls.count
def __repr__(self) -> str:
return f"<ViewModel name=\"{self._strName}\" />"
@dependency_inject(ViewModel, Model)
class View:
def __init__(self, viewModel: ViewModel, mModel: Model, strName: str = "") -> None:
self._viewModel = viewModel
self._model = mModel
self._strName = strName
def __repr__(self) -> str:
return f"<View name=\"{self._strName}\" />"
Then use the View as normal
view = View()
print(view._model)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ntt-injector-1.1.0.tar.gz
(2.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ntt-injector-1.1.0.tar.gz.
File metadata
- Download URL: ntt-injector-1.1.0.tar.gz
- Upload date:
- Size: 2.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e58653fd832f47ce50e4ab6b1bc472b2e6871cb61629025d4dda81efe2f9c52f
|
|
| MD5 |
cf44374eb8a1eae0f3decce34ab2fbc3
|
|
| BLAKE2b-256 |
fa69e84ad4af2d5a5b41da032a2d2b5b966521ead774cc2b7aabd5cef98711d8
|
File details
Details for the file ntt_injector-1.1.0-py3-none-any.whl.
File metadata
- Download URL: ntt_injector-1.1.0-py3-none-any.whl
- Upload date:
- Size: 3.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0fb757968869e6009a1ddce0bad74d8be551d7639cccb59d4f8649f1ede81e38
|
|
| MD5 |
4208a691d7b6941617b24329315bd6e3
|
|
| BLAKE2b-256 |
f485f9d6fb98429d4aece9641be11bc7fbad92a986a06e3960e48d7a49992fec
|