Inversion Of Control: Spring.Net Overview

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    Favorites, Groups & Events

    Inversion Of Control: Spring.Net Overview - Presentation 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

    + Orbit One Internet SolutionsOrbit One Internet Solutions, 1 month ago

    custom

    167 views, 0 favs, 0 embeds more stats

    Introduction to Spring.NET, Inversion of Control. S more

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 167
      • 167 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 0
    • Downloads 5
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories