SlideShare a Scribd company logo
1 of 24
More object oriented development with Page Type Builder -or how to have a little more fun at work
Agenda Problems with the standard EPiSevermodel How Page TypeBuildersolves the problems How to use Page TypeBuilder Questions
The EPiServer Model PageType Is, sort of, an  instance of Decideswhich template to use PageData Page (.ASPX) Renderscontent from
Deardiary, today I… …created Page Types
Deardiary, today I… …addedproperties
Deardiary, today I… …addedmarkup to display properties
Deardiary, today I… …wrotesomecode
Deardiary, today I… …did a release
A few problems Wespend a lot of time not writingcode Wedefine ”templates” for objects in a webbased UI There’s no inheritancebetween page types Synchronizing different environments is a pain ObjectOrientation? Weuse a lot of ”magic strings” Weplacelogic in the presentation layer that doesn’tnecessarilybelongthere WedistinguishPageDataobjects by the ID of their Page Type
Whatif… Article Decideswhich template to use Actually is an instance of ArticlePage Page<Article> (.ASPX) Renderscontent from, knowing the type
Page TypeBuilder An opensourceproject Creates and updates page typesbased on classes Ensures that DataFactoryreturnsinstances of your classes
By using Page TypeBuilderwe get Less switchingbetween Visual Studio and Admin Inheritancebetween page types Stronglytyped access to properties The ability to placelogic in pages Polymorphism Faster and easier releases Bettertestability
Getting started Download from pagetypebuilder.codeplex.com ReferencePageTypeBuilder.dll CopyCastle.Core.dll and Castle.DynamicProxy2.dll to your bin folder
Creating a page type usingPageTypeBuilder; namespaceMySite.PageTypes { [PageType] public classArticle : TypedPageData     {     } }
Specifying settings [PageType( Filename ="/Templates/Article.aspx”, DefaultChildSortOrder =FilterSortOrder.Index)] public classArticle : TypedPageData { }
Addingproperties [PageType] public classArticle : TypedPageData { 	[PageTypeProperty] public virtual stringMainBody { get; set; } }
Specifyingproperty settings [PageType] public classArticle : TypedPageData { 	[PageTypeProperty( EditCaption ="Main body", HelpText = "Will be shown in the main content area of the page", Type = typeof(PropertyXhtmlString))] public virtual stringMainBody { get; set; } }
Creating a template usingPageTypeBuilder.UI; namespaceMySite.Templates { public partialclassArticle : TemplatePage<PageTypes.Article>     {     } }
Creating a template <%@ PageLanguage="C#"CodeBehind="Article.aspx.cs" Inherits="MySite.Templates.Article" MasterPageFile="~/Templates/MasterPages/MasterPage.master"%> <asp:ContentContentPlaceHolderID="MainBodyRegion"runat="server"> <%= CurrentPage.MainBody%> </asp:Content>
Addlogic to properties [PageTypeProperty(Type = typeof(PropertyString))] public string Heading { 	get { 	      string heading= this.GetPropertyValue(page => page.Heading); 	      if (!string.IsNullOrEmpty(heading)) 	          return heading; 	      return PageName; } }
Addingmethods to page types [PageType] public classArticle : TypedPageData {       publicIEnumerable<Comment> GetComments()       { return DataFactory.Instance.GetChildren(PageLink)                         .OfType<Comment>();       } }
DependencyInjection [PageType] public classArticle : TypedPageData { privateIPageSourcedataFactory; public Article(IPageSourcedataFactory) { this.dataFactory = dataFactory; }       publicIEnumerable<Comment> GetComments()       { returndataFactory.GetChildren(PageLink)                         	.OfType<Comment>();       } }
Where to learnmore pagetypebuilder.codeplex.com ,[object Object]
Links to 40+ blog posts,[object Object]

More Related Content

What's hot

Office 2013 loves web developers slide
Office 2013 loves web developers   slideOffice 2013 loves web developers   slide
Office 2013 loves web developers slideFabio Franzini
 
Active Server Page(ASP)
Active Server Page(ASP)Active Server Page(ASP)
Active Server Page(ASP)Keshab Nath
 
Industrial training seminar ppt on asp.net
Industrial training seminar ppt on asp.netIndustrial training seminar ppt on asp.net
Industrial training seminar ppt on asp.netPankaj Kushwaha
 
Sviluppare app per office
Sviluppare app per officeSviluppare app per office
Sviluppare app per officeFabio Franzini
 
Local storage in Web apps
Local storage in Web appsLocal storage in Web apps
Local storage in Web appsIvano Malavolta
 
Active server pages
Active server pagesActive server pages
Active server pagesmcatahir947
 
Come riprogettare le attuali farm solution di share point con il nuovo modell...
Come riprogettare le attuali farm solution di share point con il nuovo modell...Come riprogettare le attuali farm solution di share point con il nuovo modell...
Come riprogettare le attuali farm solution di share point con il nuovo modell...Fabio Franzini
 
tTecniche di sviluppo mobile per share point 2013 e office 365
tTecniche di sviluppo mobile per share point 2013 e office 365 tTecniche di sviluppo mobile per share point 2013 e office 365
tTecniche di sviluppo mobile per share point 2013 e office 365 Fabio Franzini
 
Web components
Web componentsWeb components
Web componentsNoam Kfir
 
Google Developer Group(GDG) DevFest Event 2012 Android talk
Google Developer Group(GDG) DevFest Event 2012 Android talkGoogle Developer Group(GDG) DevFest Event 2012 Android talk
Google Developer Group(GDG) DevFest Event 2012 Android talkImam Raza
 
SPSNH 2014 - The SharePoint & jQueryGuide
SPSNH 2014 - The SharePoint & jQueryGuideSPSNH 2014 - The SharePoint & jQueryGuide
SPSNH 2014 - The SharePoint & jQueryGuideMark Rackley
 
Bridging the Gap: Single-Page Apps and AEM
Bridging the Gap: Single-Page Apps and AEMBridging the Gap: Single-Page Apps and AEM
Bridging the Gap: Single-Page Apps and AEMrbl002
 
Your First ASP_Net project part 1
Your First ASP_Net project part 1Your First ASP_Net project part 1
Your First ASP_Net project part 1Biswadip Goswami
 
Build single page applications using AngularJS on AEM
Build single page applications using AngularJS on AEMBuild single page applications using AngularJS on AEM
Build single page applications using AngularJS on AEMAdobeMarketingCloud
 
Introduction to Plugin Programming, WordCamp Miami 2011
Introduction to Plugin Programming, WordCamp Miami 2011Introduction to Plugin Programming, WordCamp Miami 2011
Introduction to Plugin Programming, WordCamp Miami 2011David Carr
 
Creating a Data Driven UI Framework
Creating a Data Driven UI FrameworkCreating a Data Driven UI Framework
Creating a Data Driven UI FrameworkAnkur Bansal
 

What's hot (20)

Office 2013 loves web developers slide
Office 2013 loves web developers   slideOffice 2013 loves web developers   slide
Office 2013 loves web developers slide
 
Asp net
Asp netAsp net
Asp net
 
Active Server Page(ASP)
Active Server Page(ASP)Active Server Page(ASP)
Active Server Page(ASP)
 
Industrial training seminar ppt on asp.net
Industrial training seminar ppt on asp.netIndustrial training seminar ppt on asp.net
Industrial training seminar ppt on asp.net
 
Sviluppare app per office
Sviluppare app per officeSviluppare app per office
Sviluppare app per office
 
Local storage in Web apps
Local storage in Web appsLocal storage in Web apps
Local storage in Web apps
 
Active server pages
Active server pagesActive server pages
Active server pages
 
Come riprogettare le attuali farm solution di share point con il nuovo modell...
Come riprogettare le attuali farm solution di share point con il nuovo modell...Come riprogettare le attuali farm solution di share point con il nuovo modell...
Come riprogettare le attuali farm solution di share point con il nuovo modell...
 
Apex & jQuery Mobile
Apex & jQuery MobileApex & jQuery Mobile
Apex & jQuery Mobile
 
Introduction to asp
Introduction to aspIntroduction to asp
Introduction to asp
 
tTecniche di sviluppo mobile per share point 2013 e office 365
tTecniche di sviluppo mobile per share point 2013 e office 365 tTecniche di sviluppo mobile per share point 2013 e office 365
tTecniche di sviluppo mobile per share point 2013 e office 365
 
Web components
Web componentsWeb components
Web components
 
Google Developer Group(GDG) DevFest Event 2012 Android talk
Google Developer Group(GDG) DevFest Event 2012 Android talkGoogle Developer Group(GDG) DevFest Event 2012 Android talk
Google Developer Group(GDG) DevFest Event 2012 Android talk
 
SPSNH 2014 - The SharePoint & jQueryGuide
SPSNH 2014 - The SharePoint & jQueryGuideSPSNH 2014 - The SharePoint & jQueryGuide
SPSNH 2014 - The SharePoint & jQueryGuide
 
Bridging the Gap: Single-Page Apps and AEM
Bridging the Gap: Single-Page Apps and AEMBridging the Gap: Single-Page Apps and AEM
Bridging the Gap: Single-Page Apps and AEM
 
Learn ASP
Learn ASPLearn ASP
Learn ASP
 
Your First ASP_Net project part 1
Your First ASP_Net project part 1Your First ASP_Net project part 1
Your First ASP_Net project part 1
 
Build single page applications using AngularJS on AEM
Build single page applications using AngularJS on AEMBuild single page applications using AngularJS on AEM
Build single page applications using AngularJS on AEM
 
Introduction to Plugin Programming, WordCamp Miami 2011
Introduction to Plugin Programming, WordCamp Miami 2011Introduction to Plugin Programming, WordCamp Miami 2011
Introduction to Plugin Programming, WordCamp Miami 2011
 
Creating a Data Driven UI Framework
Creating a Data Driven UI FrameworkCreating a Data Driven UI Framework
Creating a Data Driven UI Framework
 

Viewers also liked

Progressive EPiServer Development
Progressive EPiServer DevelopmentProgressive EPiServer Development
Progressive EPiServer Developmentjoelabrahamsson
 
En introduktion till SOLID-principerna
En introduktion till SOLID-principernaEn introduktion till SOLID-principerna
En introduktion till SOLID-principernajoelabrahamsson
 
The Total Book Developing Solutions With EPiServer 4
The Total Book Developing Solutions With EPiServer 4The Total Book Developing Solutions With EPiServer 4
The Total Book Developing Solutions With EPiServer 4Martin Edenström MKSE.com
 
Automated Testing Of EPiServer CMS Sites
Automated Testing Of EPiServer CMS SitesAutomated Testing Of EPiServer CMS Sites
Automated Testing Of EPiServer CMS Sitesjoelabrahamsson
 
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika AldabaLightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldabaux singapore
 

Viewers also liked (7)

Progressive EPiServer Development
Progressive EPiServer DevelopmentProgressive EPiServer Development
Progressive EPiServer Development
 
En introduktion till SOLID-principerna
En introduktion till SOLID-principernaEn introduktion till SOLID-principerna
En introduktion till SOLID-principerna
 
The Total Book Developing Solutions With EPiServer 4
The Total Book Developing Solutions With EPiServer 4The Total Book Developing Solutions With EPiServer 4
The Total Book Developing Solutions With EPiServer 4
 
Automated Testing Of EPiServer CMS Sites
Automated Testing Of EPiServer CMS SitesAutomated Testing Of EPiServer CMS Sites
Automated Testing Of EPiServer CMS Sites
 
EPiServer Deployment Tips & Tricks
EPiServer Deployment Tips & TricksEPiServer Deployment Tips & Tricks
EPiServer Deployment Tips & Tricks
 
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job? Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
 
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika AldabaLightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
 

Similar to More fun object oriented development with Page Type Builder

Templates
TemplatesTemplates
Templatessoon
 
The Django Web Application Framework 2
The Django Web Application Framework 2The Django Web Application Framework 2
The Django Web Application Framework 2fishwarter
 
The Django Web Application Framework 2
The Django Web Application Framework 2The Django Web Application Framework 2
The Django Web Application Framework 2fishwarter
 
The Django Web Application Framework 2
The Django Web Application Framework 2The Django Web Application Framework 2
The Django Web Application Framework 2fishwarter
 
The Django Web Application Framework 2
The Django Web Application Framework 2The Django Web Application Framework 2
The Django Web Application Framework 2fishwarter
 
Advanced SharePoint 2010 and 2013 Web Part Development by Rob Windsor - SPTec...
Advanced SharePoint 2010 and 2013 Web Part Development by Rob Windsor - SPTec...Advanced SharePoint 2010 and 2013 Web Part Development by Rob Windsor - SPTec...
Advanced SharePoint 2010 and 2013 Web Part Development by Rob Windsor - SPTec...SPTechCon
 
Advanced SharePoint Web Part Development
Advanced SharePoint Web Part DevelopmentAdvanced SharePoint Web Part Development
Advanced SharePoint Web Part DevelopmentRob Windsor
 
04 asp.net session05
04 asp.net session0504 asp.net session05
04 asp.net session05Vivek chan
 
Introduction To Code Igniter
Introduction To Code IgniterIntroduction To Code Igniter
Introduction To Code IgniterAmzad Hossain
 
Web Development for UX Designers
Web Development for UX DesignersWeb Development for UX Designers
Web Development for UX DesignersAshlimarie
 
Building Your First Store App with XAML and C#
Building Your First Store App with XAML and C#Building Your First Store App with XAML and C#
Building Your First Store App with XAML and C#Tamir Dresher
 
JavaScript front end performance optimizations
JavaScript front end performance optimizationsJavaScript front end performance optimizations
JavaScript front end performance optimizationsChris Love
 
SharePoint Cincy 2012 - jQuery essentials
SharePoint Cincy 2012 - jQuery essentialsSharePoint Cincy 2012 - jQuery essentials
SharePoint Cincy 2012 - jQuery essentialsMark Rackley
 
Asp.Net 2.0 Presentation
Asp.Net 2.0 PresentationAsp.Net 2.0 Presentation
Asp.Net 2.0 Presentationsasidhar
 
d.mix: Programming by a Sample
d.mix: Programming by a Sampled.mix: Programming by a Sample
d.mix: Programming by a SampleLeslie W
 
Decoding the Web
Decoding the WebDecoding the Web
Decoding the Webnewcircle
 
JavaScript: Ajax & DOM Manipulation
JavaScript: Ajax & DOM ManipulationJavaScript: Ajax & DOM Manipulation
JavaScript: Ajax & DOM Manipulationborkweb
 
Intro to mobile web application development
Intro to mobile web application developmentIntro to mobile web application development
Intro to mobile web application developmentzonathen
 

Similar to More fun object oriented development with Page Type Builder (20)

Templates
TemplatesTemplates
Templates
 
Javascript projects Course
Javascript projects CourseJavascript projects Course
Javascript projects Course
 
The Django Web Application Framework 2
The Django Web Application Framework 2The Django Web Application Framework 2
The Django Web Application Framework 2
 
The Django Web Application Framework 2
The Django Web Application Framework 2The Django Web Application Framework 2
The Django Web Application Framework 2
 
The Django Web Application Framework 2
The Django Web Application Framework 2The Django Web Application Framework 2
The Django Web Application Framework 2
 
The Django Web Application Framework 2
The Django Web Application Framework 2The Django Web Application Framework 2
The Django Web Application Framework 2
 
Advanced SharePoint 2010 and 2013 Web Part Development by Rob Windsor - SPTec...
Advanced SharePoint 2010 and 2013 Web Part Development by Rob Windsor - SPTec...Advanced SharePoint 2010 and 2013 Web Part Development by Rob Windsor - SPTec...
Advanced SharePoint 2010 and 2013 Web Part Development by Rob Windsor - SPTec...
 
Advanced SharePoint Web Part Development
Advanced SharePoint Web Part DevelopmentAdvanced SharePoint Web Part Development
Advanced SharePoint Web Part Development
 
04 asp.net session05
04 asp.net session0504 asp.net session05
04 asp.net session05
 
Introduction To Code Igniter
Introduction To Code IgniterIntroduction To Code Igniter
Introduction To Code Igniter
 
Web Development for UX Designers
Web Development for UX DesignersWeb Development for UX Designers
Web Development for UX Designers
 
Building Your First Store App with XAML and C#
Building Your First Store App with XAML and C#Building Your First Store App with XAML and C#
Building Your First Store App with XAML and C#
 
JavaScript front end performance optimizations
JavaScript front end performance optimizationsJavaScript front end performance optimizations
JavaScript front end performance optimizations
 
Master page
Master pageMaster page
Master page
 
SharePoint Cincy 2012 - jQuery essentials
SharePoint Cincy 2012 - jQuery essentialsSharePoint Cincy 2012 - jQuery essentials
SharePoint Cincy 2012 - jQuery essentials
 
Asp.Net 2.0 Presentation
Asp.Net 2.0 PresentationAsp.Net 2.0 Presentation
Asp.Net 2.0 Presentation
 
d.mix: Programming by a Sample
d.mix: Programming by a Sampled.mix: Programming by a Sample
d.mix: Programming by a Sample
 
Decoding the Web
Decoding the WebDecoding the Web
Decoding the Web
 
JavaScript: Ajax & DOM Manipulation
JavaScript: Ajax & DOM ManipulationJavaScript: Ajax & DOM Manipulation
JavaScript: Ajax & DOM Manipulation
 
Intro to mobile web application development
Intro to mobile web application developmentIntro to mobile web application development
Intro to mobile web application development
 

Recently uploaded

Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Scott Andery
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 

Recently uploaded (20)

Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 

More fun object oriented development with Page Type Builder

  • 1. More object oriented development with Page Type Builder -or how to have a little more fun at work
  • 2. Agenda Problems with the standard EPiSevermodel How Page TypeBuildersolves the problems How to use Page TypeBuilder Questions
  • 3. The EPiServer Model PageType Is, sort of, an instance of Decideswhich template to use PageData Page (.ASPX) Renderscontent from
  • 4. Deardiary, today I… …created Page Types
  • 5. Deardiary, today I… …addedproperties
  • 6. Deardiary, today I… …addedmarkup to display properties
  • 7. Deardiary, today I… …wrotesomecode
  • 8. Deardiary, today I… …did a release
  • 9. A few problems Wespend a lot of time not writingcode Wedefine ”templates” for objects in a webbased UI There’s no inheritancebetween page types Synchronizing different environments is a pain ObjectOrientation? Weuse a lot of ”magic strings” Weplacelogic in the presentation layer that doesn’tnecessarilybelongthere WedistinguishPageDataobjects by the ID of their Page Type
  • 10. Whatif… Article Decideswhich template to use Actually is an instance of ArticlePage Page<Article> (.ASPX) Renderscontent from, knowing the type
  • 11. Page TypeBuilder An opensourceproject Creates and updates page typesbased on classes Ensures that DataFactoryreturnsinstances of your classes
  • 12. By using Page TypeBuilderwe get Less switchingbetween Visual Studio and Admin Inheritancebetween page types Stronglytyped access to properties The ability to placelogic in pages Polymorphism Faster and easier releases Bettertestability
  • 13. Getting started Download from pagetypebuilder.codeplex.com ReferencePageTypeBuilder.dll CopyCastle.Core.dll and Castle.DynamicProxy2.dll to your bin folder
  • 14. Creating a page type usingPageTypeBuilder; namespaceMySite.PageTypes { [PageType] public classArticle : TypedPageData { } }
  • 15. Specifying settings [PageType( Filename ="/Templates/Article.aspx”, DefaultChildSortOrder =FilterSortOrder.Index)] public classArticle : TypedPageData { }
  • 16. Addingproperties [PageType] public classArticle : TypedPageData { [PageTypeProperty] public virtual stringMainBody { get; set; } }
  • 17. Specifyingproperty settings [PageType] public classArticle : TypedPageData { [PageTypeProperty( EditCaption ="Main body", HelpText = "Will be shown in the main content area of the page", Type = typeof(PropertyXhtmlString))] public virtual stringMainBody { get; set; } }
  • 18. Creating a template usingPageTypeBuilder.UI; namespaceMySite.Templates { public partialclassArticle : TemplatePage<PageTypes.Article> { } }
  • 19. Creating a template <%@ PageLanguage="C#"CodeBehind="Article.aspx.cs" Inherits="MySite.Templates.Article" MasterPageFile="~/Templates/MasterPages/MasterPage.master"%> <asp:ContentContentPlaceHolderID="MainBodyRegion"runat="server"> <%= CurrentPage.MainBody%> </asp:Content>
  • 20. Addlogic to properties [PageTypeProperty(Type = typeof(PropertyString))] public string Heading { get { string heading= this.GetPropertyValue(page => page.Heading); if (!string.IsNullOrEmpty(heading)) return heading; return PageName; } }
  • 21. Addingmethods to page types [PageType] public classArticle : TypedPageData { publicIEnumerable<Comment> GetComments() { return DataFactory.Instance.GetChildren(PageLink) .OfType<Comment>(); } }
  • 22. DependencyInjection [PageType] public classArticle : TypedPageData { privateIPageSourcedataFactory; public Article(IPageSourcedataFactory) { this.dataFactory = dataFactory; } publicIEnumerable<Comment> GetComments() { returndataFactory.GetChildren(PageLink) .OfType<Comment>(); } }
  • 23.
  • 24.

Editor's Notes

  1. Three of the mostimportantcomponentswhendeveloping with EPiServer is Page Types, PageDataobjects and templates.A PageDataobject is sort of an instance of a PageType. A PageType is sort of like class, but not quite. Let’stake a look at whatimplications this has for oureveryday work.
  2. Wecreate page types in EPiServer’sadmin mode.
  3. Weaddproperties to page types, again in EPiServer’sadmin mode.
  4. Weaddmarkup to pages and usercontrols, oftenusingwebcontrols that ship with EPiServer, to display the properties.
  5. Whenweneedsomecustombehaviorweadd it to pages,customcontrols or some sort of utilityclasses.
  6. Althoughweuse a staticallytypedlanguageweuse a lot of magic strings and therebybypass the checks performed by the compiler.It can be discussed, but I personallydon’tthink that determiningwhat to display as a heading for a page is the presentation layer’sjob, it’s the page’s.Since all pages are just instance of PageDatawehave to rely on filtering by numericalID’swhenwewant to find pages of a certain page type. This is extra problematicwhenwewant pages that may be of several different page typessincethere’s no inheritancebetween page types and theycan’timplement interfaces.
  7. What if each page type was actually a class? And whatifeachPageDataobjectwas an instance of that class? And whatif the templateknewwhichtype, or basetype, it was rendering?If that was the casewewouldhaveinheritancebetween page types. Wecouldstrongly access propertyvalues. And wecouldeasily filter pages not only by typebutalso by whetherit’stypeimplements an interface or not.
  8. Page TypeBuildersolves this (the previousslide).Page TypeBuilderdoesquite a lot of things, but the twomostimportantthings is that it creates and updates page typebased on classes that we, or third party products, candefine and that it interceptsrequests for PageDataobjects to DataFactory’smethods and replaces the objects that theyreturn with instances of the class that defines the page’s page type.
  9. As wedefine page types in code all wehave to do to add or update page types, properties and tabs is writecode, compile and go to the site.As classes are used to define page typesweeffectively get inheritancebetween page types.SinceDataFactorynowreturnsinstances of ourclasseswe get stronglytyped access to propertyvalues.Another benefit of DataFactoryreturninginstances of ourclassesinstead of just PageData is that wecanplacelogic in theseclasses. I’llsoon show a couple of example of how this can work.Aseach page is an instance of a class that canhaveit’sownspecificbehaviour and alsoimplement interfaces wecanusepolymorphism. That is several page typescanhave the same method with the same signature that is implemented in different ways. Wecanthenusecode that is uses this methodbutdoesn’tknowaboutit’simplementation.Since Page TypeBuilderadds and updates page types, properties and tabs all wehave to dowhenwewantneed to do a release that involves page typechanges is to deployourassemblies.The moreobjectorientedway of working with Page TypeBuildercan a cornerstone in writingcode that it’spossible to writeunit tests for. Page TypeBuilderalso offers a moreconcreteadvantagewhen it comes to testing. Sincewecanmovesomelogic from the hard-to-test presentation layerintoour page typeclasses, and Page TypeBuilder has a feature for injectingdependenciesintoPageDataobjectswecanputquiteeasily test it.
  10. I’veputsomeeffortintomaking it as easy as possible to get started with Page TypeBuilder. This meansthere’s no configuration or installationrequired. All you have to do is download it and put the assemblies that the Zipfilecontainsinto your bin folder and add a reference to PageTypeBuilder.dll.Of course, in a realistic scenario you wouldprobablywant to putthird party libraries like this somewhereelse and havethemautomaticallycopied to your bin folder when you compile. In that case you need to ensure that the two Castle assemblies are copied to the bin folder as Page TypeBuilder is dependent on them.PageTypeBuilderrequires EPiServer CMS 5 R2 SP2 or EPiServer CMS 6.
  11. To create a page type all you have to do is add a new class in your project that inherits from TypedPageData and has a PageTypeattribute. Given thesefewlines of code Page TypeBuilderwillcreate a new page typenamedArticle as soon as you compile and browse the site.Normallywhenwecreate a page typewehave to specify a fewthingssuch as a path to the template that shouldrender the page type. Page TypeBuilderdoesn’t force us to do this and instead has a fewconventions. For instance, ifwedon’tspecify a path to the template it willautomatically be set to default.aspx.
  12. By setting properties on the PageTypeattributewecanspecifyevery setting for a page type that wecanspecify in EPiServer’sadmin mode.By default the name of the page typewill be the class’ namebutwecanspecify that as wellusing the PageTypeproperty. Be awarethough that the name is used to identify the page type.
  13. Tocreateproperties all wehave to do is add a codeproperty to a page typeclass and add a PageTypePropertyattribute to it.Again Page TypeBuilderwilluseit’s default conventions for mandatory settings. For instance, codeproperties of type string willautomatically be created as XHTML string properties.
  14. Just as for page typeswecanuseproperties of the PageTypePropertyattribute to specifyeverything that wecanspecify in admin mode. However, it does not handle the new property settings that wasintroduced in EPiServer CMS 6. At least not yet.
  15. Oncewehave a page typewewillprobablywant to render it using a template. Creating templateswhenusing Page TypeBuilder is verysimillar to how you do it when you aren’tusing Page TypeBuilder. The onlydifference, which is optional, is that you inherit from Page TypeBuilder’sgenericTemplatePage, or UserControllBase, instead of the EPiServer equivalents. These in turninherit from EPiServer’sclasses with the same name so no functionality is lost.
  16. By inheriting from Page TypeBuildersgenericbaseclasses for pages or usercontrols the CurrentPagepropertywill be of the specifiedtype, enablingstronglytyped access to the currentpage’sproperties.
  17. Previouslywesaw a verybasicimplementation of a propertyusingautomatic getters and setters. Wecanalsoimplementpropertiesusing an extension method for PageDatanamedGetPropertyValue. This waywecancreateproperties with logic in them. In this casewe check if the headingproperty is set and return it if it is. If it isn’twereturn the page’sname. This waywhenwewant to display a heading for the page wedon’thave to createanyconditionallogic, just display the page’sHeadingcodeproperty. This wayweencapsulate data where it belong and we get less code repetition.
  18. AsDataFactorynowreturnsinstances of ourclasseswecan not just addlogic to properties. Wecanalsoaddregularmethods to our page types.This exampleillustratestwothings. First of all that wecanadd a methodsuch as GetComments to ourArticle page typeclass. Second that wecan filter pages by type.In a real scenarioweprobablywouldn’twant to callDataFactory.Instance from the methodbutinject an instance of an interface into the object.