SlideShare une entreprise Scribd logo
1  sur  26
DECEMBER 12, 2011 | SLIDE 1
www.realdolmen.com




                              FUN WITH ASP.NET MVC 3,
                                  MEF AND NUGET




DECEMBER 12, 2011 | SLIDE 2
WHO AM I?
        Maarten Balliauw
        Antwerp, Belgium
                                       Me, looking
        www.realdolmen.com            intelligent with
        Focus on web                  glasses
          ASP.NET MVC, PHP, Azure, SignalR, …
          MVP Windows Azure (formerly ASP.NET)
        Co-founder of AZUG
        http://blog.maartenballiauw.be
        @maartenballiauw




DECEMBER 12, 2011 | SLIDE 4
AGENDA
        Technologies & techniques used
          ASP.NET MVC 3
          Managed Extensibility Framework (MEF)
          NuGet
        Creating application components
        Building an application
        Conclusion
        Further information
        Q&A




DECEMBER 12, 2011 | SLIDE 5
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




DECEMBER 12, 2011 | SLIDE 6
DEPENDENCY INJECTION?


               I need a
                              var partA =
              “Part B” !      new PartA(new PartB())
                                                   Coming
                                                     up!




                                 Me on a
                                 typical
                                 work day




DECEMBER 12, 2011 | SLIDE 7
DEPENDENCY INJECTION?


               I need a
                                   Let me
                                    There
              “Part B” !
                                   you go!
                                    see...
                              Container




DECEMBER 12, 2011 | SLIDE 8
WHAT ABOUT ASP.NET MVC 3?
        ASP.NET MVC 3 uses DependencyResolver

        : IDependencyResolver
          GetService()
          GetServices()


        Register it on application start




DECEMBER 12, 2011 | SLIDE 9
WHAT ABOUT ASP.NET MVC 3?
       ASP.NET MVC will / can query the
        IDependencyResolver for
            Controllers                        Value providers
            View engines & view pages          Model binders
            Filters                            Controller activator
            Model validators                   View page activator
            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




DECEMBER 12, 2011 | SLIDE 10
in ASP.NET MVC 3

     DEPENDENCY INJECTION


