ERLEDIGT
NEIN
NEIN
ANTWORTEN
0
0
ZUGRIFFE
1221
1221
EMPFEHLEN
-
27.02.08 15:00 #1
- Registriert seit
- Jun 2002
- Ort
- Saarbrücken (Saarland)
- Beiträge
- 9.886
- Blog-Einträge
- 29
Hallo,
hier mal ein einfaches Beispiel dazu wie man das neue Dependency Injection Framework Unity von Microsoft verwendet:
http://www.codeplex.com/unity
Code csharp:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Practices.Unity; namespace De.Tutorials.Unity { public class Program { static void Main(string[] args) { IUnityContainer container = new UnityContainer().Register<IFoo, Foo>(); Bar bar = container.Get<Bar>(); Console.WriteLine(bar); } } public interface IFoo{} public class Foo : IFoo{} public class Bar { [Dependency] public IFoo Foo { get; set; } public override string ToString() { return "Foo: " + Foo; } } }
Ausgabe:
Code :1
Foo: De.Tutorials.Unity.Foo
Die API fühlt sich ein wenig so an wie die von Googles Guice:
http://code.google.com/p/google-guice/
Gruß TomJava rocks!
How to become a good Java Programmer?
Does IT in Java and .Net
The only valid measurement of code quality: WTFs / minute
Blog
Xing
Twitter
Ähnliche Themen
-
Dependency Injection Frameworks für .Net
Von Thomas Darimont im Forum .NET CaféAntworten: 0Letzter Beitrag: 18.01.10, 19:11 -
Beispiel zu Dependency Injection mit GWT & Springframework ME
Von Konstantin Denerz im Forum JavaAntworten: 0Letzter Beitrag: 21.04.09, 13:54 -
Dependency Injection & Security
Von misiu im Forum Enterprise Java (JEE, J2EE, Spring & Co.)Antworten: 4Letzter Beitrag: 17.05.08, 21:31 -
Beispiel zur Dependency Injection in Eclipse RCP View mit AspectJ und Spring
Von Thomas Darimont im Forum JavaAntworten: 8Letzter Beitrag: 17.02.08, 11:04 -
Guice - Neues Dependency Injection Framework von Google
Von Thomas Darimont im Forum JavaAntworten: 0Letzter Beitrag: 12.03.07, 13:21






Zitieren
Login





