SlideShare ist ein Scribd-Unternehmen logo
1 von 12
Downloaden Sie, um offline zu lesen
1

… in short
SamNium (January 2014) https://qinjection.codeplex.com/

QInjection ... about how to use Roslyn to implement a simple query injection engine
2

How QInjection come from?
It comes from the need to use Microsoft Roslyn in order to evaluate
lambda expressions at service side (of a WCF web Service)

QInjection ... about how to use Roslyn to implement a simple query injection engine
3

Filtering at the client side
Client
Application

Web Service

GetData

Client
Application

Web Service

Client
Application

Web Service

Client
Application

Web Service

Filter

APPLY lambda expression
and take the white ones
QInjection ... about how to use Roslyn to implement a simple query injection engine
4

Filtering at the web service side
Client
Application

Web Service

GetData with lambda expression

Client
Application

Web Service

Client
Application

Web Service

Client
Application

Web Service

Client
Application

Web Service

QInjection ... about how to use Roslyn to implement a simple query injection engine

APPLY
lambda
expression
5

How do you use QInjection?
You have to implement a class that act as Data Provider Bridge of the data
collection, this class have to implement the interface IQProvider<T> where T is the
type of the items (integer in this example)

You have to instantiate the QInjector object and then:
Define the validation RULE
Validate the expression
Execute the expression on your Data Provider Bridge (this one will act as container of the
runtime injected code).

QInjection ... about how to use Roslyn to implement a simple query injection engine
6

Three phases

Define

Define Syntax of
the lambda
expression to
accept as input.

QInjection ... about how to use Roslyn to implement a simple query injection engine

Validate
Validate the
lambda
expression by
using its AST
representation.

Evaluate
Evaluate lambda
expression on
your code.
7

A sample Code

Define

Validate
Evaluate

QInjection ... about how to use Roslyn to implement a simple query injection engine
8

Looking at the Validation Facilities
User Code

Aggregate
Validation Rule
Facilities
Low Level
Vlidation Rule
Facilities

Support
As
WithName
WithNameRegex
WithArity
WithOperator
RefuseReference

Accept
AcceptNames
AcceptOperators
AcceptArities

Core
Validation
&
Scripting

QInjection ... about how to use Roslyn to implement a simple query injection engine

Validate
9

How QInjection works?
QInjection is based on Microsoft Roslyn both for Validation and
Scripting.

QInjection ... about how to use Roslyn to implement a simple query injection engine
10

VALIDATE

EVALUATE

The expression is translated in an
AST representation.
An internal TreeValidator engine
go through the AST and checks
the Links between Branches and
evaluates if the Validation Rules
on Nodes are satisfied.

If the expression is valid then an
internal engine inject a Spy
Object inside your Object.
The Spy Object acts as Bridge
between your data provider and
the IEnumerable<T>.Where(…)
method of your data collection.

QInjection ... about how to use Roslyn to implement a simple query injection engine
11

The AST of “x => x == 1”
x => x == 1

Parameter

IdentifierName
Syntax

SimpleLambda
ExpressionSyntax

Left

IdentifierName
Syntax

QInjection ... about how to use Roslyn to implement a simple query injection engine

Body

BinaryExpression
Syntax

RIght

LiteralExpression
Syntax
12

A small look at the Core
<lambda expression>

AST

Map of <Branch, List of Node>
Branch Set

Rule Set
Map of <Node, Map of <Rule, List of Rule Data>>

QInjection ... about how to use Roslyn to implement a simple query injection engine

TreeValidator

Rule Validator

Weitere ähnliche Inhalte

Kürzlich hochgeladen

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Kürzlich hochgeladen (20)

Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
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 New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.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
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 

Empfohlen

Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Saba Software
 

Empfohlen (20)

Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
 

QInjection (Lambda Query Injection in C# using Roslyn)

  • 1. 1 … in short SamNium (January 2014) https://qinjection.codeplex.com/ QInjection ... about how to use Roslyn to implement a simple query injection engine
  • 2. 2 How QInjection come from? It comes from the need to use Microsoft Roslyn in order to evaluate lambda expressions at service side (of a WCF web Service) QInjection ... about how to use Roslyn to implement a simple query injection engine
  • 3. 3 Filtering at the client side Client Application Web Service GetData Client Application Web Service Client Application Web Service Client Application Web Service Filter APPLY lambda expression and take the white ones QInjection ... about how to use Roslyn to implement a simple query injection engine
  • 4. 4 Filtering at the web service side Client Application Web Service GetData with lambda expression Client Application Web Service Client Application Web Service Client Application Web Service Client Application Web Service QInjection ... about how to use Roslyn to implement a simple query injection engine APPLY lambda expression
  • 5. 5 How do you use QInjection? You have to implement a class that act as Data Provider Bridge of the data collection, this class have to implement the interface IQProvider<T> where T is the type of the items (integer in this example) You have to instantiate the QInjector object and then: Define the validation RULE Validate the expression Execute the expression on your Data Provider Bridge (this one will act as container of the runtime injected code). QInjection ... about how to use Roslyn to implement a simple query injection engine
  • 6. 6 Three phases Define Define Syntax of the lambda expression to accept as input. QInjection ... about how to use Roslyn to implement a simple query injection engine Validate Validate the lambda expression by using its AST representation. Evaluate Evaluate lambda expression on your code.
  • 7. 7 A sample Code Define Validate Evaluate QInjection ... about how to use Roslyn to implement a simple query injection engine
  • 8. 8 Looking at the Validation Facilities User Code Aggregate Validation Rule Facilities Low Level Vlidation Rule Facilities Support As WithName WithNameRegex WithArity WithOperator RefuseReference Accept AcceptNames AcceptOperators AcceptArities Core Validation & Scripting QInjection ... about how to use Roslyn to implement a simple query injection engine Validate
  • 9. 9 How QInjection works? QInjection is based on Microsoft Roslyn both for Validation and Scripting. QInjection ... about how to use Roslyn to implement a simple query injection engine
  • 10. 10 VALIDATE EVALUATE The expression is translated in an AST representation. An internal TreeValidator engine go through the AST and checks the Links between Branches and evaluates if the Validation Rules on Nodes are satisfied. If the expression is valid then an internal engine inject a Spy Object inside your Object. The Spy Object acts as Bridge between your data provider and the IEnumerable<T>.Where(…) method of your data collection. QInjection ... about how to use Roslyn to implement a simple query injection engine
  • 11. 11 The AST of “x => x == 1” x => x == 1 Parameter IdentifierName Syntax SimpleLambda ExpressionSyntax Left IdentifierName Syntax QInjection ... about how to use Roslyn to implement a simple query injection engine Body BinaryExpression Syntax RIght LiteralExpression Syntax
  • 12. 12 A small look at the Core <lambda expression> AST Map of <Branch, List of Node> Branch Set Rule Set Map of <Node, Map of <Rule, List of Rule Data>> QInjection ... about how to use Roslyn to implement a simple query injection engine TreeValidator Rule Validator