SlideShare a Scribd company logo
1 of 26
OPN07 Fun with ASP.NET MVC 3, MEF and NuGet Maarten Balliauw Technical Consultant RealDolmen @maartenballiauw
Notes (hidden) So you have a team of developers… And a nice architecture to build on… How about making that architecture easy for everyone and getting developers up to speed quickly? Learn all about integrating the managed extensibility framework (MEF) and ASP.NET MVC with some NuGet sauce for creating loosely coupled, easy to use architectures that anyone can grasp. So what’s this talk about? Show you how you can build an app like Lego Show you how you can create Lego blocks for your team This is NOT a “general recommended approach”, just an idea that proved to work at one of our customers.
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 Me, looking intelligent with glasses
Agenda Technologies & techniques used ASP.NET MVC 3 Managed Extensibility Framework (MEF) NuGet Creating application components Building an application Conclusion Further information Q&A
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
var partA =new PartA(new PartB()) Sidenote: Dependency Injection? I need a “Part B” ! Coming up! Part A Me, doing actual software development
Container Sidenote: Dependency Injection? I need a “Part B” ! Let me see... There you go! Part A Part B
How does this fit into ASP.NET MVC 3? ASP.NET MVC 3 uses DependencyResolver : IDependencyResolver GetService() GetServices() Register it on application start
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 Wilson’s 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
Dependency Injection in ASP.NET MVC 3 demo
Managed Extensibility Framework (MEF) Cool as ICE: Import, Compose, Export [Import]Ilogger logger; MEF catalog HomeController [Export(typeof(Ilogger)] Let me see... There you go! ConsoleLogger MEF container
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
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
Using MefContrib And finding it. On NuGet. demo
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
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(        // ...       );  } }
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! Me, actually thinking
Creating application components Initech Default Theme demo
What’s 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) Install-Package NuGet.Server
Let’s see if we can build this... Wiredwith MEF Packagedas .nupkg
Building an application TPS ReportsCover Sheet Generator demo
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)
Further information For time travelers: FRM06 – Deconstructing Orchard – Bradley Millington – Lagoon L (Tuesday) FRM13 – Scaffolding – Steve Sanderson – Breakers H (Wednesday) Upcoming: FRM09 – NuGetIn Depth – Scott Hanselman & Phil Haack –Lagoon H (now) On the Internet: www.nuget.org mefcontrib.codeplex.com
Thank you for joining     & filling out the evals! Q&A http://blog.maartenballiauw.be @maartenballiauw Me, having a question
OPN07 Fun with ASP.NET MVC 3, MEF and NuGet Maarten Balliauw Technical Consultant RealDolmen @maartenballiauw

More Related Content

Similar to Fun with ASP.NET MVC 3, MEF and NuGet

A Brief Note On Asp.Net And Cloud Computing Essay
A Brief Note On Asp.Net And Cloud Computing EssayA Brief Note On Asp.Net And Cloud Computing Essay
A Brief Note On Asp.Net And Cloud Computing EssayLanate Drummond
 
ASP.NET MVC Introduction
ASP.NET MVC IntroductionASP.NET MVC Introduction
ASP.NET MVC IntroductionSumit Chhabra
 
MV(C, mvvm) in iOS and ReactiveCocoa
MV(C, mvvm) in iOS and ReactiveCocoaMV(C, mvvm) in iOS and ReactiveCocoa
MV(C, mvvm) in iOS and ReactiveCocoaYi-Shou Chen
 
Ncrafts.io - Refactor your software architecture
Ncrafts.io - Refactor your software architectureNcrafts.io - Refactor your software architecture
Ncrafts.io - Refactor your software architectureJulien Lavigne du Cadet
 
Ordina SOFTC Presentation - TFS and JAVA, better together
Ordina SOFTC Presentation - TFS and JAVA, better togetherOrdina SOFTC Presentation - TFS and JAVA, better together
Ordina SOFTC Presentation - TFS and JAVA, better togetherOrdina Belgium
 
NET Event - Migrating WinForm
NET Event - Migrating WinFormNET Event - Migrating WinForm
NET Event - Migrating WinFormRaffaele Garofalo
 
learn mvc project in 7 day
learn mvc project in 7 daylearn mvc project in 7 day
learn mvc project in 7 dayQuach Long
 
Overview of CSharp MVC3 and EF4
Overview of CSharp MVC3 and EF4Overview of CSharp MVC3 and EF4
Overview of CSharp MVC3 and EF4Rich Helton
 
