lemoer / di Goto Github PK
View Code? Open in Web Editor NEWA simple Python DependencyInjection-System
License: MIT License
A simple Python DependencyInjection-System
License: MIT License
It would be cool to have a function that provides one or more features in the dependency tree. It should be able to use wildcards. Something like this:
di.implements(ConfigProvider, "Config/*")
When a feature e.g. "Config/ServerIP"
is needed for an injection, the di module should ask the Provider
to return this feature. So the Provider
has the possibilty to create the feature, do some setup on it and return it.
(This function could also used for creating a mocking function)
Maybe I should add a check if there is an existing implementation for the module and throw an specific exception relevated to this.
A real tree structure should be used. There should be two ways to access/manipulate the child elements: python indexes with fast access node["Options/Test"]
and properties node.Options.Test
. Changes should not be allowed.
A Node should have:
Leafs should be like Providers. Possibilities:
In the main tree structure should be only Providers. If a Feature get's accessed the di library searches for a provider that implements it.
From outside the library it should not be possible to access a leaf. You should always get the Feature provided by the Provider
User's of the library should never change the features directly. Every changes should be done by calling method's or function.
Every Feature should have a Provider. A provider can have a subnode tree, where it is provides features. So a Provider can have multiple Features (1:N). When a Feature shoud get injected the Provider should decide wheter to give the Feature or not. So the Feature structure can be dynamic and isn't known at the application start. That would be a very flexible, but not the easiest way.
Service Providers should convert the Service (A) in a Node. So if an other Service or Controller (B) needs a single function from (A), it just needs to require this single function. So the function is it's own Feature and can be mocked a lot easier.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.