Giter Site home page Giter Site logo

wpf.dependencyresolution's Introduction

Wpf.DependencyResolution

Build Status Nuget

The Dependency Resolution Protocol is a protocol used for dependency resolution using events. This protocol was presented at the talk below and ported to WPF by leveraging routed events. This implementation was mainly built to facilitate the use of the Flux pattern in WPF instead of the MVVM pattern.

Building a Complex Application with Web Components and LitElement

This implementation provides extensions that can be used with elements to allow elements to provide dependencies to all their decendants. However, when using this protocol, a dependency injection framework must be supplied and can be adapted to this protocol using the IInjector interface. This protocol allows for dependencies to be staggered through the component tree, which can allow for dependencies to be isolated within certain branches of the tree. However, for simplicity's sake, it's best to start out with a single root element that acts as the IoC container.

Usage

  1. Implement an injector with your favourite Dependency Injection framework by using the IInjector interface.
  2. Call ProvideInstance on the injector in the Root element - ideally in the constructor.
  3. Call RequestInstance on any decendant element to get the dependency.

API

IInjector interface

AddInstance

This method adds an instance to be tracked by the dependency injection framework. This should return the injector to allow for fluent chaining of dependencies when configuring the dependency injection framework.

ResolveInstance

This method returns the instance that matches the generic type provided by the caller.

InstanceProvider extension

ProvideInstance

By calling this method within an element, the element will listen for any RequestInstance routed event and attempt to find the instance within its associated injector.

InstanceRequester extension

RequestInstance

By calling this method within an element, the element will raise the RequestInstance routed event to request an instance from an ancestor element that is an InstanceProvider.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.