Hithhiker guide to eclipse presentation frameworks galaxy
Hithhiker guide to eclipse presentation frameworks galaxyHithhiker guide to eclipse presentation frameworks galaxy
Hithhiker guide to eclipse presentation frameworks galaxyglefur
 
A report on mvc using the information
A report on mvc using the informationA report on mvc using the information
A report on mvc using the informationToushik Paul
 
Which is better asp.net mvc vs asp.net
Which is better  asp.net mvc vs asp.netWhich is better  asp.net mvc vs asp.net
Which is better asp.net mvc vs asp.netConcetto Labs
 
235042632 super-shop-ee
235042632 super-shop-ee235042632 super-shop-ee
235042632 super-shop-eehomeworkping3
 
Developing Java Web Applications
Developing Java Web ApplicationsDeveloping Java Web Applications
Developing Java Web Applicationshchen1
 
Lunch and learn as3_frameworks
Lunch and learn as3_frameworksLunch and learn as3_frameworks
Lunch and learn as3_frameworksYuri Visser
 
Introduction to MVC Web Framework with CodeIgniter
Introduction to MVC Web Framework with CodeIgniterIntroduction to MVC Web Framework with CodeIgniter
Introduction to MVC Web Framework with CodeIgniterPongsakorn U-chupala
 

Similar to Fun with ASP.NET MVC 3, MEF and NuGet (20)

A Brief Note On Asp.Net And Cloud Computing Essay
A Brief Note On Asp.Net And Cloud Computing EssayA Brief Note On Asp.Net And Cloud Computing Essay
A Brief Note On Asp.Net And Cloud Computing Essay
 
ASP.NET MVC Introduction
ASP.NET MVC IntroductionASP.NET MVC Introduction
ASP.NET MVC Introduction
 
Building APIs with Mule and Spring Boot
Building APIs with Mule and Spring BootBuilding APIs with Mule and Spring Boot
Building APIs with Mule and Spring Boot
 
MV(C, mvvm) in iOS and ReactiveCocoa
MV(C, mvvm) in iOS and ReactiveCocoaMV(C, mvvm) in iOS and ReactiveCocoa
MV(C, mvvm) in iOS and ReactiveCocoa
 
Ncrafts.io - Refactor your software architecture
Ncrafts.io - Refactor your software architectureNcrafts.io - Refactor your software architecture
Ncrafts.io - Refactor your software architecture
 
Angular js workshop
Angular js workshopAngular js workshop
Angular js workshop
 
Walther Mvc
Walther MvcWalther Mvc
Walther Mvc
 
Ordina SOFTC Presentation - TFS and JAVA, better together
Ordina SOFTC Presentation - TFS and JAVA, better togetherOrdina SOFTC Presentation - TFS and JAVA, better together
Ordina SOFTC Presentation - TFS and JAVA, better together
 
NET Event - Migrating WinForm
NET Event - Migrating WinFormNET Event - Migrating WinForm
NET Event - Migrating WinForm
 
learn mvc project in 7 day
learn mvc project in 7 daylearn mvc project in 7 day
learn mvc project in 7 day
 
Overview of CSharp MVC3 and EF4
Overview of CSharp MVC3 and EF4Overview of CSharp MVC3 and EF4
Overview of CSharp MVC3 and EF4
 
Tdd is not about testing
Tdd is not about testingTdd is not about testing
Tdd is not about testing
 
Hithhiker guide to eclipse presentation frameworks galaxy
Hithhiker guide to eclipse presentation frameworks galaxyHithhiker guide to eclipse presentation frameworks galaxy
Hithhiker guide to eclipse presentation frameworks galaxy
 
MVC 3.0 KU Day 1 v 1.1
MVC 3.0 KU Day 1 v 1.1MVC 3.0 KU Day 1 v 1.1
MVC 3.0 KU Day 1 v 1.1
 
A report on mvc using the information
A report on mvc using the informationA report on mvc using the information
A report on mvc using the information
 
Which is better asp.net mvc vs asp.net
Which is better  asp.net mvc vs asp.netWhich is better  asp.net mvc vs asp.net
Which is better asp.net mvc vs asp.net
 
235042632 super-shop-ee
235042632 super-shop-ee235042632 super-shop-ee
235042632 super-shop-ee
 
Developing Java Web Applications
Developing Java Web ApplicationsDeveloping Java Web Applications
Developing Java Web Applications
 
