marcel-valdez / dependency-locator Goto Github PK
View Code? Open in Web Editor NEWA dynamic-dependency-loading service locator for .net, written in C#
License: Other
A dynamic-dependency-loading service locator for .net, written in C#
License: Other
Add a way to support constructor contracts in the Setup assemblies.
This can be done by returning a PROXY to the implementation when an interface's implementation object is created, and when you want to change an object's implementation three things have to happen:
// 1. At some point the client side
var myService = locator.Create<IService>();
// this produces valid results
result = myService.Action();
// ...
// 2. Some other place in the client side
locator.ReloadDependencies();
// ...
// 3. In the proxy's code, in parallel preferably
void changeImpl(IService newImpl) {
object memento = this.impl.Stop();
newImpl.Start(memento);
this.impl = newImpl;
}
// ...
// 4. At some point in the client side again
// this produces valid results
result = myService.Action();
Using csharp as a script, configure the implementations of -interface components-.
Important details
Example Dependfile
// Default implementations
Interfaces("Interfaces.dll").ImplementedBy("Implementations.dll");
// Explicit implementations alternatives
// 1.
Setup.Interface<IService>().ImplementedBy<Service>();
// 2.
using(var iface = Interfaces("Interfaces.dll"))
using(var impl = Implementations("Implementations.dll")) {
Interface<IService>(iface).ImplementedBy<Service>(impl);
}
// 3
using(var iface = Interfaces("Interfaces.dll"))
using(var impl = Implementations("Implementations.dll")) {
iface.Dependency<IService, Service>(impl);
}
// 4
Interface<IService>("Interfaces.dll").ImplementedBy<Service>("Implementation.dll");
The script needs to identify, at runtime the type IService and Service, because there is no "using"
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.