SlideShare a Scribd company logo
1 of 43
 
Understanding Reflection  Tamir Khason Technology Consultor ¹ mPrest Systems http://blogs.microsoft.co.il/blogs/tamir   Session Code: DVP307 ¹ con·sul·tor  (kən sult ′ ər) - one of a group of priests appointed to advise and assist a bishop
CLR – compilation and execution Execution Compilation Source code Language compiler JIT compiler Before installation or the first time each method is called MSIL Metadata Code Native code
Reflection overview ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
What is “Reflection”? ,[object Object],[object Object],[object Object],[object Object]
Where is “Reflection”? ,[object Object],[object Object],[object Object]
How to “Reflection”? ,[object Object],[object Object],[object Object],[object Object]
How to… perform type discovery ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
What are you? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
What you have? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
MemberInfo ,[object Object],[object Object],[object Object],MemberInfo MethodBase ParameterInfo FieldInfo EventInfo PropertyInfo MethodInfo ConstructorInfo
MethodInfo vs. ConstructorInfo ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
FieldInfo vs. PropertyInfo ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
We can clone it… Type kidType = oldKid.GetType(); Kid newKid = new Kid();   foreach (var m in kidType.GetProperties()) { m.SetValue(newKid ,    m.GetValue(oldKid, null), null); } Unknown object GetType().GetMembers() For Each Member FieldInfo.Copy old value to new Object
Clone optimization Kid CloneKid(Kid) { newKid.Height = oldKid.Height   newKid.Weight = oldKid.Weight } Unknown object GetType().GetMembers() For Each Member Create Code that copies members Save as Method for later Invocation
Clone optimized Unknown object Has custom method? Execute Yes Copy Members No
What is… attributes ,[object Object],[object Object],[object Object],[object Object]
Code generation ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Kid CloneKid(Kid) { newKid.Height = oldKid.Height   newKid.Weight = oldKid.Weight }
 
CodeDOM ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],public static void Main() { System.Console.WriteLine(“Hello World!”); }
CodeDOM ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
CodeDOM – even more ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object]
CodeDOM – Bottom line ,[object Object],[object Object],[object Object]
 
IL introduction ,[object Object],[object Object],[object Object],[object Object],5 + 10 - 3    IL_0001:  ldc.i4  5 IL_0002:  ldc.i4  10  IL_0003:  add IL_0004:  ldc.i4 3 IL_0005:  sub Evaluation Stack 0000 005 0000 0010 0000 0015 0000 0003 0000 0012
IL introduction ,[object Object],[object Object],[object Object],string str = “Hello, World!” IL_0001: ldstr  “Hello, World!” IL_0002:  stloc str IL_0003:  ldloc str  Foo.f = “Hello, World!” IL_0001:  ldstr  “Hello, World!” IL_0002:  stfld string  Foo::f IL_0003:  ldfld string  Foo::f
IL introduction ,[object Object],if (b) { ... } else { ... }  IL_0001:  ldloc b IL_0002:  ldc.i4.1 IL_0003:  ceq IL_0004:  brfalse  IL_00020 // if true statements IL_0010:  ... IL_0011: br  IL_00025 // else statements IL_0020:  ... // rest of method IL_0025: ...
Reflection.Emit ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Code Emitting public  class MyClass { public static void Main()  { string str  = “Hello World!”; Console.WriteLine (str); } } AssemblyBuilder ModuleBuilder TypeBuilder MethodBuilder LocalBuilder ILGenerator OPCodes
Lightweight Code Generation ,[object Object],Kid CloneKid(Kid) { newKid.Height = oldKid.Height   newKid.Weight = oldKid.Weight } DynamicMethod ILGenerator OPCodes
[object Object]
 