Lunch and learn as3_frameworks
Lunch and learn as3_frameworksLunch and learn as3_frameworks
Lunch and learn as3_frameworks
 
Introduction to MVC Web Framework with CodeIgniter
Introduction to MVC Web Framework with CodeIgniterIntroduction to MVC Web Framework with CodeIgniter
Introduction to MVC Web Framework with CodeIgniter
 

More from Maarten Balliauw

Bringing nullability into existing code - dammit is not the answer.pptx
Bringing nullability into existing code - dammit is not the answer.pptxBringing nullability into existing code - dammit is not the answer.pptx
Bringing nullability into existing code - dammit is not the answer.pptxMaarten Balliauw
 
Nerd sniping myself into a rabbit hole... Streaming online audio to a Sonos s...
Nerd sniping myself into a rabbit hole... Streaming online audio to a Sonos s...Nerd sniping myself into a rabbit hole... Streaming online audio to a Sonos s...
Nerd sniping myself into a rabbit hole... Streaming online audio to a Sonos s...Maarten Balliauw
 
Building a friendly .NET SDK to connect to Space
Building a friendly .NET SDK to connect to SpaceBuilding a friendly .NET SDK to connect to Space
Building a friendly .NET SDK to connect to SpaceMaarten Balliauw
 
Microservices for building an IDE - The innards of JetBrains Rider - NDC Oslo...
Microservices for building an IDE - The innards of JetBrains Rider - NDC Oslo...Microservices for building an IDE - The innards of JetBrains Rider - NDC Oslo...
Microservices for building an IDE - The innards of JetBrains Rider - NDC Oslo...Maarten Balliauw
 
Indexing and searching NuGet.org with Azure Functions and Search - .NET fwday...
Indexing and searching NuGet.org with Azure Functions and Search - .NET fwday...Indexing and searching NuGet.org with Azure Functions and Search - .NET fwday...
Indexing and searching NuGet.org with Azure Functions and Search - .NET fwday...Maarten Balliauw
 
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...Maarten Balliauw
 
JetBrains Australia 2019 - Exploring .NET’s memory management – a trip down m...
JetBrains Australia 2019 - Exploring .NET’s memory management – a trip down m...JetBrains Australia 2019 - Exploring .NET’s memory management – a trip down m...
JetBrains Australia 2019 - Exploring .NET’s memory management – a trip down m...Maarten Balliauw
 
.NET Conf 2019 - Indexing and searching NuGet.org with Azure Functions and Se...
.NET Conf 2019 - Indexing and searching NuGet.org with Azure Functions and Se....NET Conf 2019 - Indexing and searching NuGet.org with Azure Functions and Se...
.NET Conf 2019 - Indexing and searching NuGet.org with Azure Functions and Se...Maarten Balliauw
 
CloudBurst 2019 - Indexing and searching NuGet.org with Azure Functions and S...
CloudBurst 2019 - Indexing and searching NuGet.org with Azure Functions and S...CloudBurst 2019 - Indexing and searching NuGet.org with Azure Functions and S...
CloudBurst 2019 - Indexing and searching NuGet.org with Azure Functions and S...Maarten Balliauw
 
NDC Oslo 2019 - Indexing and searching NuGet.org with Azure Functions and Search
NDC Oslo 2019 - Indexing and searching NuGet.org with Azure Functions and SearchNDC Oslo 2019 - Indexing and searching NuGet.org with Azure Functions and Search
NDC Oslo 2019 - Indexing and searching NuGet.org with Azure Functions and SearchMaarten Balliauw
 
Approaches for application request throttling - Cloud Developer Days Poland
Approaches for application request throttling - Cloud Developer Days PolandApproaches for application request throttling - Cloud Developer Days Poland
Approaches for application request throttling - Cloud Developer Days PolandMaarten Balliauw
 
Indexing and searching NuGet.org with Azure Functions and Search - Cloud Deve...
Indexing and searching NuGet.org with Azure Functions and Search - Cloud Deve...Indexing and searching NuGet.org with Azure Functions and Search - Cloud Deve...
Indexing and searching NuGet.org with Azure Functions and Search - Cloud Deve...Maarten Balliauw
 
Approaches for application request throttling - dotNetCologne
Approaches for application request throttling - dotNetCologneApproaches for application request throttling - dotNetCologne
Approaches for application request throttling - dotNetCologneMaarten Balliauw
 
