Giter VIP home page Giter VIP logo

compose's Introduction

Compose

Latest Release NuGet

Build status Stories in Backlog Stories in Ready Stories in Progress

Description

Compose is a lightweight framework to assist in application composition, enforcing clean and efficient component isolation, whilst providing key features out of the box.

Compose follows the same OWIN composition patterns as found in the MVC 6 samples, but on a broader basis, minimising dependencies and providing consistent patterns across all application types, from ASP.Net MVC, to Console Applications.

Getting Started

Prerequisites

  • .Net 4.5.2 or higher

Install Compose

Includes built-in support for Dependency Injection, Transitioning, Snapshotting, and basic Executable Applications.

To install Compose, run the following command in the Package Manager Console

PM> Install-Package Compose -Pre

Basic Usage

Features

Dependency Injection

There are a myriad of DI Containers available nowadays such as Autofac, Castle Windsor, Ninject, StructureMap, Unity, etc.

As part of ASP.Net vNext development, Microsoft are releasing an Open Source Dependency Injection Framework that supports all of the popular existing containers listed above.

We utilise this new framework so that, unless you need additional features provided by Compose, your services only require a dependency on the Microsoft.Framework.DependencyInjection package.

Transitioning

One of the key features Compose provides is the ability to seamlessly switch your service implementations at runtime. No additional code or changes are required in your service extensions, simply tag the service(s) as Transitional during composition.

For example:

app.UseServices(services => 
{
	services
		.AddYourServices()
		// Mark one of the interfaces added by your service as transitional
		.WithTransitional<IDependency>();
});
// So long as an interface is regsitered as transitional, you can change it at any stage using
app.Transition<IDependency, MyReplacementDependency>();

Snapshotting

This feature allows your application to better manage dependencies, particularly those for which your application is not responsible. For example, you may transition an interface from a service extension without any knowledge of how the interface is implemented. Snapshotting allows you to Rollback the dependency graph to use the original implementation, without the need to reference it directly.

app.UseServices(services =>
{
	services
		.AddSomeServices()
		// Mark all interfaces as transitional
		.AsTransitional();
});
// app.Snapshot() is called for you by UseServices, but you can
// call it at any stage to overwrite the existing snapshot.

// Transition a component to your own implementation
app.Transition<IDependency, MyReplacementDependency>();
// When you want to transition back to the original service
app.Restore(); 

FAQ / Troubleshooting

-Q. How to debug/view the code emitted? -A. Add the ENABLE_SAVE_DYNAMIC_ASSEMBLY compilation symbol to the Compose build to have the dyanmic assemblies stored in the execution directory.

compose's People

Contributors

devbot-net avatar herecydev avatar mattridgway avatar smudge202 avatar

Watchers

 avatar

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.