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,283

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,283
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
    Inversion Of Control -
    Spring.NETOverview
  • 2. Dependencies and Dependency Injection
    10 May, 2009
    2
    Inversion Of Control - Spring.NET Overview
  • 3. What is Dependency Injection?
    Dependency injection (DI) in programming refers to the process of supplying an external dependency to a software component.
    It is a specific form of inversion of control where the concern being inverted is the process of obtaining the needed dependency.
    10 May, 2009
    3
    Inversion Of Control - Spring.NET Overview
  • 4. But … what is Inversion of control?
    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.
    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.
    10 May, 2009
    4
    Inversion Of Control - Spring.NET Overview
  • 5. IOC Container
    10 May, 2009
    5
    Inversion Of Control - Spring.NET Overview
  • 6. Aha…and what is an IOC container?
    10 May, 2009
    6
    Inversion Of Control - Spring.NET Overview
  • 7. Spring.NET
    an application framework for buidling Enterprise .NET applications
    an IoC Container (Inversion of Control) that manages and injects dependencies on behalf of developers (DI = Dependency Injection)
    10 May, 2009
    Inversion Of Control - Spring.NET Overview
    7
  • 8. And more…
    10 May, 2009
    8
    Inversion Of Control - Spring.NET Overview
  • 9. IoC Containers for .NET
    PicoContainer.NET: lightweight and highly embeddable IoC container
    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
    Castle: Tools for application development including small IoC container
    Spring.NET: full featured IoC container (port of Java version)
    10 May, 2009
    9
    Inversion Of Control - Spring.NET Overview
  • 10. Practice First approach - Dependencies
    public class ExampleObject {
    private AnotherObjectobjectOne; // dependencies
    private YetAnotherObjectobjectTwo;
    private inti;
    public AnotherObjectObjectOne {
    set { this.objectOne = value; }
    }
    public YetAnotherObjectObjectTwo {
    set { this.objectTwo = value; }
    }
    public intIntegerProperty {
    set { this.i = value; }
    }
    }
    10 May, 2009
    10
    Inversion Of Control - Spring.NET Overview
  • 11. Configuration I
    Preferred way to create Object Factories and Application contexts is via configuration:
    <configuration>
    <configSections>
    <sectionGroup name="spring">
    <section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core"/>
    <section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core" />
    </sectionGroup>
    </configSections>
    <spring>
    <context>
    <resource uri="config://spring/objects"/>
    </context>
    <objects>
    ...
    </objects>
    </spring>
    </configuration>
    Handlers usedfor Spring configurationsection
    Where to find object configuration, e.g. file, assembly, config
    Configurationof Spring managedobjects
    10 May, 2009
    11
    Inversion Of Control - Spring.NET Overview
  • 12. Configuration II
    The configuration tells Spring.NET how objects depend on each other:
    Object name
    Object type: namespacepath + class, assembly
    <object id="exampleObject" type="Examples.ExampleObject, ExamplesLibrary">
    <property name="objectOne" ref="anotherExampleObject"/>
    <property name="objectTwo" ref="yetAnotherObject"/>
    <property name="IntegerProperty" value="1"/>
    </object>
    <object id="anotherExampleObject" type="Examples.AnotherObject, ExamplesLibrary"/>
    <object id="yetAnotherObject" type="Examples.YetAnotherObject, ExamplesLibrary"/>
    Properties referring to other objects: often called dependencies or collaborators
    10 May, 2009
    12
    Inversion Of Control - Spring.NET Overview
  • 13. Usage
    Now instantiating an
    ApplicationContext is simple:
    ID that should appear in object configuration
    IApplicationContextctx = ContextRegistry.GetContext();
    ExampleObject person = (ExampleObject)ctx.GetObject(“exampleObject ");
    10 May, 2009
    13
    Inversion Of Control - Spring.NET Overview
  • 14. Example application
    10 May, 2009
    14
    Inversion Of Control - Spring.NET Overview
  • 15. Solve the dependencies with Spring.NET IOC
    Demo
    10 May, 2009
    15
    Inversion Of Control - Spring.NET Overview
  • 16. 16
    Inversion Of Control - Spring.NET Overview
    10 May, 2009
    http://en.wikipedia.org/wiki/Inversion_of_control
    http://martinfowler.com/articles/injection.html
    http://abdullin.com/wiki/inversion-of-control-ioc.html
    http://www.springframework.net/doc-latest/reference/html/objects.html
    http://www.developer.com/net/csharp/article.php/3722931/Dependency-Injection-with-SpringNet.htm
    Resources
  • 17. 17
    Inversion Of Control - Spring.NET Overview
    10 May, 2009

×