CodeStock - Exploring .NET memory management - a trip down memory lane
CodeStock - Exploring .NET memory management - a trip down memory laneCodeStock - Exploring .NET memory management - a trip down memory lane
CodeStock - Exploring .NET memory management - a trip down memory laneMaarten Balliauw
 
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...Maarten Balliauw
 
ConFoo Montreal - Approaches for application request throttling
ConFoo Montreal - Approaches for application request throttlingConFoo Montreal - Approaches for application request throttling
ConFoo Montreal - Approaches for application request throttlingMaarten Balliauw
 
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...Microservices for building an IDE – The innards of JetBrains Rider - TechDays...
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...Maarten Balliauw
 
JetBrains Day Seoul - Exploring .NET’s memory management – a trip down memory...
JetBrains Day Seoul - Exploring .NET’s memory management – a trip down memory...JetBrains Day Seoul - Exploring .NET’s memory management – a trip down memory...
JetBrains Day Seoul - Exploring .NET’s memory management – a trip down memory...Maarten Balliauw
 
DotNetFest - Let’s refresh our memory! Memory management in .NET
DotNetFest - Let’s refresh our memory! Memory management in .NETDotNetFest - Let’s refresh our memory! Memory management in .NET
DotNetFest - Let’s refresh our memory! Memory management in .NETMaarten Balliauw
 
VISUG - Approaches for application request throttling
VISUG - Approaches for application request throttlingVISUG - Approaches for application request throttling
VISUG - Approaches for application request throttlingMaarten Balliauw
 

More from Maarten Balliauw (20)

Bringing nullability into existing code - dammit is not the answer.pptx
Bringing nullability into existing code - dammit is not the answer.pptxBringing nullability into existing code - dammit is not the answer.pptx
Bringing nullability into existing code - dammit is not the answer.pptx
 
Nerd sniping myself into a rabbit hole... Streaming online audio to a Sonos s...
Nerd sniping myself into a rabbit hole... Streaming online audio to a Sonos s...Nerd sniping myself into a rabbit hole... Streaming online audio to a Sonos s...
Nerd sniping myself into a rabbit hole... Streaming online audio to a Sonos s...
 
Building a friendly .NET SDK to connect to Space
Building a friendly .NET SDK to connect to SpaceBuilding a friendly .NET SDK to connect to Space
Building a friendly .NET SDK to connect to Space
 
Microservices for building an IDE - The innards of JetBrains Rider - NDC Oslo...
Microservices for building an IDE - The innards of JetBrains Rider - NDC Oslo...Microservices for building an IDE - The innards of JetBrains Rider - NDC Oslo...
Microservices for building an IDE - The innards of JetBrains Rider - NDC Oslo...
 
Indexing and searching NuGet.org with Azure Functions and Search - .NET fwday...
Indexing and searching NuGet.org with Azure Functions and Search - .NET fwday...Indexing and searching NuGet.org with Azure Functions and Search - .NET fwday...
Indexing and searching NuGet.org with Azure Functions and Search - .NET fwday...
 
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
 
JetBrains Australia 2019 - Exploring .NET’s memory management – a trip down m...
JetBrains Australia 2019 - Exploring .NET’s memory management – a trip down m...JetBrains Australia 2019 - Exploring .NET’s memory management – a trip down m...
JetBrains Australia 2019 - Exploring .NET’s memory management – a trip down m...
 
.NET Conf 2019 - Indexing and searching NuGet.org with Azure Functions and Se...
.NET Conf 2019 - Indexing and searching NuGet.org with Azure Functions and Se....NET Conf 2019 - Indexing and searching NuGet.org with Azure Functions and Se...
.NET Conf 2019 - Indexing and searching NuGet.org with Azure Functions and Se...
 
CloudBurst 2019 - Indexing and searching NuGet.org with Azure Functions and S...
CloudBurst 2019 - Indexing and searching NuGet.org with Azure Functions and S...CloudBurst 2019 - Indexing and searching NuGet.org with Azure Functions and S...
CloudBurst 2019 - Indexing and searching NuGet.org with Azure Functions and S...
 
NDC Oslo 2019 - Indexing and searching NuGet.org with Azure Functions and Search
NDC Oslo 2019 - Indexing and searching NuGet.org with Azure Functions and SearchNDC Oslo 2019 - Indexing and searching NuGet.org with Azure Functions and Search
NDC Oslo 2019 - Indexing and searching NuGet.org with Azure Functions and Search
 
Approaches for application request throttling - Cloud Developer Days Poland
Approaches for application request throttling - Cloud Developer Days PolandApproaches for application request throttling - Cloud Developer Days Poland
Approaches for application request throttling - Cloud Developer Days Poland
 