HackMe ,[object Object],[object Object],[object Object],[object Object],[object Object]
What's new in .NET 3.5? ,[object Object],[object Object],[object Object],[object Object]
From delegate to Lambda Delegate void SomeDelegate(EventsArgs e); Object.SomeEvent += new SomeDelegate(SomeMethod); Delegate Object.SomeEvent += delegate(EventArgs e)    { //work here } Anonymous delegate  Object.SomeEvent += (e) => { //work here }; Lambda
Expression Tree ,[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object]
Related Content ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Resources ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Please complete an evaluation
 
© 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation.  Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation.  MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

More Related Content

What's hot

Java Script Patterns
Java Script PatternsJava Script Patterns
Java Script PatternsAllan Huang
 
Ado.net session11
Ado.net session11Ado.net session11
Ado.net session11Niit Care
 
Real-World Scala Design Patterns
Real-World Scala Design PatternsReal-World Scala Design Patterns
Real-World Scala Design PatternsNLJUG
 
Java core - Detailed Overview
Java  core - Detailed OverviewJava  core - Detailed Overview
Java core - Detailed OverviewBuddha Tree
 
JavaScript Parser Infrastructure for Code Quality Analysis
JavaScript Parser Infrastructure for Code Quality AnalysisJavaScript Parser Infrastructure for Code Quality Analysis
JavaScript Parser Infrastructure for Code Quality AnalysisAriya Hidayat
 
Effective Scala: Programming Patterns
Effective Scala: Programming PatternsEffective Scala: Programming Patterns
Effective Scala: Programming PatternsVasil Remeniuk
 
Chapter 7 C++ As OOP
Chapter 7 C++ As OOPChapter 7 C++ As OOP
Chapter 7 C++ As OOPAmrit Kaur
 
NDK Primer (Wearable DevCon 2014)
NDK Primer (Wearable DevCon 2014)NDK Primer (Wearable DevCon 2014)
NDK Primer (Wearable DevCon 2014)Ron Munitz
 
Core java Basics
Core java BasicsCore java Basics
Core java BasicsRAMU KOLLI
 
openFrameworks freakDay S03E02 Diederick Huijbers - C++/Physics/Cloth Animati...
openFrameworks freakDay S03E02 Diederick Huijbers - C++/Physics/Cloth Animati...openFrameworks freakDay S03E02 Diederick Huijbers - C++/Physics/Cloth Animati...
openFrameworks freakDay S03E02 Diederick Huijbers - C++/Physics/Cloth Animati...roxlu
 
Introduction to iOS and Objective-C
Introduction to iOS and Objective-CIntroduction to iOS and Objective-C
Introduction to iOS and Objective-CDaniela Da Cruz
 

What's hot (20)

Java Script Patterns
Java Script PatternsJava Script Patterns
Java Script Patterns
 
Ado.net session11
Ado.net session11Ado.net session11
Ado.net session11
 
Real-World Scala Design Patterns
Real-World Scala Design PatternsReal-World Scala Design Patterns
Real-World Scala Design Patterns
 
03class
03class03class
03class
 
Java core - Detailed Overview
Java  core - Detailed OverviewJava  core - Detailed Overview
Java core - Detailed Overview
 
Scala’s implicits
Scala’s implicitsScala’s implicits
Scala’s implicits
 
JavaScript Parser Infrastructure for Code Quality Analysis
JavaScript Parser Infrastructure for Code Quality AnalysisJavaScript Parser Infrastructure for Code Quality Analysis
JavaScript Parser Infrastructure for Code Quality Analysis
 
Effective Scala: Programming Patterns
Effective Scala: Programming PatternsEffective Scala: Programming Patterns
Effective Scala: Programming Patterns
 
Iphone lecture imp
Iphone lecture  impIphone lecture  imp
Iphone lecture imp
 
Hello Java-First Level
Hello Java-First LevelHello Java-First Level
Hello Java-First Level
 
Hello java
Hello java  Hello java
Hello java
 
Chapter 7 C++ As OOP
Chapter 7 C++ As OOPChapter 7 C++ As OOP
Chapter 7 C++ As OOP
 
Presentation to java
Presentation  to  javaPresentation  to  java
Presentation to java
 
NDK Primer (Wearable DevCon 2014)
NDK Primer (Wearable DevCon 2014)NDK Primer (Wearable DevCon 2014)
NDK Primer (Wearable DevCon 2014)
 
Java
Java Java
Java
 
Core java Basics
Core java BasicsCore java Basics
Core java Basics
 
openFrameworks freakDay S03E02 Diederick Huijbers - C++/Physics/Cloth Animati...
openFrameworks freakDay S03E02 Diederick Huijbers - C++/Physics/Cloth Animati...openFrameworks freakDay S03E02 Diederick Huijbers - C++/Physics/Cloth Animati...
openFrameworks freakDay S03E02 Diederick Huijbers - C++/Physics/Cloth Animati...
 
Introduction to iOS and Objective-C
Introduction to iOS and Objective-CIntroduction to iOS and Objective-C
Introduction to iOS and Objective-C
 
About Python
About PythonAbout Python
About Python
 
C# for beginners
C# for beginnersC# for beginners
C# for beginners
 

Similar to Understanding Reflection

Reflecting On The Code Dom
Reflecting On The Code DomReflecting On The Code Dom
Reflecting On The Code DomNick Harrison
 
Jeff English: Demystifying Module Development - How to Extend Titanium
Jeff English: Demystifying Module Development - How to Extend TitaniumJeff English: Demystifying Module Development - How to Extend Titanium
Jeff English: Demystifying Module Development - How to Extend TitaniumAxway Appcelerator
 
Introduction to directshow II
Introduction to directshow IIIntroduction to directshow II
Introduction to directshow IIYoss Cohen
 
Windows 8 für .net Entwickler
Windows 8 für .net EntwicklerWindows 8 für .net Entwickler
Windows 8 für .net EntwicklerPatric Boscolo
 
Net framework session03
Net framework session03Net framework session03
Net framework session03Vivek chan
 
03 oo with-c-sharp
03 oo with-c-sharp03 oo with-c-sharp
03 oo with-c-sharpNaved khan
 
Introduction to c sharp 4.0 and dynamic
Introduction to c sharp 4.0 and dynamicIntroduction to c sharp 4.0 and dynamic
Introduction to c sharp 4.0 and dynamicGieno Miao
 
Reflection Slides by Zubair Dar
Reflection Slides by Zubair DarReflection Slides by Zubair Dar
Reflection Slides by Zubair Darzubairdar6
 
Basics of c# by sabir
Basics of c# by sabirBasics of c# by sabir
Basics of c# by sabirSabir Ali
 
Net framework session01
Net framework session01Net framework session01
Net framework session01Vivek chan
 
Introduction to .NET
Introduction to .NETIntroduction to .NET
Introduction to .NETJoni
 
NNUG Certification Presentation
NNUG Certification PresentationNNUG Certification Presentation
NNUG Certification PresentationNiall Merrigan
 
Concepts of Asp.Net
Concepts of Asp.NetConcepts of Asp.Net
Concepts of Asp.Netvidyamittal
 
Mobile Weekend Budapest presentation
Mobile Weekend Budapest presentationMobile Weekend Budapest presentation
Mobile Weekend Budapest presentationPéter Ádám Wiesner
 

Similar to Understanding Reflection (20)

Reflection
ReflectionReflection
Reflection
 
Reflecting On The Code Dom
Reflecting On The Code DomReflecting On The Code Dom
Reflecting On The Code Dom
 
Jeff English: Demystifying Module Development - How to Extend Titanium
Jeff English: Demystifying Module Development - How to Extend TitaniumJeff English: Demystifying Module Development - How to Extend Titanium
Jeff English: Demystifying Module Development - How to Extend Titanium
 
.NET Reflection
.NET Reflection.NET Reflection
.NET Reflection
 
Introduction to directshow II
Introduction to directshow IIIntroduction to directshow II
Introduction to directshow II
 
Windows 8 für .net Entwickler
Windows 8 für .net EntwicklerWindows 8 für .net Entwickler
Windows 8 für .net Entwickler
 
Net framework session03
Net framework session03Net framework session03
Net framework session03
 
03 oo with-c-sharp
03 oo with-c-sharp03 oo with-c-sharp
03 oo with-c-sharp
 
Introduction to c sharp 4.0 and dynamic
Introduction to c sharp 4.0 and dynamicIntroduction to c sharp 4.0 and dynamic
Introduction to c sharp 4.0 and dynamic
 
1.Philosophy of .NET
1.Philosophy of .NET1.Philosophy of .NET
1.Philosophy of .NET
 
Reflection Slides by Zubair Dar
Reflection Slides by Zubair DarReflection Slides by Zubair Dar
Reflection Slides by Zubair Dar
 
Basics of c# by sabir
Basics of c# by sabirBasics of c# by sabir
Basics of c# by sabir
 
Net framework session01
Net framework session01Net framework session01
Net framework session01
 
Introduction to .NET
Introduction to .NETIntroduction to .NET
Introduction to .NET
 
NNUG Certification Presentation
NNUG Certification PresentationNNUG Certification Presentation
NNUG Certification Presentation
 
C Sharp Jn
C Sharp JnC Sharp Jn
C Sharp Jn
 
C Sharp Jn
C Sharp JnC Sharp Jn
C Sharp Jn
 
Tdd,Ioc
Tdd,IocTdd,Ioc
Tdd,Ioc
 
Concepts of Asp.Net
Concepts of Asp.NetConcepts of Asp.Net
Concepts of Asp.Net
 
Mobile Weekend Budapest presentation
Mobile Weekend Budapest presentationMobile Weekend Budapest presentation
Mobile Weekend Budapest presentation
 

More from Tamir Khason

Smart Client Development
Smart Client DevelopmentSmart Client Development
Smart Client DevelopmentTamir Khason
 
WPF for developers - optimizing your WPF application
WPF for developers - optimizing your WPF applicationWPF for developers - optimizing your WPF application
WPF for developers - optimizing your WPF applicationTamir Khason
 
Creating A Game Using Microsoft’s Next Generation Technologies
Creating A Game Using Microsoft’s Next Generation TechnologiesCreating A Game Using Microsoft’s Next Generation Technologies
Creating A Game Using Microsoft’s Next Generation TechnologiesTamir Khason
 
Modern C&C Systems, Using New Technologies
Modern C&C Systems, Using New TechnologiesModern C&C Systems, Using New Technologies
Modern C&C Systems, Using New TechnologiesTamir Khason
 
Wpf Under The Hood Engines
Wpf Under The Hood EnginesWpf Under The Hood Engines
Wpf Under The Hood EnginesTamir Khason
 
Introduction To Wpf Engines
Introduction To Wpf   EnginesIntroduction To Wpf   Engines
Introduction To Wpf EnginesTamir Khason
 

More from Tamir Khason (6)

Smart Client Development
Smart Client DevelopmentSmart Client Development
Smart Client Development
 
WPF for developers - optimizing your WPF application
WPF for developers - optimizing your WPF applicationWPF for developers - optimizing your WPF application
WPF for developers - optimizing your WPF application
 
Creating A Game Using Microsoft’s Next Generation Technologies
Creating A Game Using Microsoft’s Next Generation TechnologiesCreating A Game Using Microsoft’s Next Generation Technologies
Creating A Game Using Microsoft’s Next Generation Technologies
 
Modern C&C Systems, Using New Technologies
Modern C&C Systems, Using New TechnologiesModern C&C Systems, Using New Technologies
Modern C&C Systems, Using New Technologies
 
Wpf Under The Hood Engines
Wpf Under The Hood EnginesWpf Under The Hood Engines
Wpf Under The Hood Engines
 
Introduction To Wpf Engines
Introduction To Wpf   EnginesIntroduction To Wpf   Engines
Introduction To Wpf Engines
 

Recently uploaded

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
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
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
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
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
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
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
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 

Recently uploaded (20)

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...
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
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
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
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
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 

Understanding Reflection

  • 1.  
  • 2. Understanding Reflection Tamir Khason Technology Consultor ¹ mPrest Systems http://blogs.microsoft.co.il/blogs/tamir Session Code: DVP307 ¹ con·sul·tor (kən sult ′ ər) - one of a group of priests appointed to advise and assist a bishop
  • 3. CLR – compilation and execution Execution Compilation Source code Language compiler JIT compiler Before installation or the first time each method is called MSIL Metadata Code Native code
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14. We can clone it… Type kidType = oldKid.GetType(); Kid newKid = new Kid(); foreach (var m in kidType.GetProperties()) { m.SetValue(newKid , m.GetValue(oldKid, null), null); } Unknown object GetType().GetMembers() For Each Member FieldInfo.Copy old value to new Object
  • 15. Clone optimization Kid CloneKid(Kid) { newKid.Height = oldKid.Height newKid.Weight = oldKid.Weight } Unknown object GetType().GetMembers() For Each Member Create Code that copies members Save as Method for later Invocation
  • 16. Clone optimized Unknown object Has custom method? Execute Yes Copy Members No
  • 17.
  • 18.
  • 19.  
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.  
  • 26.
  • 27.
  • 28.
  • 29.
  • 30. Code Emitting public class MyClass { public static void Main() { string str = “Hello World!”; Console.WriteLine (str); } } AssemblyBuilder ModuleBuilder TypeBuilder MethodBuilder LocalBuilder ILGenerator OPCodes
  • 31.
  • 32.
  • 33.  
  • 34.
  • 35.
  • 36. From delegate to Lambda Delegate void SomeDelegate(EventsArgs e); Object.SomeEvent += new SomeDelegate(SomeMethod); Delegate Object.SomeEvent += delegate(EventArgs e) { //work here } Anonymous delegate Object.SomeEvent += (e) => { //work here }; Lambda
  • 37.
  • 38.
  • 39.
  • 40.
  • 41. Please complete an evaluation
  • 42.  
  • 43. © 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Editor's Notes

  1. 06/07/09 17:53 © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.