Your SlideShare is downloading. ×
0
Inversion Of Control: Spring.Net Overview
Inversion Of Control: Spring.Net Overview
Inversion Of Control: Spring.Net Overview
Inversion Of Control: Spring.Net Overview
Inversion Of Control: Spring.Net Overview
Inversion Of Control: Spring.Net Overview
Inversion Of Control: Spring.Net Overview
Inversion Of Control: Spring.Net Overview
Inversion Of Control: Spring.Net Overview
Inversion Of Control: Spring.Net Overview
Inversion Of Control: Spring.Net Overview
Inversion Of Control: Spring.Net Overview
Inversion Of Control: Spring.Net Overview
Inversion Of Control: Spring.Net Overview
Inversion Of Control: Spring.Net Overview
Inversion Of Control: Spring.Net Overview
Inversion Of Control: Spring.Net Overview
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Inversion Of Control: Spring.Net Overview

3,290

Published on

Introduction to Spring.NET, Inversion of Control. Spring.NET is an open source application framework that makes building enterprise .NET applications easier.

Introduction to Spring.NET, Inversion of Control. Spring.NET is an open source application framework that makes building enterprise .NET applications easier.

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
3,290
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
81
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. 10 May, 2009<br />Inversion Of Control - <br />Spring.NETOverview<br />
  • 2. Dependencies and Dependency Injection<br />10 May, 2009<br />2<br />Inversion Of Control - Spring.NET Overview<br />
  • 3. What is Dependency Injection?<br />Dependency injection (DI) in programming refers to the process of supplying an external dependency to a software component. <br />It is a specific form of inversion of control where the concern being inverted is the process of obtaining the needed dependency.<br />10 May, 2009<br />3<br />Inversion Of Control - Spring.NET Overview<br />
  • 4. But … what is Inversion of control?<br />Inversion of control, or IoC, is an abstract principle describing an aspect of some software architecture designs in which the flow of control of a system is inverted in comparison to the traditional architecture.<br />Control flow is expressed in imperative programming in the form of a series of instructions or procedure calls. Instead of specifying a sequence of decisions and procedures to occur during the lifetime of a process, the user of a IoCframework writes the desired responses linked to particular events or data requests. <br />10 May, 2009<br />4<br />Inversion Of Control - Spring.NET Overview<br />
  • 5. IOC Container<br />10 May, 2009<br />5<br />Inversion Of Control - Spring.NET Overview<br />
  • 6. Aha…and what is an IOC container?<br />10 May, 2009<br />6<br />Inversion Of Control - Spring.NET Overview<br />
  • 7. Spring.NET<br />an application framework for buidling Enterprise .NET applications <br />an IoC Container (Inversion of Control) that manages and injects dependencies on behalf of developers (DI = Dependency Injection)<br />10 May, 2009<br />Inversion Of Control - Spring.NET Overview<br />7<br />
  • 8. And more…<br />10 May, 2009<br />8<br />Inversion Of Control - Spring.NET Overview<br />
  • 9. IoC Containers for .NET<br />PicoContainer.NET: lightweight and highly embeddable IoC container<br />StructureMap: lightweight Inversion of Control (IoC) Container written in C#; can improve the architectural qualities of .NET apps by reducing the mechanical costs of good design techniques<br />Castle: Tools for application development including small IoC container<br />Spring.NET: full featured IoC container (port of Java version)<br />10 May, 2009<br />9<br />Inversion Of Control - Spring.NET Overview<br />
  • 10. Practice First approach - Dependencies<br />public class ExampleObject {<br /> private AnotherObjectobjectOne; // dependencies<br /> private YetAnotherObjectobjectTwo;<br /> private inti; <br /> public AnotherObjectObjectOne {<br /> set { this.objectOne = value; }<br /> }<br /> public YetAnotherObjectObjectTwo {<br /> set { this.objectTwo = value; }<br /> }<br /> public intIntegerProperty {<br /> set { this.i = value; } <br /> } <br />}<br />10 May, 2009<br />10<br />Inversion Of Control - Spring.NET Overview<br />
  • 11. Configuration I<br />Preferred way to create Object Factories and Application contexts is via configuration:<br />&lt;configuration&gt;<br /> &lt;configSections&gt;<br /> &lt;sectionGroup name=&quot;spring&quot;&gt;<br /> &lt;section name=&quot;context&quot; type=&quot;Spring.Context.Support.ContextHandler, Spring.Core&quot;/&gt;<br /> &lt;section name=&quot;objects&quot; type=&quot;Spring.Context.Support.DefaultSectionHandler, Spring.Core&quot; /&gt;<br /> &lt;/sectionGroup&gt;<br /> &lt;/configSections&gt;<br /> &lt;spring&gt;<br /> &lt;context&gt;<br /> &lt;resource uri=&quot;config://spring/objects&quot;/&gt;<br /> &lt;/context&gt;<br /> &lt;objects&gt;<br /> ...<br /> &lt;/objects&gt;<br /> &lt;/spring&gt;<br />&lt;/configuration&gt;<br />Handlers usedfor Spring configurationsection<br />Where to find object configuration, e.g. file, assembly, config<br />Configurationof Spring managedobjects<br />10 May, 2009<br />11<br />Inversion Of Control - Spring.NET Overview<br />
  • 12. Configuration II<br />The configuration tells Spring.NET how objects depend on each other: <br />Object name<br />Object type: namespacepath + class, assembly<br />&lt;object id=&quot;exampleObject&quot; type=&quot;Examples.ExampleObject, ExamplesLibrary&quot;&gt;<br /> &lt;property name=&quot;objectOne&quot; ref=&quot;anotherExampleObject&quot;/&gt;<br /> &lt;property name=&quot;objectTwo&quot; ref=&quot;yetAnotherObject&quot;/&gt;<br /> &lt;property name=&quot;IntegerProperty&quot; value=&quot;1&quot;/&gt;<br />&lt;/object&gt;<br />&lt;object id=&quot;anotherExampleObject&quot; type=&quot;Examples.AnotherObject, ExamplesLibrary&quot;/&gt;<br />&lt;object id=&quot;yetAnotherObject&quot; type=&quot;Examples.YetAnotherObject, ExamplesLibrary&quot;/&gt;<br />Properties referring to other objects: often called dependencies or collaborators<br />10 May, 2009<br />12<br />Inversion Of Control - Spring.NET Overview<br />
  • 13. Usage<br />Now instantiating an <br />ApplicationContext is simple:<br />ID that should appear in object configuration<br />IApplicationContextctx = ContextRegistry.GetContext();<br />ExampleObject person = (ExampleObject)ctx.GetObject(“exampleObject &quot;); <br />10 May, 2009<br />13<br />Inversion Of Control - Spring.NET Overview<br />
  • 14. Example application<br />10 May, 2009<br />14<br />Inversion Of Control - Spring.NET Overview<br />
  • 15. Solve the dependencies with Spring.NET IOC<br />Demo<br />10 May, 2009<br />15<br />Inversion Of Control - Spring.NET Overview<br />
  • 16. 16<br />Inversion Of Control - Spring.NET Overview<br />10 May, 2009<br />http://en.wikipedia.org/wiki/Inversion_of_control<br />http://martinfowler.com/articles/injection.html<br />http://abdullin.com/wiki/inversion-of-control-ioc.html<br />http://www.springframework.net/doc-latest/reference/html/objects.html<br />http://www.developer.com/net/csharp/article.php/3722931/Dependency-Injection-with-SpringNet.htm<br />Resources<br />
  • 17. 17<br />Inversion Of Control - Spring.NET Overview<br />10 May, 2009<br />

×