Indexing and searching NuGet.org with Azure Functions and Search - Cloud Deve...
Indexing and searching NuGet.org with Azure Functions and Search - Cloud Deve...Indexing and searching NuGet.org with Azure Functions and Search - Cloud Deve...
Indexing and searching NuGet.org with Azure Functions and Search - Cloud Deve...
 
Approaches for application request throttling - dotNetCologne
Approaches for application request throttling - dotNetCologneApproaches for application request throttling - dotNetCologne
Approaches for application request throttling - dotNetCologne
 
CodeStock - Exploring .NET memory management - a trip down memory lane
CodeStock - Exploring .NET memory management - a trip down memory laneCodeStock - Exploring .NET memory management - a trip down memory lane
CodeStock - Exploring .NET memory management - a trip down memory lane
 
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
 
ConFoo Montreal - Approaches for application request throttling
ConFoo Montreal - Approaches for application request throttlingConFoo Montreal - Approaches for application request throttling
ConFoo Montreal - Approaches for application request throttling
 
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...Microservices for building an IDE – The innards of JetBrains Rider - TechDays...
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...
 
JetBrains Day Seoul - Exploring .NET’s memory management – a trip down memory...
JetBrains Day Seoul - Exploring .NET’s memory management – a trip down memory...JetBrains Day Seoul - Exploring .NET’s memory management – a trip down memory...
JetBrains Day Seoul - Exploring .NET’s memory management – a trip down memory...
 
DotNetFest - Let’s refresh our memory! Memory management in .NET
DotNetFest - Let’s refresh our memory! Memory management in .NETDotNetFest - Let’s refresh our memory! Memory management in .NET
DotNetFest - Let’s refresh our memory! Memory management in .NET
 
VISUG - Approaches for application request throttling
VISUG - Approaches for application request throttlingVISUG - Approaches for application request throttling
VISUG - Approaches for application request throttling
 

Recently uploaded

FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Hyundai Motor Group
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 

Recently uploaded (20)

FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 

