1 / 25

Fun with ASP MVC 3, MEF and NuGet

aram
Télécharger la présentation

Fun with ASP MVC 3, MEF and NuGet

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


    1. Fun with ASP.NET MVC 3, MEF and NuGet Maarten Balliauw Technical Consultant RealDolmen @maartenballiauw

    2. Who am I? Maarten Balliauw Antwerp, Belgium www.realdolmen.com Focus on web ASP.NET, ASP.NET MVC, PHP, Azure, MVP ASP.NET http://blog.maartenballiauw.be @maartenballiauw

    3. Agenda Technologies & techniques used ASP.NET MVC 3 Managed Extensibility Framework (MEF) NuGet Creating application components Building an application Conclusion Further information Q&A

    4. ASP.NET MVC 3 All the new stuff: Razor view engine Global Action Filters Unobtrusive Ajax & Client Validation Better Visual Studio tooling And a very interesting one for doing Lego development: Better support for Dependency Injection

    5. Sidenote: Dependency Injection?

    6. Sidenote: Dependency Injection?

    7. How does this fit into ASP.NET MVC 3? ASP.NET MVC 3 uses DependencyResolver : IDependencyResolver GetService() GetServices() Register it on application start

    8. How does this fit in ASP.NET MVC 3? ASP.NET MVC will / can query the IDependencyResolver for Controllers View engines & view pages Filters Model validators Model metadata Check Brad Wilsons blog for examples on all of these http://bradwilson.typepad.com/blog/2010/07/service-location-pt1-introduction.html Value providers Model binders Controller activator View page activator

    9. Dependency Injection in ASP.NET MVC 3 demo

    10. Managed Extensibility Framework (MEF) Cool as ICE: Import, Compose, Export

    11. Options for MEF in ASP.NET MVC 3 Build an IDependencyResolver based on MEF container Use MefContrib has a built-in IDependencyResolver has a Convention model is available on NuGet mefcontrib.codeplex.com

    12. A brief NuGet introduction... Package management system for .NET Simplifies incorporating 3rd party libraries Developer focused Free, open source Use packages from the official feed Publish your own packages Create & use your own feed

    13. Using MefContrib And finding it. On NuGet. demo

    14. MefContrib.MVC3 Optional addition for MefContrib Adds some things to your application: AppStart code that does the wiring A CompositionDependencyResolver Will check all assemblies in /bin Will export everything : IController by convention

    15. Conventions in MefContrib-MVC3 public class MvcApplicationRegistry : PartRegistry { public MvcApplicationRegistry() { Scan(x => { x.Assembly(Assembly.GetExecutingAssembly()); x.Directory(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "bin")); }); Part() .ForTypesAssignableFrom<IController>() .MakeNonShared() .ExportTypeAs<IController>() .ExportType() .Imports( // ... ); } }

    16. This all makes me think... Package company components using NuGet? Distribute them in a custom feed? Use ASP.NET MVC 3? Wire everything with MEF & MefContrib? Pure application Lego!

    17. Creating application components Initech Default Theme demo

    18. Whats next? Building it MSBuild (or whatever! Nuget.exe is all that matters) Hosting it Create a NuGet server Or drop everything in a folder Using it Reference the feed Download & install components needed Assemble using MEF (or another IoC)

    19. Lets see if we can build this...

    20. Building an application TPS Reports Cover Sheet Generator demo

    21. Conclusion You can build an app like a Lego set Requires bricks (NuGet packages) Requires glue (MEF / MefContrib / other IoC) Requires you to think in terms of components Structure is key! Not a best-practice architecture Just something we toyed with on a project Proved to work (for the customer)

    22. Further information For time travelers: FRM06 Deconstructing Orchard Bradley Millington Lagoon L (Tuesday) FRM13 Scaffolding Steve Sanderson Breakers H (Wednesday) Upcoming: FRM09 NuGet In Depth Scott Hanselman & Phil Haack Lagoon H (now) On the Internet: www.nuget.org mefcontrib.codeplex.com

    23. Thank you for joining! Q&A

    24. Fun with ASP.NET MVC 3, MEF and NuGet Maarten Balliauw Technical Consultant RealDolmen @maartenballiauw

More Related