Your SlideShare is downloading. ×
0
Inverting Control in WCF
Inverting Control in WCF
Inverting Control in WCF
Inverting Control in WCF
Inverting Control in WCF
Inverting Control in WCF
Inverting Control in WCF
Inverting Control in WCF
Inverting Control in WCF
Inverting Control in WCF
Inverting Control in WCF
Inverting Control in WCF
Inverting Control in WCF
Inverting Control in WCF
Inverting Control in WCF
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

Inverting Control in WCF

2,269

Published on

WCF provides many extension points and in this session Chris will cover how to wire up an Inversion of Control container into the WCF stack. Chris will discuss behaviors, instance providers, and the …

WCF provides many extension points and in this session Chris will cover how to wire up an Inversion of Control container into the WCF stack. Chris will discuss behaviors, instance providers, and the architecture of WCF in order to illustrate the best way to invert control in your services.

Published in: Technology
1 Comment
1 Like
Statistics
Notes
No Downloads
Views
Total Views
2,269
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
46
Comments
1
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. Inverting Control in WCF
    Chris Deweese
    photo by brentdanley via Flickr
  • 2. About Chris Deweese
    .NET Developer/Architect
    Specialties: SOA, Xml, Distributed Messaging, Object-Oriented Design
    Primarily work on System Integration & Information Sharing projects
    2009 Microsoft MVP, Solutions Architect
    Twitter @cdeweese
    http://christopherDeweese.com/
    Avid Xbox player (when kids are sleeping)
  • 3. At a Glance
    Brief overview of Inversion of Control
    The “container”
    Quick Overview of WCF Hosting Environment
    Short Overview of WCF Extensibility
    Where to invert control in WCF
    Ode to Code
    Review
  • 4. Wikipedia: Inversion of Control
    In object-oriented programming, the dependency inversion principle refers to a specific form of decoupling where conventional dependency relationships established from high-level, policy-setting modules to low-level, dependency modules are inverted (e.g. reversed) for the purpose of rendering high-level modules independent of the low-level module implementation details. The principle states:
    A. High-level modules should not depend on low-level modules. Both should depend on abstractions.
    B. Abstractions should not depend upon details. Details should depend upon abstractions.
    http://en.wikipedia.org/wiki/Dependency_inversion_principle
  • 5. English […]! Do you speak it?
    Reduce coupling between modules (classes, components, subsystems, etc) by using abstractions (interfaces, base classes).
    Modules built to require dependencies be provided.
    At runtime the dependencies will be provided so the module can do it’s job.
    Example: Class PersonService requires an IPersonRepository instance in order to perform its work.
  • 6. The “Container”
    Inversion of Control containers are a pattern to implement the dependency inversion principle.
    The “container” is used to locate dependencies typically by type <T> or type <T> + a unique key.
  • 7. Containers for .NET
    Structure Map
    Castle Windsor
    Unity
    Spring.Net
    AutoFac
    Ninject
    … Others via Scott Hanselman’s Computer Zen
  • 8. WCF Hosting Environment
    Service instances hosted inside a service host and service context
    Service Instance Provider responsible for managing service instance lifetimes
    If service instance faults the service host will abort and destroy the instance
    Default is per call instancing, i.e., every call to your endpoint creates new instance of your service*
    *This is probably a key point.
  • 9. WCF Hosting Environment
  • 10. WCF Extensibility
    WCF Extensible through many means
    Behaviors, Instance Providers, Hosts, Dispatchers, and more. All done via:
    Overriding Base classes
    Implementing Interfaces
    For Today’s discussion we’ll focus on Service Behaviors, Instance Providers, Service Hosts, and Service Host Factories
  • 11. Service Behavior?
    Controls the local execution of a service
    Applied to alter the services behavior at runtime
    Service Behavior must implement System.ServiceModel.Description.IServiceBehavior.
    Service Behavior applied through code by a custom service host or through configuration.
  • 12. “Best” location to attach container?
    In WCF, for a container to serve all instances it must be hosted at the Service Host level
    The container will be available to pass dependencies to the service instances at runtime
    Created once and serves all instances of the service
  • 13. Ode to code.
    photo by Premshree via Flickr
  • 14. The Solution
    Custom Instance Provider
    Provides instances of your service class to the WCF Runtime.
    Custom Service Behavior
    To substitute your instance provider for the default one.
    Custom Service Host
    Controls the container.
    Custom Service Host Factory
    Initializes container, creates custom service host and passes container to custom service host.
  • 15. Discussion/Questions
    Thanks for your time. Let’s talk if you have any tips or questions.

×