anyioc-0.9.1
توضیحات
Another simple ioc framework for python
| ویژگی | مقدار |
|---|---|
| سیستم عامل | - |
| نام فایل | anyioc-0.9.1 |
| نام | anyioc |
| نسخه کتابخانه | 0.9.1 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Cologler |
| ایمیل نویسنده | skyoflw@gmail.com |
| آدرس صفحه اصلی | - |
| آدرس اینترنتی | https://pypi.org/project/anyioc/ |
| مجوز | MIT |
# anyioc

[](https://github.com/Cologler/anyioc-python/actions/workflows/main.yml)
[](https://pypi.org/project/anyioc/)

Another simple ioc framework for python.
## Usage
``` py
from anyioc import ServiceProvider
provider = ServiceProvider()
provider.register_singleton('the key', lambda ioc: 102) # ioc will be a `IServiceProvider`
value = provider.get('the key')
assert value == 102
```
## Register and resolve
By default, you can use following methods to register services:
- `ServiceProvider.register_singleton(key, factory)`
- `ServiceProvider.register_scoped(key, factory)`
- `ServiceProvider.register_transient(key, factory)`
- `ServiceProvider.register(key, factory, lifetime)`
- `ServiceProvider.register_value(key, value)`
- `ServiceProvider.register_group(key, keys)`
- `ServiceProvider.register_bind(new_key, target_key)`
And use following methods to resolve services:
- `ServiceProvider.__getitem__(key)`
- `ServiceProvider.get(key)`
- `ServiceProvider.get_many(key)`
*`get` return `None` if the service was not found, but `__getitem__` will raise a `ServiceNotFoundError`.*
Read full [documentation](https://github.com/Cologler/anyioc-python/wiki).
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.8,<4.0 | Python |
نحوه نصب
نصب پکیج whl anyioc-0.9.1:
pip install anyioc-0.9.1.whl
نصب پکیج tar.gz anyioc-0.9.1:
pip install anyioc-0.9.1.tar.gz