Click here to Skip to main content

Philip Laureano - Professional Profile

14,180
Author
285
Authority
2,394
Debator
40
Editor
36
Enquirer
1,573
Organiser
1,736
Participant
31 Dec 2007: CodeProject MVP 2008
No Biography provided
Member since Monday, December 2, 2002 (9 years, 6 months)

Below is the list of groups in which the member is participating


CodeProject Insiders



United States United States

Member



Collaborative Group
members


For more information on Reputation please see the FAQ.
 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
  Refresh
NewsLinFu IoC 2.0 out in the repository! Pin
Friday, August 29, 2008 3:10 AM
Here[^]'s the repository link. In addition to the features from version 1.0, LinFu.IoC v2.0 supports the following features:
 
Constructor Injection using Fluent Interfaces.
 
This is what the code looked like in v1.0:
 
[Factory(typeof(IVehicle))]
public class CarFactory : IFactory<ivehicle>
{
   public IVehicle CreateInstance(IContainer container)
   {
      // Get an instance of the engine
      // and the driver
      IEngine engine = container.GetService<iengine>();
      IPerson driver = container.GetService<iperson>();
      Car newCar = new Car(engine, driver);
 
      return newCar;
   }
}
</iperson></iengine></ivehicle>
 
This is what it looks like in LinFu IoC 2.0:
 
// Configure the container inject instances
// into the Car class constructor
container.Inject<ivehicle>()
  .Using(ioc => new Car(ioc.GetService<iengine>(),
                        ioc.GetService<iperson>()))
                        .OncePerRequest();
</iperson></iengine></ivehicle>
 
Property Injection using Fluent Interfaces.
 
Here's the code in 1.0:
 
[Implements(typeof(IVehicle), LifecycleType.OncePerRequest)]
public class Car : IVehicle, IInitialize
{
   // … Code omitted for brevity
   public void Initialize(IContainer container)
   {
      _engine = container.GetService<iengine>();
      _person = container.GetService<iperson>();
   }
}
</iperson></iengine>
 
Here's the 2.0 code using Fluent Interfaces:
 
container.Inject<ivehicle>()
                .Using(ioc => new Car(ioc.GetService<iengine>(),
                                      ioc.GetService<iperson>()))
                                      .OncePerRequest();
</iperson></iengine></ivehicle>
 

In addition, LinFu.IoC v2.0 has been outfitted with a battery of automated unit tests so you'll be able to test it with confidence. It has been rewritten from the ground up to support unit tests, and if you ever get lost in the code, you'll find that almost every class, interface, method, property and enum is filled to the brim with C# XML doc comments.
 
I'm currently in the process of rewriting the entire LinFu library, and this should give you an idea of where things are heading with LinFu in the future. I want to thank everyone in CP for their great feedback and support, and this is my way of giving back to the other CPians who taught me the value of writing good code. Again, thanks everyone Smile | :)
 
Do you know...LinFu?

 
GeneralThe LinFu Framework is now available on Google Code! Pin
Thursday, November 15, 2007 4:03 PM
To get the latest source for LinFu, click here.
GeneralRe: The LinFu Framework is now available on Google Code! PinmemberWiltek Ghozali17:13 17 Apr '08  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   


Advertise | Privacy | Mobile
Web01 | 2.5.120604.1 | Last Updated 4 Jun 2012
Copyright © CodeProject, 1999-2012
All Rights Reserved. Terms of Use
Layout: fixed | fluid