Fun with ASP.NET MVC 3, MEF and NuGet

  • 1.
  • 2. OPN07 Fun with ASP.NET MVC 3, MEF and NuGet Maarten Balliauw Technical Consultant RealDolmen @maartenballiauw
  • 3. Notes (hidden) So you have a team of developers… And a nice architecture to build on… How about making that architecture easy for everyone and getting developers up to speed quickly? Learn all about integrating the managed extensibility framework (MEF) and ASP.NET MVC with some NuGet sauce for creating loosely coupled, easy to use architectures that anyone can grasp. So what’s this talk about? Show you how you can build an app like Lego Show you how you can create Lego blocks for your team This is NOT a “general recommended approach”, just an idea that proved to work at one of our customers.
  • 4. 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 Me, looking intelligent with glasses
  • 5. Agenda Technologies & techniques used ASP.NET MVC 3 Managed Extensibility Framework (MEF) NuGet Creating application components Building an application Conclusion Further information Q&A
  • 6. 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
  • 7. var partA =new PartA(new PartB()) Sidenote: Dependency Injection? I need a “Part B” ! Coming up! Part A Me, doing actual software development
  • 8. Container Sidenote: Dependency Injection? I need a “Part B” ! Let me see... There you go! Part A Part B
  • 9. How does this fit into ASP.NET MVC 3? ASP.NET MVC 3 uses DependencyResolver : IDependencyResolver GetService() GetServices() Register it on application start
  • 10. 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 Wilson’s 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
  • 11. Dependency Injection in ASP.NET MVC 3 demo
  • 12. Managed Extensibility Framework (MEF) Cool as ICE: Import, Compose, Export [Import]Ilogger logger; MEF catalog HomeController [Export(typeof(Ilogger)] Let me see... There you go! ConsoleLogger MEF container
  • 13. 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
  • 14. 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
  • 15. Using MefContrib And finding it. On NuGet. demo
  • 16. 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
  • 17. 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( // ... ); } }
  • 18. 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! Me, actually thinking
  • 19. Creating application components Initech Default Theme demo
  • 20. What’s 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) Install-Package NuGet.Server
  • 21. Let’s see if we can build this... Wiredwith MEF Packagedas .nupkg
  • 22. Building an application TPS ReportsCover Sheet Generator demo
  • 23. 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)
  • 24. Further information For time travelers: FRM06 – Deconstructing Orchard – Bradley Millington – Lagoon L (Tuesday) FRM13 – Scaffolding – Steve Sanderson – Breakers H (Wednesday) Upcoming: FRM09 – NuGetIn Depth – Scott Hanselman & Phil Haack –Lagoon H (now) On the Internet: www.nuget.org mefcontrib.codeplex.com
  • 25. Thank you for joining & filling out the evals! Q&A http://blog.maartenballiauw.be @maartenballiauw Me, having a question
  • 26. OPN07 Fun with ASP.NET MVC 3, MEF and NuGet Maarten Balliauw Technical Consultant RealDolmen @maartenballiauw
  • 27. © 2011 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Editor's Notes

  1. Demo01_MVC_DependencyResolverAdd a property to the HomeController for specifying the welcome messageAdd a class “SimpleDependencyResolver.cs”Implement IdependencyResolver (use snippets for some parts)    public class SimpleDependencyResolver        : IDependencyResolver    {        public object GetService(Type serviceType)        {            if (serviceType == typeof(Controllers.HomeController))            {                var controller = Activator.CreateInstance(serviceType) as Controllers.HomeController;                controller.MessageText = &quot;Welcome, this text has been injected!&quot;;                return controller;            }            if (serviceType.IsInterface)            {                if (serviceType == typeof(IControllerFactory)) return new DefaultControllerFactory();                if (serviceType == typeof(IControllerActivator)) return null;                if (serviceType == typeof(IFilterProvider)) return GlobalFilters.Filters;                if (serviceType == typeof(IViewEngine)) return new RazorViewEngine();                if (serviceType == typeof(IViewPageActivator)) return null;            }            return Activator.CreateInstance(serviceType);        }        public IEnumerable&lt;object&gt; GetServices(Type serviceType)        {            return new object[] { GetService(serviceType) };        }    } Register dependencyresolver in App_Start:DependencyResolver.SetResolver(new SimpleDependencyResolver());
  2. Demo02_MefContribCreate a new MVC application (application template)Add an IHelloWorldService    public interface IHelloWorldService    {        string Hello();    } Add a HelloWorldService    [Export(typeof(IHelloWorldService))]    public class HelloWorldService        : IHelloWorldService    {        public string Hello()        {            return &quot;Hello from HelloWorldService!&quot;;        }    } Change HomeController     public class HomeController : Controller    {        private IHelloWorldService service;         [ImportingConstructor]        public HomeController(IHelloWorldService helloWorldService)        {            this.service = helloWorldService;        }         public ActionResult Index()        {            ViewBag.Message = this.service.Hello();             return View();        }         public ActionResult About()        {            return View();        }    } Run and fail…NuGet the MefContrib.MVC packageExplain the fact that it uses the /bin folder for part discoveryExplain the use of conventions
  3. Initech.Components.Theming.DefaultThemeOpen solutionShow it’s nothing but a “plain old” MVC applicationRun the projectDemonstrate it does nothing, it’s just a template…Show the NuGet folder in Windows ExplorerOpen package.nuspec using NuGet Package ExplorerShow people around:Show the “Content” folder, this is where package contents will go. In this case, it will contain the Views, CSS and scripts.Show “lib”: it will contain assemblies (if appropriate for the package)Package.proj is the MSBUILD script that does the packagingOpen itSpecify some settings about what to copy and packageUpdate version number in nuspec fileRun nuget.exe on the nuspec fileAwesomeness!
  4. IniTech.TpsCoverSheetGeneratorCreate an empty MVC applicationAdd a library package reference to InitechThemeDefaultThemeUpdate _ViewStart.cshtml to use _InitechLayout.cshtmlAdd a HomeControllerAdd a viewRun the application to show off the templateRemove the view: we’ll generate that later onAdd library package reference (from command line?) to InitechDomainTpsReportsModify Index() action method:        public ActionResult Index()        {            return View(new TpsReportCoverSheet());        } Add POST action        [HttpPost]        public ActionResult Index(TpsReportCoverSheet model)        {            if (ModelState.IsValid)            {                return View(&quot;TpsReportCoverSheet&quot;, model);            }             return View(model);        } Add [Authorize] attributeAdd library package reference to InitechWebMvcAuthenticationDemonstrate it adds dependencies from NuGet as well as from Initech package repositoryWe need an implementation for the contracts… InitechAuthenticationMembershipDummy &amp; InitechAuthenticationFormsShow the app: almost no code, we just combined some building blocks…