SlideShare ist ein Scribd-Unternehmen logo
1 von 25
Policy Injection in ASP.NET  using Enterprise Library 3.0 Alex Homer [email_address] http://www.daveandal.net
Agenda ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Terminology and Buzzwords ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
What are Crosscutting Concerns? Core Concerns Application Business  Object Business  Object Data Access Object Application Business  Object Data Access Object Validation Logging Exception Handling Caching Authorization Crosscutting Concerns Performance Counters
What is Policy Injection? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The Handlers Pipeline ,[object Object],[object Object],[object Object],[object Object]
Interceptable Object Types (1) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],VB.NET: object  = PolicyInjection.Create(Of  type )( ctor_params ) object  = PolicyInjection.Create(Of  type )(IConfigurationSource,  params ) object  = PolicyInjection.Wrap(Of  type )( existing_object ) object  = PolicyInjection.Wrap(Of  type )(IConfigurationSource,  object ) C# Visual Basic .NET
Interceptable Object Types (2) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],C# interface  = PolicyInjection.Create(Of  type ,  interface )( ctor_params ) interface  = PolicyInjection.Create (Of  type ,  interface ) _ (IConfigurationSource,  ctor_params ) interface  = PolicyInjection.Wrap (Of  interface )  ( existing_object ) interface  = PolicyInjection.Wrap (Of  interface ) _ (IConfigurationSource,  existing_object ) Visual Basic .NET
Configuring Policies ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Configuring Policies Demo Demo
Demo Business Object Members Public members exposed by the two business objects Member Attributed Customer Model Interface Customer Model Notes GetCustomerList()   GetCustomerName(customerID)   GetCustomerNameWithWildcard (customerID)   Uses GetCustomerName method with a wildcard. GetCustomerDetails(customerID)   Not defined in interface. GetCityList(minimumCount)   CityCount   Property. Uses GetCityList
Demo Policies The policies defined in the example application Policy Name Matching Rules Call Handlers InterfaceModelPolicy Member Name = GetCustomerNameWithWildcard or GetCustomerList Type Name = InterfaceCustomerModel Logging Handler with Categories = "AuditFile" and "EventLog" Caching Handler with cache duration 20 seconds Exception Handler with Exception Policy = "CustomerModelPolicy” AttributeModelPolicy Method Signature, Name = * and parameter = System.String Type Name = AttributedCustomerModel Logging Handler with Categories = "AuditFile" CacheByTagPolicy Tag Attribute = "ApplyTenSecondCaching" Caching Handler with cache duration 10 seconds
Using Attributes (1) ,[object Object],[CachingCallHandler(0, 0, 30)] public DataTable GetCustomerList() { … } C# <CachingCallHandler(0, 0, 30)> _ Public Sub GetCustomerList() As  DataTable  … End Sub Visual Basic .NET
Using Attributes (2) ,[object Object],[ValidationCallHandler] [ValidationCallHandler] public String GetCustomerName( [StringLengthValidator(3, RangeBoundaryType.Inclusive,  5, RangeBoundaryType.Inclusive)]  String customerID) C# <ValidationCallHandler()> _ Public Function GetCustomerName( _ <StringLengthValidator(3, RangeBoundaryType.Inclusive, _ 5, RangeBoundaryType.Inclusive)> _ ByVal customerID As String) As  String  Visual Basic .NET
Using Attributes (3) ,[object Object],[ApplyNoPolicies] public DataTable GetCustomerList() … C# <  ApplyNoPolicies > _ Public Sub GetCustomerList() As  DataTable  … Visual Basic .NET ,[object Object],[object Object]
Using Attributes Demo Demo
Factory Proxy Handlers Matching  Rules Pipeline
Extending the PIAB ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Inside a Matching Rule ,[object Object],[object Object],[object Object],[object Object],// for example… the built-in Tag Attribute Matching Rule uses: public bool Matches(MethodBase member) { foreach (TagAttribute tagAttribute in GetAllAttributes(member, true)) { if (string.Compare(tagAttribute.Tag, tagToMatch, ignoreCase) == 0) return true; } return false; }
Inside a Pipeline Handler ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Handler Process Overview public class ExampleHandler : ICallHandler { public IMethodReturn Invoke(IMethodInvocation  input , GetNextHandlerDelegate  getNext ) { // Perform any pre-processing tasks required in the custom handler. ... // Invoke next handler that the block should execute. This code gets the current return message that you must pass back to the caller: IMethodReturn msg = getNext()(input, getNext);  ... // Perform any post-processing tasks required in the custom handler. // You can modify the return message if required. // Return the message to the previous handler or the client.  return msg; }
Messages and Short-Circuiting Each handler invokes the next one, passing the invocation message along the pipeline and the return message back again A handler can instead simply refuse to call the next handler, and can add information (e.g. an exception) to the return message. Note that previous handlers still execute
Short-Circuiting Execution public IMethodReturn Invoke(IMethodInvocation  input , GetNextHandlerDelegate  getNext ) { GregorianCalendar cal = new GregorianCalendar(); DayOfWeek weekDay = cal.GetDayOfWeek(DateTime.Now); if (weekDay == DayOfWeek.Saturday || weekDay == DayOfWeek.Sunday)  { // create an Exception to return and the return message. Exception ex = new Exception(&quot;Available on weekdays only&quot;); IMethodReturn msg = input.CreateExceptionMethodReturn(ex) return msg;  } else { return getNext()(input, getNext);  // invoke the next handler  }
Custom Handler Attributes [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property |  AttributeTargets.Method)] public class CachingCallHandlerAttribute : HandlerAttribute { private TimeSpan expirationTime; public CachingCallHandlerAttribute(int  hours , int  minutes , int  seconds ) {  // constructor, save the parameter values expirationTime = new TimeSpan(hours, minutes, seconds); } public override ICallHandler CreateHandler() {  // create the appropriate handler instance and return it return new CachingCallHandler(expirationTime); } }
References ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],http://www.codeplex.com

Weitere ähnliche Inhalte

Was ist angesagt?

GWT integration with Vaadin
GWT integration with VaadinGWT integration with Vaadin
GWT integration with VaadinPeter Lehto
 
ASP.NET MVC 3.0 Validation
ASP.NET MVC 3.0 ValidationASP.NET MVC 3.0 Validation
ASP.NET MVC 3.0 ValidationEyal Vardi
 
Object Oreinted Approach in Coldfusion
Object Oreinted Approach in ColdfusionObject Oreinted Approach in Coldfusion
Object Oreinted Approach in Coldfusionguestcc9fa5
 
Il n'y a pas que Polymer dans la vie… - RennesJS - 2017-06-27
Il n'y a pas que Polymer dans la vie… - RennesJS - 2017-06-27Il n'y a pas que Polymer dans la vie… - RennesJS - 2017-06-27
Il n'y a pas que Polymer dans la vie… - RennesJS - 2017-06-27Horacio Gonzalez
 
[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (3/3)
[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (3/3)[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (3/3)
[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (3/3)Carles Farré
 
MongoDB Stitch Tutorial
MongoDB Stitch TutorialMongoDB Stitch Tutorial
MongoDB Stitch TutorialMongoDB
 
Michał Kopacz: Ports and adapters architecture for business processes
Michał Kopacz: Ports and adapters architecture for business processesMichał Kopacz: Ports and adapters architecture for business processes
Michał Kopacz: Ports and adapters architecture for business processesRST Software Masters
 
Udi Dahan Intentions And Interfaces
Udi Dahan Intentions And InterfacesUdi Dahan Intentions And Interfaces
Udi Dahan Intentions And Interfacesdeimos
 
Introduction to Google Guice
Introduction to Google GuiceIntroduction to Google Guice
Introduction to Google GuiceKnoldus Inc.
 
Mvc & java script
Mvc & java scriptMvc & java script
Mvc & java scriptEyal Vardi
 
Adopting F# at SBTech
Adopting F# at SBTechAdopting F# at SBTech
Adopting F# at SBTechAntya Dev
 
Vaadin DevDay 2017 - Data Binding in Vaadin 8
Vaadin DevDay 2017 - Data Binding in Vaadin 8Vaadin DevDay 2017 - Data Binding in Vaadin 8
Vaadin DevDay 2017 - Data Binding in Vaadin 8Peter Lehto
 

Was ist angesagt? (20)

Jsr 303
Jsr 303Jsr 303
Jsr 303
 
GWT integration with Vaadin
GWT integration with VaadinGWT integration with Vaadin
GWT integration with Vaadin
 
ASP.NET MVC 3.0 Validation
ASP.NET MVC 3.0 ValidationASP.NET MVC 3.0 Validation
ASP.NET MVC 3.0 Validation
 
JavaScript Refactoring
JavaScript RefactoringJavaScript Refactoring
JavaScript Refactoring
 
Object Oreinted Approach in Coldfusion
Object Oreinted Approach in ColdfusionObject Oreinted Approach in Coldfusion
Object Oreinted Approach in Coldfusion
 
Devoxx 2012 (v2)
Devoxx 2012 (v2)Devoxx 2012 (v2)
Devoxx 2012 (v2)
 
Il n'y a pas que Polymer dans la vie… - RennesJS - 2017-06-27
Il n'y a pas que Polymer dans la vie… - RennesJS - 2017-06-27Il n'y a pas que Polymer dans la vie… - RennesJS - 2017-06-27
Il n'y a pas que Polymer dans la vie… - RennesJS - 2017-06-27
 
[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (3/3)
[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (3/3)[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (3/3)
[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (3/3)
 
MongoDB Stitch Tutorial
MongoDB Stitch TutorialMongoDB Stitch Tutorial
MongoDB Stitch Tutorial
 
Michał Kopacz: Ports and adapters architecture for business processes
Michał Kopacz: Ports and adapters architecture for business processesMichał Kopacz: Ports and adapters architecture for business processes
Michał Kopacz: Ports and adapters architecture for business processes
 
Graphql, REST and Apollo
Graphql, REST and ApolloGraphql, REST and Apollo
Graphql, REST and Apollo
 
Backbone Basics with Examples
Backbone Basics with ExamplesBackbone Basics with Examples
Backbone Basics with Examples
 
J2EE jsp_03
J2EE jsp_03J2EE jsp_03
J2EE jsp_03
 
Udi Dahan Intentions And Interfaces
Udi Dahan Intentions And InterfacesUdi Dahan Intentions And Interfaces
Udi Dahan Intentions And Interfaces
 
Introduction to Google Guice
Introduction to Google GuiceIntroduction to Google Guice
Introduction to Google Guice
 
Domain Driven Design 101
Domain Driven Design 101Domain Driven Design 101
Domain Driven Design 101
 
Mvc & java script
Mvc & java scriptMvc & java script
Mvc & java script
 
Adopting F# at SBTech
Adopting F# at SBTechAdopting F# at SBTech
Adopting F# at SBTech
 
Vaadin DevDay 2017 - Data Binding in Vaadin 8
Vaadin DevDay 2017 - Data Binding in Vaadin 8Vaadin DevDay 2017 - Data Binding in Vaadin 8
Vaadin DevDay 2017 - Data Binding in Vaadin 8
 
Solving the n + 1 query problem
Solving the n + 1 query problemSolving the n + 1 query problem
Solving the n + 1 query problem
 

Ähnlich wie Policy Injection in ASP.NET using Enterprise Library 3.0

Diving in the Flex Data Binding Waters
Diving in the Flex Data Binding WatersDiving in the Flex Data Binding Waters
Diving in the Flex Data Binding Watersmichael.labriola
 
Refactoring and code smells
Refactoring and code smellsRefactoring and code smells
Refactoring and code smellsPaul Nguyen
 
Enterprise Library 3.0 Policy Injection Applicatoin Block
Enterprise Library 3.0 Policy Injection Applicatoin BlockEnterprise Library 3.0 Policy Injection Applicatoin Block
Enterprise Library 3.0 Policy Injection Applicatoin Blockmcgurk
 
Introduction to Spring MVC
Introduction to Spring MVCIntroduction to Spring MVC
Introduction to Spring MVCRichard Paul
 
Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#Juan Pablo
 
CiklumJavaSat_15112011:Alex Kruk VMForce
CiklumJavaSat_15112011:Alex Kruk VMForceCiklumJavaSat_15112011:Alex Kruk VMForce
CiklumJavaSat_15112011:Alex Kruk VMForceCiklum Ukraine
 
Oleksandr Valetskyy - DI vs. IoC
Oleksandr Valetskyy - DI vs. IoCOleksandr Valetskyy - DI vs. IoC
Oleksandr Valetskyy - DI vs. IoCOleksandr Valetskyy
 
Back-2-Basics: .NET Coding Standards For The Real World (2011)
Back-2-Basics: .NET Coding Standards For The Real World (2011)Back-2-Basics: .NET Coding Standards For The Real World (2011)
Back-2-Basics: .NET Coding Standards For The Real World (2011)David McCarter
 
ASP.NET Web API
ASP.NET Web APIASP.NET Web API
ASP.NET Web APIhabib_786
 
Lab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptLab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptWalid Ashraf
 
Advanced #2 networking
Advanced #2   networkingAdvanced #2   networking
Advanced #2 networkingVitali Pekelis
 
Introducing Struts 2
Introducing Struts 2Introducing Struts 2
Introducing Struts 2wiradikusuma
 
Knockoutjs databinding
Knockoutjs databindingKnockoutjs databinding
Knockoutjs databindingBoulos Dib
 
Developing ASP.NET Applications Using the Model View Controller Pattern
Developing ASP.NET Applications Using the Model View Controller PatternDeveloping ASP.NET Applications Using the Model View Controller Pattern
Developing ASP.NET Applications Using the Model View Controller Patterngoodfriday
 
Nestjs MasterClass Slides
Nestjs MasterClass SlidesNestjs MasterClass Slides
Nestjs MasterClass SlidesNir Kaufman
 

Ähnlich wie Policy Injection in ASP.NET using Enterprise Library 3.0 (20)

Diving in the Flex Data Binding Waters
Diving in the Flex Data Binding WatersDiving in the Flex Data Binding Waters
Diving in the Flex Data Binding Waters
 
Refactoring and code smells
Refactoring and code smellsRefactoring and code smells
Refactoring and code smells
 
Rhino Mocks
Rhino MocksRhino Mocks
Rhino Mocks
 
Tdd,Ioc
Tdd,IocTdd,Ioc
Tdd,Ioc
 
Enterprise Library 3.0 Policy Injection Applicatoin Block
Enterprise Library 3.0 Policy Injection Applicatoin BlockEnterprise Library 3.0 Policy Injection Applicatoin Block
Enterprise Library 3.0 Policy Injection Applicatoin Block
 
Introduction to Spring MVC
Introduction to Spring MVCIntroduction to Spring MVC
Introduction to Spring MVC
 
Working with Servlets
Working with ServletsWorking with Servlets
Working with Servlets
 
Javascript Design Patterns
Javascript Design PatternsJavascript Design Patterns
Javascript Design Patterns
 
Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#
 
CiklumJavaSat_15112011:Alex Kruk VMForce
CiklumJavaSat_15112011:Alex Kruk VMForceCiklumJavaSat_15112011:Alex Kruk VMForce
CiklumJavaSat_15112011:Alex Kruk VMForce
 
Oleksandr Valetskyy - DI vs. IoC
Oleksandr Valetskyy - DI vs. IoCOleksandr Valetskyy - DI vs. IoC
Oleksandr Valetskyy - DI vs. IoC
 
Back-2-Basics: .NET Coding Standards For The Real World (2011)
Back-2-Basics: .NET Coding Standards For The Real World (2011)Back-2-Basics: .NET Coding Standards For The Real World (2011)
Back-2-Basics: .NET Coding Standards For The Real World (2011)
 
ASP.NET Web API
ASP.NET Web APIASP.NET Web API
ASP.NET Web API
 
Lab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptLab #2: Introduction to Javascript
Lab #2: Introduction to Javascript
 
Advanced #2 networking
Advanced #2   networkingAdvanced #2   networking
Advanced #2 networking
 
Introducing Struts 2
Introducing Struts 2Introducing Struts 2
Introducing Struts 2
 
Knockoutjs databinding
Knockoutjs databindingKnockoutjs databinding
Knockoutjs databinding
 
08 Queries
08 Queries08 Queries
08 Queries
 
Developing ASP.NET Applications Using the Model View Controller Pattern
Developing ASP.NET Applications Using the Model View Controller PatternDeveloping ASP.NET Applications Using the Model View Controller Pattern
Developing ASP.NET Applications Using the Model View Controller Pattern
 
Nestjs MasterClass Slides
Nestjs MasterClass SlidesNestjs MasterClass Slides
Nestjs MasterClass Slides
 

Mehr von PhilWinstanley

Using New Data Types In2008
Using New Data Types In2008Using New Data Types In2008
Using New Data Types In2008PhilWinstanley
 
Getting Started with Enterprise Library 3.0 in ASP.NET
Getting Started with Enterprise Library 3.0 in ASP.NETGetting Started with Enterprise Library 3.0 in ASP.NET
Getting Started with Enterprise Library 3.0 in ASP.NETPhilWinstanley
 
Object Relational Mapping In Real World Applications
Object Relational Mapping In Real World ApplicationsObject Relational Mapping In Real World Applications
Object Relational Mapping In Real World ApplicationsPhilWinstanley
 

Mehr von PhilWinstanley (6)

Spatial SQL
Spatial SQLSpatial SQL
Spatial SQL
 
Using New Data Types In2008
Using New Data Types In2008Using New Data Types In2008
Using New Data Types In2008
 
Translation
TranslationTranslation
Translation
 
Go With The Flow
Go With The FlowGo With The Flow
Go With The Flow
 
Getting Started with Enterprise Library 3.0 in ASP.NET
Getting Started with Enterprise Library 3.0 in ASP.NETGetting Started with Enterprise Library 3.0 in ASP.NET
Getting Started with Enterprise Library 3.0 in ASP.NET
 
Object Relational Mapping In Real World Applications
Object Relational Mapping In Real World ApplicationsObject Relational Mapping In Real World Applications
Object Relational Mapping In Real World Applications
 

Kürzlich hochgeladen

Pitch Deck Teardown: Geodesic.Life's $500k Pre-seed deck
Pitch Deck Teardown: Geodesic.Life's $500k Pre-seed deckPitch Deck Teardown: Geodesic.Life's $500k Pre-seed deck
Pitch Deck Teardown: Geodesic.Life's $500k Pre-seed deckHajeJanKamps
 
Investment in The Coconut Industry by Nancy Cheruiyot
Investment in The Coconut Industry by Nancy CheruiyotInvestment in The Coconut Industry by Nancy Cheruiyot
Investment in The Coconut Industry by Nancy Cheruiyotictsugar
 
Islamabad Escorts | Call 03070433345 | Escort Service in Islamabad
Islamabad Escorts | Call 03070433345 | Escort Service in IslamabadIslamabad Escorts | Call 03070433345 | Escort Service in Islamabad
Islamabad Escorts | Call 03070433345 | Escort Service in IslamabadAyesha Khan
 
Memorándum de Entendimiento (MoU) entre Codelco y SQM
Memorándum de Entendimiento (MoU) entre Codelco y SQMMemorándum de Entendimiento (MoU) entre Codelco y SQM
Memorándum de Entendimiento (MoU) entre Codelco y SQMVoces Mineras
 
Annual General Meeting Presentation Slides
Annual General Meeting Presentation SlidesAnnual General Meeting Presentation Slides
Annual General Meeting Presentation SlidesKeppelCorporation
 
FULL ENJOY Call girls in Paharganj Delhi | 8377087607
FULL ENJOY Call girls in Paharganj Delhi | 8377087607FULL ENJOY Call girls in Paharganj Delhi | 8377087607
FULL ENJOY Call girls in Paharganj Delhi | 8377087607dollysharma2066
 
IoT Insurance Observatory: summary 2024
IoT Insurance Observatory:  summary 2024IoT Insurance Observatory:  summary 2024
IoT Insurance Observatory: summary 2024Matteo Carbone
 
8447779800, Low rate Call girls in Saket Delhi NCR
8447779800, Low rate Call girls in Saket Delhi NCR8447779800, Low rate Call girls in Saket Delhi NCR
8447779800, Low rate Call girls in Saket Delhi NCRashishs7044
 
Ten Organizational Design Models to align structure and operations to busines...
Ten Organizational Design Models to align structure and operations to busines...Ten Organizational Design Models to align structure and operations to busines...
Ten Organizational Design Models to align structure and operations to busines...Seta Wicaksana
 
Contemporary Economic Issues Facing the Filipino Entrepreneur (1).pptx
Contemporary Economic Issues Facing the Filipino Entrepreneur (1).pptxContemporary Economic Issues Facing the Filipino Entrepreneur (1).pptx
Contemporary Economic Issues Facing the Filipino Entrepreneur (1).pptxMarkAnthonyAurellano
 
Global Scenario On Sustainable and Resilient Coconut Industry by Dr. Jelfina...
Global Scenario On Sustainable  and Resilient Coconut Industry by Dr. Jelfina...Global Scenario On Sustainable  and Resilient Coconut Industry by Dr. Jelfina...
Global Scenario On Sustainable and Resilient Coconut Industry by Dr. Jelfina...ictsugar
 
Intro to BCG's Carbon Emissions Benchmark_vF.pdf
Intro to BCG's Carbon Emissions Benchmark_vF.pdfIntro to BCG's Carbon Emissions Benchmark_vF.pdf
Intro to BCG's Carbon Emissions Benchmark_vF.pdfpollardmorgan
 
Call Girls in DELHI Cantt, ( Call Me )-8377877756-Female Escort- In Delhi / Ncr
Call Girls in DELHI Cantt, ( Call Me )-8377877756-Female Escort- In Delhi / NcrCall Girls in DELHI Cantt, ( Call Me )-8377877756-Female Escort- In Delhi / Ncr
Call Girls in DELHI Cantt, ( Call Me )-8377877756-Female Escort- In Delhi / Ncrdollysharma2066
 
Traction part 2 - EOS Model JAX Bridges.
Traction part 2 - EOS Model JAX Bridges.Traction part 2 - EOS Model JAX Bridges.
Traction part 2 - EOS Model JAX Bridges.Anamaria Contreras
 
Future Of Sample Report 2024 | Redacted Version
Future Of Sample Report 2024 | Redacted VersionFuture Of Sample Report 2024 | Redacted Version
Future Of Sample Report 2024 | Redacted VersionMintel Group
 
Case study on tata clothing brand zudio in detail
Case study on tata clothing brand zudio in detailCase study on tata clothing brand zudio in detail
Case study on tata clothing brand zudio in detailAriel592675
 
India Consumer 2024 Redacted Sample Report
India Consumer 2024 Redacted Sample ReportIndia Consumer 2024 Redacted Sample Report
India Consumer 2024 Redacted Sample ReportMintel Group
 
Independent Call Girls Andheri Nightlaila 9967584737
Independent Call Girls Andheri Nightlaila 9967584737Independent Call Girls Andheri Nightlaila 9967584737
Independent Call Girls Andheri Nightlaila 9967584737Riya Pathan
 
Ms Motilal Padampat Sugar Mills vs. State of Uttar Pradesh & Ors. - A Milesto...
Ms Motilal Padampat Sugar Mills vs. State of Uttar Pradesh & Ors. - A Milesto...Ms Motilal Padampat Sugar Mills vs. State of Uttar Pradesh & Ors. - A Milesto...
Ms Motilal Padampat Sugar Mills vs. State of Uttar Pradesh & Ors. - A Milesto...ShrutiBose4
 

Kürzlich hochgeladen (20)

Pitch Deck Teardown: Geodesic.Life's $500k Pre-seed deck
Pitch Deck Teardown: Geodesic.Life's $500k Pre-seed deckPitch Deck Teardown: Geodesic.Life's $500k Pre-seed deck
Pitch Deck Teardown: Geodesic.Life's $500k Pre-seed deck
 
Investment in The Coconut Industry by Nancy Cheruiyot
Investment in The Coconut Industry by Nancy CheruiyotInvestment in The Coconut Industry by Nancy Cheruiyot
Investment in The Coconut Industry by Nancy Cheruiyot
 
Islamabad Escorts | Call 03070433345 | Escort Service in Islamabad
Islamabad Escorts | Call 03070433345 | Escort Service in IslamabadIslamabad Escorts | Call 03070433345 | Escort Service in Islamabad
Islamabad Escorts | Call 03070433345 | Escort Service in Islamabad
 
Memorándum de Entendimiento (MoU) entre Codelco y SQM
Memorándum de Entendimiento (MoU) entre Codelco y SQMMemorándum de Entendimiento (MoU) entre Codelco y SQM
Memorándum de Entendimiento (MoU) entre Codelco y SQM
 
Annual General Meeting Presentation Slides
Annual General Meeting Presentation SlidesAnnual General Meeting Presentation Slides
Annual General Meeting Presentation Slides
 
FULL ENJOY Call girls in Paharganj Delhi | 8377087607
FULL ENJOY Call girls in Paharganj Delhi | 8377087607FULL ENJOY Call girls in Paharganj Delhi | 8377087607
FULL ENJOY Call girls in Paharganj Delhi | 8377087607
 
IoT Insurance Observatory: summary 2024
IoT Insurance Observatory:  summary 2024IoT Insurance Observatory:  summary 2024
IoT Insurance Observatory: summary 2024
 
8447779800, Low rate Call girls in Saket Delhi NCR
8447779800, Low rate Call girls in Saket Delhi NCR8447779800, Low rate Call girls in Saket Delhi NCR
8447779800, Low rate Call girls in Saket Delhi NCR
 
Ten Organizational Design Models to align structure and operations to busines...
Ten Organizational Design Models to align structure and operations to busines...Ten Organizational Design Models to align structure and operations to busines...
Ten Organizational Design Models to align structure and operations to busines...
 
Contemporary Economic Issues Facing the Filipino Entrepreneur (1).pptx
Contemporary Economic Issues Facing the Filipino Entrepreneur (1).pptxContemporary Economic Issues Facing the Filipino Entrepreneur (1).pptx
Contemporary Economic Issues Facing the Filipino Entrepreneur (1).pptx
 
Global Scenario On Sustainable and Resilient Coconut Industry by Dr. Jelfina...
Global Scenario On Sustainable  and Resilient Coconut Industry by Dr. Jelfina...Global Scenario On Sustainable  and Resilient Coconut Industry by Dr. Jelfina...
Global Scenario On Sustainable and Resilient Coconut Industry by Dr. Jelfina...
 
Intro to BCG's Carbon Emissions Benchmark_vF.pdf
Intro to BCG's Carbon Emissions Benchmark_vF.pdfIntro to BCG's Carbon Emissions Benchmark_vF.pdf
Intro to BCG's Carbon Emissions Benchmark_vF.pdf
 
Call Girls in DELHI Cantt, ( Call Me )-8377877756-Female Escort- In Delhi / Ncr
Call Girls in DELHI Cantt, ( Call Me )-8377877756-Female Escort- In Delhi / NcrCall Girls in DELHI Cantt, ( Call Me )-8377877756-Female Escort- In Delhi / Ncr
Call Girls in DELHI Cantt, ( Call Me )-8377877756-Female Escort- In Delhi / Ncr
 
Traction part 2 - EOS Model JAX Bridges.
Traction part 2 - EOS Model JAX Bridges.Traction part 2 - EOS Model JAX Bridges.
Traction part 2 - EOS Model JAX Bridges.
 
Future Of Sample Report 2024 | Redacted Version
Future Of Sample Report 2024 | Redacted VersionFuture Of Sample Report 2024 | Redacted Version
Future Of Sample Report 2024 | Redacted Version
 
Case study on tata clothing brand zudio in detail
Case study on tata clothing brand zudio in detailCase study on tata clothing brand zudio in detail
Case study on tata clothing brand zudio in detail
 
India Consumer 2024 Redacted Sample Report
India Consumer 2024 Redacted Sample ReportIndia Consumer 2024 Redacted Sample Report
India Consumer 2024 Redacted Sample Report
 
Independent Call Girls Andheri Nightlaila 9967584737
Independent Call Girls Andheri Nightlaila 9967584737Independent Call Girls Andheri Nightlaila 9967584737
Independent Call Girls Andheri Nightlaila 9967584737
 
Enjoy ➥8448380779▻ Call Girls In Sector 18 Noida Escorts Delhi NCR
Enjoy ➥8448380779▻ Call Girls In Sector 18 Noida Escorts Delhi NCREnjoy ➥8448380779▻ Call Girls In Sector 18 Noida Escorts Delhi NCR
Enjoy ➥8448380779▻ Call Girls In Sector 18 Noida Escorts Delhi NCR
 
Ms Motilal Padampat Sugar Mills vs. State of Uttar Pradesh & Ors. - A Milesto...
Ms Motilal Padampat Sugar Mills vs. State of Uttar Pradesh & Ors. - A Milesto...Ms Motilal Padampat Sugar Mills vs. State of Uttar Pradesh & Ors. - A Milesto...
Ms Motilal Padampat Sugar Mills vs. State of Uttar Pradesh & Ors. - A Milesto...
 

Policy Injection in ASP.NET using Enterprise Library 3.0

  • 1. Policy Injection in ASP.NET using Enterprise Library 3.0 Alex Homer [email_address] http://www.daveandal.net
  • 2.
  • 3.
  • 4. What are Crosscutting Concerns? Core Concerns Application Business Object Business Object Data Access Object Application Business Object Data Access Object Validation Logging Exception Handling Caching Authorization Crosscutting Concerns Performance Counters
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 11. Demo Business Object Members Public members exposed by the two business objects Member Attributed Customer Model Interface Customer Model Notes GetCustomerList()   GetCustomerName(customerID)   GetCustomerNameWithWildcard (customerID)   Uses GetCustomerName method with a wildcard. GetCustomerDetails(customerID)   Not defined in interface. GetCityList(minimumCount)   CityCount   Property. Uses GetCityList
  • 12. Demo Policies The policies defined in the example application Policy Name Matching Rules Call Handlers InterfaceModelPolicy Member Name = GetCustomerNameWithWildcard or GetCustomerList Type Name = InterfaceCustomerModel Logging Handler with Categories = &quot;AuditFile&quot; and &quot;EventLog&quot; Caching Handler with cache duration 20 seconds Exception Handler with Exception Policy = &quot;CustomerModelPolicy” AttributeModelPolicy Method Signature, Name = * and parameter = System.String Type Name = AttributedCustomerModel Logging Handler with Categories = &quot;AuditFile&quot; CacheByTagPolicy Tag Attribute = &quot;ApplyTenSecondCaching&quot; Caching Handler with cache duration 10 seconds
  • 13.
  • 14.
  • 15.
  • 17. Factory Proxy Handlers Matching Rules Pipeline
  • 18.
  • 19.
  • 20.
  • 21. Handler Process Overview public class ExampleHandler : ICallHandler { public IMethodReturn Invoke(IMethodInvocation input , GetNextHandlerDelegate getNext ) { // Perform any pre-processing tasks required in the custom handler. ... // Invoke next handler that the block should execute. This code gets the current return message that you must pass back to the caller: IMethodReturn msg = getNext()(input, getNext); ... // Perform any post-processing tasks required in the custom handler. // You can modify the return message if required. // Return the message to the previous handler or the client. return msg; }
  • 22. Messages and Short-Circuiting Each handler invokes the next one, passing the invocation message along the pipeline and the return message back again A handler can instead simply refuse to call the next handler, and can add information (e.g. an exception) to the return message. Note that previous handlers still execute
  • 23. Short-Circuiting Execution public IMethodReturn Invoke(IMethodInvocation input , GetNextHandlerDelegate getNext ) { GregorianCalendar cal = new GregorianCalendar(); DayOfWeek weekDay = cal.GetDayOfWeek(DateTime.Now); if (weekDay == DayOfWeek.Saturday || weekDay == DayOfWeek.Sunday) { // create an Exception to return and the return message. Exception ex = new Exception(&quot;Available on weekdays only&quot;); IMethodReturn msg = input.CreateExceptionMethodReturn(ex) return msg; } else { return getNext()(input, getNext); // invoke the next handler }
  • 24. Custom Handler Attributes [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Method)] public class CachingCallHandlerAttribute : HandlerAttribute { private TimeSpan expirationTime; public CachingCallHandlerAttribute(int hours , int minutes , int seconds ) { // constructor, save the parameter values expirationTime = new TimeSpan(hours, minutes, seconds); } public override ICallHandler CreateHandler() { // create the appropriate handler instance and return it return new CachingCallHandler(expirationTime); } }
  • 25.