mrousavy / Jellyfish

🐟 An incredibly lightweight and type safe MVVM library for .NET WPF, Silverlight, Xamarin and UWP
MIT License
20 stars 3 forks source link

Dependency Injection/Auto-wiring #4

Open mrousavy opened 6 years ago

mrousavy commented 6 years ago

Implement Dependency Injection for interfaces or other properties.

Example:

class LoginModel : Model
{
    [Autowired]
    IDatabase Database { get; }
}

Jellyfish should automatically find the IDatabase implementation (or it is pre-configured before initialization), and initialize the Database { get; } property with that instance. The IDatabase instance is either already initialized somewhere (👍) or initialized by the default constructor (👎)

Example 2:


class LoginModel : Model
{
    IDatabase Database { get; }

    public LoginModel(IDatabase database)
    {
        Database = database;
    }
}
mrousavy commented 6 years ago

Created IInjector, InjectionExtensions, InjectionResolver, Injector ~@ 26fdaa01efb4a7d50e9dc3d9520871fedbcb91a5

Done

To Do

See Dependency Injection 📖