DECEMBER 12, 2011 | SLIDE 11
MANAGED EXTENSIBILITY
 FRAMEWORK (MEF)
  Cool as ICE: Import, Compose, Export


           [Import]IRule rule;

                                           MEF catalog
                                    [Export(typeof(IRule)]

                                 Let me
                                  There
                                 you go!
                                  see...




DECEMBER 12, 2011 | SLIDE 12
MEF IN ASP.NET MVC 3


       Build an IDependencyResolver
          based on MEF container


       Use
            has a built-in IDependencyResolver
            has a “Convention” model
            is available on NuGet
            mefcontrib.codeplex.com




DECEMBER 12, 2011 | SLIDE 13
NUGET

        “NuGet is a Visual Studio extension that makes it easy to install
        and update open source libraries and tools in Visual Studio.”
                 Publish your own packages
            +    Create & use your own feed




DECEMBER 12, 2011 | SLIDE 14
and finding it on NuGet

     USING MEFCONTRIB


DECEMBER 12, 2011 | SLIDE 15
MEFCONTRIB.MVC3
       Optional addition for
       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




DECEMBER 12, 2011 | SLIDE 16
CONVENTIONS BASED MODEL
 public class MvcApplicationRegistry : PartRegistry {
   public MvcApplicationRegistry() {
     Scan(x => {
       x.Assembly(Assembly.GetExecutingAssembly());
       x.Directory(AppDomain.CurrentDomain.BaseDirectory + "bin");
     });

         Part()
           .ForTypesAssignableFrom<IController>()
           .MakeNonShared()
           .ExportTypeAs<IController>()
           .ExportType()
           .Imports(
             // ...
           );
     }
 }




DECEMBER 12, 2011 | SLIDE 17
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, thinking




DECEMBER 12, 2011 | SLIDE 18
CREATING APPLICATION
     COMPONENTS

DECEMBER 12, 2011 | SLIDE 19
WHAT’S NEXT?
       Building it
          MSBuild (or whatever! Nuget.exe is all that matters)
       Hosting it                 Install-Package NuGet.Server
          Create a NuGet server
          Drop everything in a folder
          Use a NaaS solution: www.myget.org
       Using it
          Reference the feed
          Download & install components needed
          Assemble using MEF (or another IoC)




DECEMBER 12, 2011 | SLIDE 20
A QUICK COMMERCIAL PLUG
       Create your own NuGet feed
       Packages from official feed
       Uploaded/pushed packages
       No need to setup & maintain your own NuGet Server
       Free! www.myget.org




DECEMBER 12, 2011 | SLIDE 21
CREATING A PRIVATE NUGET
     FEED

DECEMBER 12, 2011 | SLIDE 22
LET’S SEE IF WE CAN BUILD THIS...


         TPS Reports Cover Sheet Generator
                 (ASP.NET MVC 3)                                    Wired
  Domain layer                 Authentication         Theme
                                                                    with MEF

Domain.TpsReports              AccountController    Default theme




                                   Contracts
                                                                    Packaged
                                                                    as .nupkg
                                   And their
                               implementations...


DECEMBER 12, 2011 | SLIDE 23
Cover Sheet Generator

     BUILDING AN APPLICATION


DECEMBER 12, 2011 | SLIDE 24
CONCLUSION
       You can build an app like a Lego set
          Requires “bricks” (NuGet packages)
          Requires “glue” (MEF / MefContrib / 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)




DECEMBER 12, 2011 | SLIDE 25
FURTHER INFORMATION
       On the Internet:
          www.nuget.org
          www.myget.org
          mefcontrib.codeplex.com




DECEMBER 12, 2011 | SLIDE 26
THANK YOU FOR JOINING



                               Me, having
                               a question
DECEMBER 12, 2011 | SLIDE 27

Contenu connexe

Similaire à Fun with ASP.NET MVC3, MEF and NuGet

Fun with ASP.NET MVC 3, MEF and NuGet
Fun with ASP.NET MVC 3, MEF and NuGetFun with ASP.NET MVC 3, MEF and NuGet
Fun with ASP.NET MVC 3, MEF and NuGetMaarten Balliauw
 
Fun with ASP.NET MVC 3, MEF and NuGet (#comdaybe)
Fun with ASP.NET MVC 3, MEF and NuGet (#comdaybe)Fun with ASP.NET MVC 3, MEF and NuGet (#comdaybe)
Fun with ASP.NET MVC 3, MEF and NuGet (#comdaybe)Maarten Balliauw
 
Architecting for a cost effective Windows Azure solution
Architecting for a cost effective Windows Azure solutionArchitecting for a cost effective Windows Azure solution
Architecting for a cost effective Windows Azure solutionMaarten Balliauw
 
Windows Azure and the cloud - What it’s all about
Windows Azure and the cloud - What it’s all aboutWindows Azure and the cloud - What it’s all about
Windows Azure and the cloud - What it’s all aboutMaarten Balliauw
 
Oracle EBS 12.1.3 : Integrate OA Framework BC4J components within java concur...
Oracle EBS 12.1.3 : Integrate OA Framework BC4J components within java concur...Oracle EBS 12.1.3 : Integrate OA Framework BC4J components within java concur...
Oracle EBS 12.1.3 : Integrate OA Framework BC4J components within java concur...Amit Singh
 
Mobile ECM: Using the Nuxeo Platform from mobile devices
Mobile ECM: Using the Nuxeo Platform from mobile devicesMobile ECM: Using the Nuxeo Platform from mobile devices
Mobile ECM: Using the Nuxeo Platform from mobile devicesNuxeo
 
MSDN Live - CI using TFS11 & NuGet
MSDN Live - CI using TFS11 & NuGetMSDN Live - CI using TFS11 & NuGet
MSDN Live - CI using TFS11 & NuGetXavier Decoster
 
Architectural Patterns for the Cloud
Architectural Patterns for the CloudArchitectural Patterns for the Cloud
Architectural Patterns for the CloudMaarten Balliauw
 
HTML5: A complete overview
HTML5: A complete overviewHTML5: A complete overview
HTML5: A complete overviewKristof Degrave
 
Polymer / WebComponents
Polymer / WebComponentsPolymer / WebComponents
Polymer / WebComponentsArnaud Kervern
 
BUILDING WEB APPS WITH ASP.NET MVC AND NOSQL
BUILDING WEB APPS WITH ASP.NET MVC AND NOSQLBUILDING WEB APPS WITH ASP.NET MVC AND NOSQL
BUILDING WEB APPS WITH ASP.NET MVC AND NOSQLMichael Kennedy
 
Vb net xp_05
Vb net xp_05Vb net xp_05
Vb net xp_05Niit Care
 
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
 
SDC Sweden - Organize your chickens - NuGet for the Enterprise
SDC Sweden - Organize your chickens - NuGet for the EnterpriseSDC Sweden - Organize your chickens - NuGet for the Enterprise
SDC Sweden - Organize your chickens - NuGet for the EnterpriseMaarten Balliauw
 
Zero-downtime deployment of Micro-services with Kubernetes
Zero-downtime deployment of Micro-services with KubernetesZero-downtime deployment of Micro-services with Kubernetes
Zero-downtime deployment of Micro-services with KubernetesWojciech Barczyński
 
Programming with JavaFX
Programming with JavaFXProgramming with JavaFX
Programming with JavaFXFulvio Corno
 
Planbox Backbone MVC
Planbox Backbone MVCPlanbox Backbone MVC
Planbox Backbone MVCAcquisio
 
Getting started vmware apps
Getting started vmware appsGetting started vmware apps
Getting started vmware appsrickyelqasem
 

Similaire à Fun with ASP.NET MVC3, MEF and NuGet (20)

Fun with ASP.NET MVC 3, MEF and NuGet
Fun with ASP.NET MVC 3, MEF and NuGetFun with ASP.NET MVC 3, MEF and NuGet
Fun with ASP.NET MVC 3, MEF and NuGet
 
Fun with ASP.NET MVC 3, MEF and NuGet (#comdaybe)
Fun with ASP.NET MVC 3, MEF and NuGet (#comdaybe)Fun with ASP.NET MVC 3, MEF and NuGet (#comdaybe)
Fun with ASP.NET MVC 3, MEF and NuGet (#comdaybe)
 
Architecting for a cost effective Windows Azure solution
Architecting for a cost effective Windows Azure solutionArchitecting for a cost effective Windows Azure solution
Architecting for a cost effective Windows Azure solution
 
Windows Azure and the cloud - What it’s all about
Windows Azure and the cloud - What it’s all aboutWindows Azure and the cloud - What it’s all about
Windows Azure and the cloud - What it’s all about
 
iOS Design Patterns
iOS Design PatternsiOS Design Patterns
iOS Design Patterns
 
Oracle EBS 12.1.3 : Integrate OA Framework BC4J components within java concur...
Oracle EBS 12.1.3 : Integrate OA Framework BC4J components within java concur...Oracle EBS 12.1.3 : Integrate OA Framework BC4J components within java concur...
Oracle EBS 12.1.3 : Integrate OA Framework BC4J components within java concur...
 
Mobile ECM: Using the Nuxeo Platform from mobile devices
Mobile ECM: Using the Nuxeo Platform from mobile devicesMobile ECM: Using the Nuxeo Platform from mobile devices
Mobile ECM: Using the Nuxeo Platform from mobile devices
 
MSDN Live - CI using TFS11 & NuGet
MSDN Live - CI using TFS11 & NuGetMSDN Live - CI using TFS11 & NuGet
MSDN Live - CI using TFS11 & NuGet
 
Architectural Patterns for the Cloud
Architectural Patterns for the CloudArchitectural Patterns for the Cloud
Architectural Patterns for the Cloud
 
NInject - DI Container
NInject - DI ContainerNInject - DI Container
NInject - DI Container
 
HTML5: A complete overview
HTML5: A complete overviewHTML5: A complete overview
HTML5: A complete overview
 
Polymer / WebComponents
Polymer / WebComponentsPolymer / WebComponents
Polymer / WebComponents
 
BUILDING WEB APPS WITH ASP.NET MVC AND NOSQL
BUILDING WEB APPS WITH ASP.NET MVC AND NOSQLBUILDING WEB APPS WITH ASP.NET MVC AND NOSQL
BUILDING WEB APPS WITH ASP.NET MVC AND NOSQL
 
Vb net xp_05
Vb net xp_05Vb net xp_05
Vb net xp_05
 
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
 
SDC Sweden - Organize your chickens - NuGet for the Enterprise
SDC Sweden - Organize your chickens - NuGet for the EnterpriseSDC Sweden - Organize your chickens - NuGet for the Enterprise
SDC Sweden - Organize your chickens - NuGet for the Enterprise
 
Zero-downtime deployment of Micro-services with Kubernetes
Zero-downtime deployment of Micro-services with KubernetesZero-downtime deployment of Micro-services with Kubernetes
Zero-downtime deployment of Micro-services with Kubernetes
 
Programming with JavaFX
Programming with JavaFXProgramming with JavaFX
Programming with JavaFX
 
Planbox Backbone MVC
Planbox Backbone MVCPlanbox Backbone MVC
Planbox Backbone MVC
 
Getting started vmware apps
Getting started vmware appsGetting started vmware apps
Getting started vmware apps
 

Plus de 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
 

Plus de 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
 

Dernier

AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 

Dernier (20)

AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

Fun with ASP.NET MVC3, MEF and NuGet

  • 1. DECEMBER 12, 2011 | SLIDE 1
  • 2. www.realdolmen.com FUN WITH ASP.NET MVC 3, MEF AND NUGET DECEMBER 12, 2011 | SLIDE 2
  • 3. WHO AM I?  Maarten Balliauw  Antwerp, Belgium Me, looking  www.realdolmen.com intelligent with  Focus on web glasses  ASP.NET MVC, PHP, Azure, SignalR, …  MVP Windows Azure (formerly ASP.NET)  Co-founder of AZUG  http://blog.maartenballiauw.be  @maartenballiauw DECEMBER 12, 2011 | SLIDE 4
  • 4. AGENDA  Technologies & techniques used  ASP.NET MVC 3  Managed Extensibility Framework (MEF)  NuGet  Creating application components  Building an application  Conclusion  Further information  Q&A DECEMBER 12, 2011 | SLIDE 5
  • 5. 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 DECEMBER 12, 2011 | SLIDE 6
  • 6. DEPENDENCY INJECTION? I need a var partA = “Part B” ! new PartA(new PartB()) Coming up! Me on a typical work day DECEMBER 12, 2011 | SLIDE 7
  • 7. DEPENDENCY INJECTION? I need a Let me There “Part B” ! you go! see... Container DECEMBER 12, 2011 | SLIDE 8
  • 8. WHAT ABOUT ASP.NET MVC 3?  ASP.NET MVC 3 uses DependencyResolver  : IDependencyResolver  GetService()  GetServices()  Register it on application start DECEMBER 12, 2011 | SLIDE 9
  • 9. WHAT ABOUT ASP.NET MVC 3?  ASP.NET MVC will / can query the IDependencyResolver for  Controllers  Value providers  View engines & view pages  Model binders  Filters  Controller activator  Model validators  View page activator  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 DECEMBER 12, 2011 | SLIDE 10
  • 10. in ASP.NET MVC 3 DEPENDENCY INJECTION DECEMBER 12, 2011 | SLIDE 11
  • 11. MANAGED EXTENSIBILITY FRAMEWORK (MEF)  Cool as ICE: Import, Compose, Export [Import]IRule rule; MEF catalog [Export(typeof(IRule)] Let me There you go! see... DECEMBER 12, 2011 | SLIDE 12
  • 12. MEF IN ASP.NET MVC 3  Build an IDependencyResolver  based on MEF container  Use  has a built-in IDependencyResolver  has a “Convention” model  is available on NuGet  mefcontrib.codeplex.com DECEMBER 12, 2011 | SLIDE 13
  • 13. NUGET “NuGet is a Visual Studio extension that makes it easy to install and update open source libraries and tools in Visual Studio.” Publish your own packages + Create & use your own feed DECEMBER 12, 2011 | SLIDE 14
  • 14. and finding it on NuGet USING MEFCONTRIB DECEMBER 12, 2011 | SLIDE 15
  • 15. MEFCONTRIB.MVC3  Optional addition for  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 DECEMBER 12, 2011 | SLIDE 16
  • 16. CONVENTIONS BASED MODEL public class MvcApplicationRegistry : PartRegistry { public MvcApplicationRegistry() { Scan(x => { x.Assembly(Assembly.GetExecutingAssembly()); x.Directory(AppDomain.CurrentDomain.BaseDirectory + "bin"); }); Part() .ForTypesAssignableFrom<IController>() .MakeNonShared() .ExportTypeAs<IController>() .ExportType() .Imports( // ... ); } } DECEMBER 12, 2011 | SLIDE 17
  • 17. 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, thinking DECEMBER 12, 2011 | SLIDE 18
  • 18. CREATING APPLICATION COMPONENTS DECEMBER 12, 2011 | SLIDE 19
  • 19. WHAT’S NEXT?  Building it  MSBuild (or whatever! Nuget.exe is all that matters)  Hosting it Install-Package NuGet.Server  Create a NuGet server  Drop everything in a folder  Use a NaaS solution: www.myget.org  Using it  Reference the feed  Download & install components needed  Assemble using MEF (or another IoC) DECEMBER 12, 2011 | SLIDE 20
  • 20. A QUICK COMMERCIAL PLUG  Create your own NuGet feed  Packages from official feed  Uploaded/pushed packages  No need to setup & maintain your own NuGet Server  Free! www.myget.org DECEMBER 12, 2011 | SLIDE 21
  • 21. CREATING A PRIVATE NUGET FEED DECEMBER 12, 2011 | SLIDE 22
  • 22. LET’S SEE IF WE CAN BUILD THIS... TPS Reports Cover Sheet Generator (ASP.NET MVC 3) Wired Domain layer Authentication Theme with MEF Domain.TpsReports AccountController Default theme Contracts Packaged as .nupkg And their implementations... DECEMBER 12, 2011 | SLIDE 23
  • 23. Cover Sheet Generator BUILDING AN APPLICATION DECEMBER 12, 2011 | SLIDE 24
  • 24. CONCLUSION  You can build an app like a Lego set  Requires “bricks” (NuGet packages)  Requires “glue” (MEF / MefContrib / 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) DECEMBER 12, 2011 | SLIDE 25
  • 25. FURTHER INFORMATION  On the Internet:  www.nuget.org  www.myget.org  mefcontrib.codeplex.com DECEMBER 12, 2011 | SLIDE 26
  • 26. THANK YOU FOR JOINING Me, having a question DECEMBER 12, 2011 | SLIDE 27

Notes de l'éditeur

  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. Maarten
  3. 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
  4. 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!
  5. Tonen aparte directoryTonen NuGet.ServerTonen MyGet.org
  6. 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…