SlideShare una empresa de Scribd logo
1 de 9
Descargar para leer sin conexión
1 
New C#4 Features – Part V 
Nico Ludwig (@ersatzteilchen)
2 
TOC 
● New C#4 Features – Part V 
– Dynamic COM Automation with C# 
– Dynamic Objects in JavaScript 
– Expando Objects in C# 
● Sources: 
– Jon Skeet, CSharp in Depth
3 
Dynamic Coding – A better Experience with COM 
● You no longer need interop types: 
– Just don't use them: 
● if you want lazy dispatching and you don't bother finding method signatures yourself... 
● or if you simply don't want to or can't use type infos (w/o type library)! - You just use dynamic. 
– (Use them if you want to exploit early dispatching, e.g. if you want to use IntelliSense.) 
– To have no need to create code as an extra step is a key benefit of dynamic coding. 
● But if you use interop types w/o PIAs, the DLR still makes your life easier: 
– No-PIA deployed types provide the type dynamic instead of object in their APIs. 
– E.g. IDispatch and VARIANTs are exposed as dynamics, reducing cast operations. 
● With dynamic typing and COM you now have a "natural" coding experience: 
– "Plain old CLR objects" (POCOs) and COM objects can be programmed like peers. 
– During debugging the new "Dynamic View" assists you watching COM objects. 
● COM as "peer objects" is one advantage of VB and 
PowerShell programming.
4 
Example with COM Automation 
<DynamicComInteropCSharp> 
aThis example shows the application of C# dynamic coding to allow 
simple COM automation.
5 
Example: Transportation of Anonymous Types' Instances 
● Passing or returning anonymous types' instances from or to methods is limited. 
– Feasible solutions like generic methods or using the type Object are quite limiting... 
– You could only call Object's methods within such a method, not the anonymous type's ones (well, you might use reflection...). 
● With dynamic you can overcome these limits. 
● You'll get following features: 
– Easy to use adapters. 
– But data-binding, e.g. from IList<dynamic> to your controls is still fully functional (Windows Forms and WPF). 
● !!You can't access properties of anonymous types in non-friend assemblies!! 
– Anonymous types are internal and accessing them publicly may fail. 
– => Keep using them in the same assembly! 
● This is just one selected example of how dynamic typing 
simplifies coding problems. Passing anonymous types' 
instances to methods accepting dynamic arguments is used 
with view models in ASP.Net MVC. 
● Basically dynamic makes it possible to use otherwise only 
locally known anonymous types in other methods. 
● Databinding in WPF is less "sensitive", because it also 
accepts different types having equally named properties. The 
default behavior in Windows Forms requires identical types. 
● Situation in non-friend assemblies: On accessing the 
anonymous type's instance's properties (via a dynamically 
typed symbol) you'll get a RuntimeBinderException on the 
caller side, because the properties couldn't be bound. 
● More: 
● The type dynamic enables us to solve a problem on 
programming of generics: we can call arbitrary methods on 
unconstrained types' instances! Esp. we can call operators 
in generics with dynamic dispatching! 
● .Net remoting: Also can we use dynamic dispatch to access 
the interface of proxy objects on marshaled instances w/o 
having the object's type in avail.
6 
Leering at JavaScript: Dynamic Objects 
<Safari Web Inspector as REPL> 
Shows how we can exploit dynamic objects with dynamic 
properties in JavaScript. 
Key aspects of dynamic programming: 
(1. Dynamic Typing) 
(2. Late Binding) 
(3. Duck Typing) 
4. Dynamic Objects 
● The ability to modify objects during run time is 
another aspect of dynamic programming that is 
shown here. -> Dynamic objects.
7 
Dynamic Objects with .Net ExpandoObjects 
● Dynamic programming allows creating types, whose interfaces change at run time. 
– These interface changes are based on how you use instances of such dynamic types. 
● Dynamic objects are objects that have their own late binding logic! 
– (In contrast to static objects that get bound by the compiler (early binding).) 
– We can create own dynamic APIs to put mighty data driven APIs into effect! 
– The easiest way to get this is a dynamic property bag, via the type ExpandoObject. 
– ExpandoObjects are similar to JavaScript's dynamic objects that work like dictionaries. 
– In many dynamic languages (e.g. JavaScript, Python) all objects are property bags. 
● How to make use of .Net's ExpandoObject: 
– Import the namespace System.Dynamic. 
– Create a new ExpandoObject and assign it to a dynamic to enable dynamic dispatch. 
– Add/modify members during run time and exploit ExpandoObjects as dictionaries. 
● In static typing types are immutable, if you don’t have 
the source code. - In dynamic typing this is no longer 
the case, because the dynamic type information of an 
object is part of the object's value! 
● You should also check, whether a member of a 
dynamic object is really present, before accessing it 
(RuntimeBinderException). - This is a duck-typing 
aspect (Does "it" lay eggs?)! 
● As a matter of fact in .Net there also exists the type 
IExpando, which is implemented by JScript .Net objects 
(and by dynamic objects in some situations). 
● ExpandoObjects can also have functions as properties 
of a Delegate type! 
● Interoperability when hosting a DLR scripting language: 
Expose your C# objects to IronRuby as 
ExpandoObjects! 
● The class ExpandoObject is sealed. The discussion of 
more flexible dynamic objects is discussed in the next 
lecture.
8 
ExpandoObjects in Action 
<DynamicObjects> 
Shows the basic usage of ExpandoObjects. 
Key aspects of dynamic programming: 
(1. Dynamic Typing) 
(2. Late Binding) 
(3. Duck Typing) 
4. Dynamic Objects
9 
Thank you!

Más contenido relacionado

La actualidad más candente

TypeScript: Angular's Secret Weapon
TypeScript: Angular's Secret WeaponTypeScript: Angular's Secret Weapon
TypeScript: Angular's Secret WeaponLaurent Duveau
 
Typescript for the programmers who like javascript
Typescript for the programmers who like javascriptTypescript for the programmers who like javascript
Typescript for the programmers who like javascriptAndrei Sebastian Cîmpean
 
FregeDay: Roadmap for resolving differences between Haskell and Frege (Ingo W...
FregeDay: Roadmap for resolving differences between Haskell and Frege (Ingo W...FregeDay: Roadmap for resolving differences between Haskell and Frege (Ingo W...
FregeDay: Roadmap for resolving differences between Haskell and Frege (Ingo W...Dierk König
 
Comparing Golang and understanding Java Value Types
Comparing Golang and understanding Java Value TypesComparing Golang and understanding Java Value Types
Comparing Golang and understanding Java Value TypesPéter Verhás
 
Swift Tutorial Part 2. The complete guide for Swift programming language
Swift Tutorial Part 2. The complete guide for Swift programming languageSwift Tutorial Part 2. The complete guide for Swift programming language
Swift Tutorial Part 2. The complete guide for Swift programming languageHossam Ghareeb
 
Kotlin & arrow: the functional way
Kotlin & arrow:  the functional wayKotlin & arrow:  the functional way
Kotlin & arrow: the functional waynluaces
 
Introduction to f#
Introduction to f#Introduction to f#
Introduction to f#mjyeaney
 
TypeScript Modules
TypeScript ModulesTypeScript Modules
TypeScript ModulesNoam Kfir
 
Groovy / comparison with java
Groovy / comparison with javaGroovy / comparison with java
Groovy / comparison with javaLiviu Tudor
 
A Static Type Analyzer of Untyped Ruby Code for Ruby 3
A Static Type Analyzer of Untyped Ruby Code for Ruby 3A Static Type Analyzer of Untyped Ruby Code for Ruby 3
A Static Type Analyzer of Untyped Ruby Code for Ruby 3mametter
 
Javascript omg!
Javascript omg!Javascript omg!
Javascript omg!bwullems
 
Kotlin & Arrow the functional way
Kotlin & Arrow the functional wayKotlin & Arrow the functional way
Kotlin & Arrow the functional wayThoughtworks
 
Akka actorstotherescue nirmalya sengupta
Akka actorstotherescue nirmalya senguptaAkka actorstotherescue nirmalya sengupta
Akka actorstotherescue nirmalya senguptaapgionline
 
Understanding Typing. Understanding Ruby.
Understanding Typing. Understanding Ruby.Understanding Typing. Understanding Ruby.
Understanding Typing. Understanding Ruby.Justin Lin
 

La actualidad más candente (19)

TypeScript: Angular's Secret Weapon
TypeScript: Angular's Secret WeaponTypeScript: Angular's Secret Weapon
TypeScript: Angular's Secret Weapon
 
Typescript for the programmers who like javascript
Typescript for the programmers who like javascriptTypescript for the programmers who like javascript
Typescript for the programmers who like javascript
 
Metaprogramming with javascript
Metaprogramming with javascriptMetaprogramming with javascript
Metaprogramming with javascript
 
FregeDay: Roadmap for resolving differences between Haskell and Frege (Ingo W...
FregeDay: Roadmap for resolving differences between Haskell and Frege (Ingo W...FregeDay: Roadmap for resolving differences between Haskell and Frege (Ingo W...
FregeDay: Roadmap for resolving differences between Haskell and Frege (Ingo W...
 
Comparing Golang and understanding Java Value Types
Comparing Golang and understanding Java Value TypesComparing Golang and understanding Java Value Types
Comparing Golang and understanding Java Value Types
 
Swift Tutorial Part 2. The complete guide for Swift programming language
Swift Tutorial Part 2. The complete guide for Swift programming languageSwift Tutorial Part 2. The complete guide for Swift programming language
Swift Tutorial Part 2. The complete guide for Swift programming language
 
TypeScript 101
TypeScript 101TypeScript 101
TypeScript 101
 
Kotlin & arrow: the functional way
Kotlin & arrow:  the functional wayKotlin & arrow:  the functional way
Kotlin & arrow: the functional way
 
Introduction to f#
Introduction to f#Introduction to f#
Introduction to f#
 
TypeScript Modules
TypeScript ModulesTypeScript Modules
TypeScript Modules
 
Groovy / comparison with java
Groovy / comparison with javaGroovy / comparison with java
Groovy / comparison with java
 
A Static Type Analyzer of Untyped Ruby Code for Ruby 3
A Static Type Analyzer of Untyped Ruby Code for Ruby 3A Static Type Analyzer of Untyped Ruby Code for Ruby 3
A Static Type Analyzer of Untyped Ruby Code for Ruby 3
 
Javascript omg!
Javascript omg!Javascript omg!
Javascript omg!
 
Kotlin & Arrow the functional way
Kotlin & Arrow the functional wayKotlin & Arrow the functional way
Kotlin & Arrow the functional way
 
Akka actorstotherescue nirmalya sengupta
Akka actorstotherescue nirmalya senguptaAkka actorstotherescue nirmalya sengupta
Akka actorstotherescue nirmalya sengupta
 
C#
C#C#
C#
 
C#
C#C#
C#
 
C#
C#C#
C#
 
Understanding Typing. Understanding Ruby.
Understanding Typing. Understanding Ruby.Understanding Typing. Understanding Ruby.
Understanding Typing. Understanding Ruby.
 

Destacado

New c sharp4_features_part_iii
New c sharp4_features_part_iiiNew c sharp4_features_part_iii
New c sharp4_features_part_iiiNico Ludwig
 
SVR17: Data-Intensive Computing on Windows HPC Server with the ...
SVR17: Data-Intensive Computing on Windows HPC Server with the ...SVR17: Data-Intensive Computing on Windows HPC Server with the ...
SVR17: Data-Intensive Computing on Windows HPC Server with the ...butest
 
New c sharp4_features_part_ii
New c sharp4_features_part_iiNew c sharp4_features_part_ii
New c sharp4_features_part_iiNico Ludwig
 
New c sharp4_features_part_vi
New c sharp4_features_part_viNew c sharp4_features_part_vi
New c sharp4_features_part_viNico Ludwig
 
Ralf Laemmel - Not quite a sales pitch for C# 3.0 and .NET's LINQ - 2008-03-05
Ralf Laemmel - Not quite a sales pitch for C# 3.0 and .NET's LINQ - 2008-03-05Ralf Laemmel - Not quite a sales pitch for C# 3.0 and .NET's LINQ - 2008-03-05
Ralf Laemmel - Not quite a sales pitch for C# 3.0 and .NET's LINQ - 2008-03-05CHOOSE
 
New c sharp4_features_part_iv
New c sharp4_features_part_ivNew c sharp4_features_part_iv
New c sharp4_features_part_ivNico Ludwig
 
Introduction to F#x
Introduction to F#xIntroduction to F#x
Introduction to F#xRyan Riley
 
Introduction to Reactive Extensions
Introduction to Reactive ExtensionsIntroduction to Reactive Extensions
Introduction to Reactive ExtensionsPeter Goodman
 
Reactive Extensions
Reactive ExtensionsReactive Extensions
Reactive ExtensionsKiev ALT.NET
 
Pertemuan 1. introduction to image processing
Pertemuan 1. introduction to image processingPertemuan 1. introduction to image processing
Pertemuan 1. introduction to image processingAditya Kurniawan
 
F:\Universidad Tecnologica Israel
F:\Universidad Tecnologica IsraelF:\Universidad Tecnologica Israel
F:\Universidad Tecnologica Israelsantiago
 
New c sharp3_features_(linq)_part_v
New c sharp3_features_(linq)_part_vNew c sharp3_features_(linq)_part_v
New c sharp3_features_(linq)_part_vNico Ludwig
 
Introduction To Csharp
Introduction To CsharpIntroduction To Csharp
Introduction To Csharpsarfarazali
 
Getting the MVVM Kicked Out of Your F#'n Monads
Getting the MVVM Kicked Out of Your F#'n MonadsGetting the MVVM Kicked Out of Your F#'n Monads
Getting the MVVM Kicked Out of Your F#'n MonadsRichard Minerich
 
Texas STaR
Texas STaRTexas STaR
Texas STaRllyarbro
 
F# with Excel at F# in Finance, London Nov 2013
F# with Excel at F# in Finance, London Nov 2013F# with Excel at F# in Finance, London Nov 2013
F# with Excel at F# in Finance, London Nov 2013Adam Mlocek
 

Destacado (20)

New c sharp4_features_part_iii
New c sharp4_features_part_iiiNew c sharp4_features_part_iii
New c sharp4_features_part_iii
 
SVR17: Data-Intensive Computing on Windows HPC Server with the ...
SVR17: Data-Intensive Computing on Windows HPC Server with the ...SVR17: Data-Intensive Computing on Windows HPC Server with the ...
SVR17: Data-Intensive Computing on Windows HPC Server with the ...
 
New c sharp4_features_part_ii
New c sharp4_features_part_iiNew c sharp4_features_part_ii
New c sharp4_features_part_ii
 
Test first
Test firstTest first
Test first
 
New c sharp4_features_part_vi
New c sharp4_features_part_viNew c sharp4_features_part_vi
New c sharp4_features_part_vi
 
Ralf Laemmel - Not quite a sales pitch for C# 3.0 and .NET's LINQ - 2008-03-05
Ralf Laemmel - Not quite a sales pitch for C# 3.0 and .NET's LINQ - 2008-03-05Ralf Laemmel - Not quite a sales pitch for C# 3.0 and .NET's LINQ - 2008-03-05
Ralf Laemmel - Not quite a sales pitch for C# 3.0 and .NET's LINQ - 2008-03-05
 
New c sharp4_features_part_iv
New c sharp4_features_part_ivNew c sharp4_features_part_iv
New c sharp4_features_part_iv
 
Introduction to F#x
Introduction to F#xIntroduction to F#x
Introduction to F#x
 
Introduction to Reactive Extensions
Introduction to Reactive ExtensionsIntroduction to Reactive Extensions
Introduction to Reactive Extensions
 
Introduction to C# 3.0
Introduction to C# 3.0Introduction to C# 3.0
Introduction to C# 3.0
 
Reactive Extensions
Reactive ExtensionsReactive Extensions
Reactive Extensions
 
Pertemuan 1. introduction to image processing
Pertemuan 1. introduction to image processingPertemuan 1. introduction to image processing
Pertemuan 1. introduction to image processing
 
F:\Universidad Tecnologica Israel
F:\Universidad Tecnologica IsraelF:\Universidad Tecnologica Israel
F:\Universidad Tecnologica Israel
 
New c sharp3_features_(linq)_part_v
New c sharp3_features_(linq)_part_vNew c sharp3_features_(linq)_part_v
New c sharp3_features_(linq)_part_v
 
Introduction To Csharp
Introduction To CsharpIntroduction To Csharp
Introduction To Csharp
 
Getting the MVVM Kicked Out of Your F#'n Monads
Getting the MVVM Kicked Out of Your F#'n MonadsGetting the MVVM Kicked Out of Your F#'n Monads
Getting the MVVM Kicked Out of Your F#'n Monads
 
Texas
TexasTexas
Texas
 
The Power of F#
The Power of F#The Power of F#
The Power of F#
 
Texas STaR
Texas STaRTexas STaR
Texas STaR
 
F# with Excel at F# in Finance, London Nov 2013
F# with Excel at F# in Finance, London Nov 2013F# with Excel at F# in Finance, London Nov 2013
F# with Excel at F# in Finance, London Nov 2013
 

Similar a New c sharp4_features_part_v

New c sharp3_features_(linq)_part_ii
New c sharp3_features_(linq)_part_iiNew c sharp3_features_(linq)_part_ii
New c sharp3_features_(linq)_part_iiNico Ludwig
 
New c sharp3_features_(linq)_part_iv
New c sharp3_features_(linq)_part_ivNew c sharp3_features_(linq)_part_iv
New c sharp3_features_(linq)_part_ivNico Ludwig
 
ActionScript 3.0 Fundamentals
ActionScript 3.0 FundamentalsActionScript 3.0 Fundamentals
ActionScript 3.0 FundamentalsSaurabh Narula
 
Kevin Whinnery: Write Better JavaScript
Kevin Whinnery: Write Better JavaScriptKevin Whinnery: Write Better JavaScript
Kevin Whinnery: Write Better JavaScriptAxway Appcelerator
 
Bootstrapping iPhone Development
Bootstrapping iPhone DevelopmentBootstrapping iPhone Development
Bootstrapping iPhone DevelopmentThoughtWorks
 
The advantage of developing with TypeScript
The advantage of developing with TypeScript The advantage of developing with TypeScript
The advantage of developing with TypeScript Corley S.r.l.
 
Design patterns in javascript
Design patterns in javascriptDesign patterns in javascript
Design patterns in javascriptAyush Sharma
 
Introducing object oriented programming (oop)
Introducing object oriented programming (oop)Introducing object oriented programming (oop)
Introducing object oriented programming (oop)Hemlathadhevi Annadhurai
 
Write Better JavaScript
Write Better JavaScriptWrite Better JavaScript
Write Better JavaScriptKevin Whinnery
 
Write Better JavaScript
Write Better JavaScriptWrite Better JavaScript
Write Better JavaScriptKevin Whinnery
 
Half-automatic Compilable Source Code Recovery
Half-automatic Compilable Source Code RecoveryHalf-automatic Compilable Source Code Recovery
Half-automatic Compilable Source Code RecoveryJoxean Koret
 
Functional Programming In Jdk8
Functional Programming In Jdk8 Functional Programming In Jdk8
Functional Programming In Jdk8 Bansilal Haudakari
 
object oriented programming examples
object oriented programming examplesobject oriented programming examples
object oriented programming examplesAbdii Rashid
 
The Good, the Bad and the Ugly things to do with android
The Good, the Bad and the Ugly things to do with androidThe Good, the Bad and the Ugly things to do with android
The Good, the Bad and the Ugly things to do with androidStanojko Markovik
 
Hsc IT Chap 3. Advanced javascript-1.pdf
Hsc IT Chap 3. Advanced javascript-1.pdfHsc IT Chap 3. Advanced javascript-1.pdf
Hsc IT Chap 3. Advanced javascript-1.pdfAAFREEN SHAIKH
 

Similar a New c sharp4_features_part_v (20)

New c sharp3_features_(linq)_part_ii
New c sharp3_features_(linq)_part_iiNew c sharp3_features_(linq)_part_ii
New c sharp3_features_(linq)_part_ii
 
TypeScript Overview
TypeScript OverviewTypeScript Overview
TypeScript Overview
 
New c sharp3_features_(linq)_part_iv
New c sharp3_features_(linq)_part_ivNew c sharp3_features_(linq)_part_iv
New c sharp3_features_(linq)_part_iv
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
 
ActionScript 3.0 Fundamentals
ActionScript 3.0 FundamentalsActionScript 3.0 Fundamentals
ActionScript 3.0 Fundamentals
 
Kevin Whinnery: Write Better JavaScript
Kevin Whinnery: Write Better JavaScriptKevin Whinnery: Write Better JavaScript
Kevin Whinnery: Write Better JavaScript
 
Bootstrapping iPhone Development
Bootstrapping iPhone DevelopmentBootstrapping iPhone Development
Bootstrapping iPhone Development
 
The advantage of developing with TypeScript
The advantage of developing with TypeScript The advantage of developing with TypeScript
The advantage of developing with TypeScript
 
Memory models in c#
Memory models in c#Memory models in c#
Memory models in c#
 
Libreplan architecture
Libreplan architectureLibreplan architecture
Libreplan architecture
 
Design patterns in javascript
Design patterns in javascriptDesign patterns in javascript
Design patterns in javascript
 
Introducing object oriented programming (oop)
Introducing object oriented programming (oop)Introducing object oriented programming (oop)
Introducing object oriented programming (oop)
 
Write Better JavaScript
Write Better JavaScriptWrite Better JavaScript
Write Better JavaScript
 
Write Better JavaScript
Write Better JavaScriptWrite Better JavaScript
Write Better JavaScript
 
Half-automatic Compilable Source Code Recovery
Half-automatic Compilable Source Code RecoveryHalf-automatic Compilable Source Code Recovery
Half-automatic Compilable Source Code Recovery
 
Functional Programming In Jdk8
Functional Programming In Jdk8 Functional Programming In Jdk8
Functional Programming In Jdk8
 
object oriented programming examples
object oriented programming examplesobject oriented programming examples
object oriented programming examples
 
DDD with Behat
DDD with BehatDDD with Behat
DDD with Behat
 
The Good, the Bad and the Ugly things to do with android
The Good, the Bad and the Ugly things to do with androidThe Good, the Bad and the Ugly things to do with android
The Good, the Bad and the Ugly things to do with android
 
Hsc IT Chap 3. Advanced javascript-1.pdf
Hsc IT Chap 3. Advanced javascript-1.pdfHsc IT Chap 3. Advanced javascript-1.pdf
Hsc IT Chap 3. Advanced javascript-1.pdf
 

Más de Nico Ludwig

Grundkurs fuer excel_part_v
Grundkurs fuer excel_part_vGrundkurs fuer excel_part_v
Grundkurs fuer excel_part_vNico Ludwig
 
Grundkurs fuer excel_part_iv
Grundkurs fuer excel_part_ivGrundkurs fuer excel_part_iv
Grundkurs fuer excel_part_ivNico Ludwig
 
Grundkurs fuer excel_part_iii
Grundkurs fuer excel_part_iiiGrundkurs fuer excel_part_iii
Grundkurs fuer excel_part_iiiNico Ludwig
 
Grundkurs fuer excel_part_ii
Grundkurs fuer excel_part_iiGrundkurs fuer excel_part_ii
Grundkurs fuer excel_part_iiNico Ludwig
 
Grundkurs fuer excel_part_i
Grundkurs fuer excel_part_iGrundkurs fuer excel_part_i
Grundkurs fuer excel_part_iNico Ludwig
 
(1) gui history_of_interactivity
(1) gui history_of_interactivity(1) gui history_of_interactivity
(1) gui history_of_interactivityNico Ludwig
 
(1) gui history_of_interactivity
(1) gui history_of_interactivity(1) gui history_of_interactivity
(1) gui history_of_interactivityNico Ludwig
 
New c sharp4_features_part_i
New c sharp4_features_part_iNew c sharp4_features_part_i
New c sharp4_features_part_iNico Ludwig
 
New c sharp3_features_(linq)_part_iv
New c sharp3_features_(linq)_part_ivNew c sharp3_features_(linq)_part_iv
New c sharp3_features_(linq)_part_ivNico Ludwig
 
New c sharp3_features_(linq)_part_iii
New c sharp3_features_(linq)_part_iiiNew c sharp3_features_(linq)_part_iii
New c sharp3_features_(linq)_part_iiiNico Ludwig
 
New c sharp3_features_(linq)_part_i
New c sharp3_features_(linq)_part_iNew c sharp3_features_(linq)_part_i
New c sharp3_features_(linq)_part_iNico Ludwig
 
New c sharp3_features_(linq)_part_i
New c sharp3_features_(linq)_part_iNew c sharp3_features_(linq)_part_i
New c sharp3_features_(linq)_part_iNico Ludwig
 
Review of c_sharp2_features_part_iii
Review of c_sharp2_features_part_iiiReview of c_sharp2_features_part_iii
Review of c_sharp2_features_part_iiiNico Ludwig
 
Review of c_sharp2_features_part_ii
Review of c_sharp2_features_part_iiReview of c_sharp2_features_part_ii
Review of c_sharp2_features_part_iiNico Ludwig
 
Review of c_sharp2_features_part_i
Review of c_sharp2_features_part_iReview of c_sharp2_features_part_i
Review of c_sharp2_features_part_iNico Ludwig
 
(7) c sharp introduction_advanvced_features_part_ii
(7) c sharp introduction_advanvced_features_part_ii(7) c sharp introduction_advanvced_features_part_ii
(7) c sharp introduction_advanvced_features_part_iiNico Ludwig
 
(7) c sharp introduction_advanvced_features_part_ii
(7) c sharp introduction_advanvced_features_part_ii(7) c sharp introduction_advanvced_features_part_ii
(7) c sharp introduction_advanvced_features_part_iiNico Ludwig
 
(6) c sharp introduction_advanced_features_part_i
(6) c sharp introduction_advanced_features_part_i(6) c sharp introduction_advanced_features_part_i
(6) c sharp introduction_advanced_features_part_iNico Ludwig
 

Más de Nico Ludwig (20)

Grundkurs fuer excel_part_v
Grundkurs fuer excel_part_vGrundkurs fuer excel_part_v
Grundkurs fuer excel_part_v
 
Grundkurs fuer excel_part_iv
Grundkurs fuer excel_part_ivGrundkurs fuer excel_part_iv
Grundkurs fuer excel_part_iv
 
Grundkurs fuer excel_part_iii
Grundkurs fuer excel_part_iiiGrundkurs fuer excel_part_iii
Grundkurs fuer excel_part_iii
 
Grundkurs fuer excel_part_ii
Grundkurs fuer excel_part_iiGrundkurs fuer excel_part_ii
Grundkurs fuer excel_part_ii
 
Grundkurs fuer excel_part_i
Grundkurs fuer excel_part_iGrundkurs fuer excel_part_i
Grundkurs fuer excel_part_i
 
(2) gui drawing
(2) gui drawing(2) gui drawing
(2) gui drawing
 
(2) gui drawing
(2) gui drawing(2) gui drawing
(2) gui drawing
 
(1) gui history_of_interactivity
(1) gui history_of_interactivity(1) gui history_of_interactivity
(1) gui history_of_interactivity
 
(1) gui history_of_interactivity
(1) gui history_of_interactivity(1) gui history_of_interactivity
(1) gui history_of_interactivity
 
New c sharp4_features_part_i
New c sharp4_features_part_iNew c sharp4_features_part_i
New c sharp4_features_part_i
 
New c sharp3_features_(linq)_part_iv
New c sharp3_features_(linq)_part_ivNew c sharp3_features_(linq)_part_iv
New c sharp3_features_(linq)_part_iv
 
New c sharp3_features_(linq)_part_iii
New c sharp3_features_(linq)_part_iiiNew c sharp3_features_(linq)_part_iii
New c sharp3_features_(linq)_part_iii
 
New c sharp3_features_(linq)_part_i
New c sharp3_features_(linq)_part_iNew c sharp3_features_(linq)_part_i
New c sharp3_features_(linq)_part_i
 
New c sharp3_features_(linq)_part_i
New c sharp3_features_(linq)_part_iNew c sharp3_features_(linq)_part_i
New c sharp3_features_(linq)_part_i
 
Review of c_sharp2_features_part_iii
Review of c_sharp2_features_part_iiiReview of c_sharp2_features_part_iii
Review of c_sharp2_features_part_iii
 
Review of c_sharp2_features_part_ii
Review of c_sharp2_features_part_iiReview of c_sharp2_features_part_ii
Review of c_sharp2_features_part_ii
 
Review of c_sharp2_features_part_i
Review of c_sharp2_features_part_iReview of c_sharp2_features_part_i
Review of c_sharp2_features_part_i
 
(7) c sharp introduction_advanvced_features_part_ii
(7) c sharp introduction_advanvced_features_part_ii(7) c sharp introduction_advanvced_features_part_ii
(7) c sharp introduction_advanvced_features_part_ii
 
(7) c sharp introduction_advanvced_features_part_ii
(7) c sharp introduction_advanvced_features_part_ii(7) c sharp introduction_advanvced_features_part_ii
(7) c sharp introduction_advanvced_features_part_ii
 
(6) c sharp introduction_advanced_features_part_i
(6) c sharp introduction_advanced_features_part_i(6) c sharp introduction_advanced_features_part_i
(6) c sharp introduction_advanced_features_part_i
 

Último

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
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructureitnewsafrica
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...itnewsafrica
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
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
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observabilityitnewsafrica
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
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 Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...itnewsafrica
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 

Último (20)

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
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
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
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
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 Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 

New c sharp4_features_part_v

  • 1. 1 New C#4 Features – Part V Nico Ludwig (@ersatzteilchen)
  • 2. 2 TOC ● New C#4 Features – Part V – Dynamic COM Automation with C# – Dynamic Objects in JavaScript – Expando Objects in C# ● Sources: – Jon Skeet, CSharp in Depth
  • 3. 3 Dynamic Coding – A better Experience with COM ● You no longer need interop types: – Just don't use them: ● if you want lazy dispatching and you don't bother finding method signatures yourself... ● or if you simply don't want to or can't use type infos (w/o type library)! - You just use dynamic. – (Use them if you want to exploit early dispatching, e.g. if you want to use IntelliSense.) – To have no need to create code as an extra step is a key benefit of dynamic coding. ● But if you use interop types w/o PIAs, the DLR still makes your life easier: – No-PIA deployed types provide the type dynamic instead of object in their APIs. – E.g. IDispatch and VARIANTs are exposed as dynamics, reducing cast operations. ● With dynamic typing and COM you now have a "natural" coding experience: – "Plain old CLR objects" (POCOs) and COM objects can be programmed like peers. – During debugging the new "Dynamic View" assists you watching COM objects. ● COM as "peer objects" is one advantage of VB and PowerShell programming.
  • 4. 4 Example with COM Automation <DynamicComInteropCSharp> aThis example shows the application of C# dynamic coding to allow simple COM automation.
  • 5. 5 Example: Transportation of Anonymous Types' Instances ● Passing or returning anonymous types' instances from or to methods is limited. – Feasible solutions like generic methods or using the type Object are quite limiting... – You could only call Object's methods within such a method, not the anonymous type's ones (well, you might use reflection...). ● With dynamic you can overcome these limits. ● You'll get following features: – Easy to use adapters. – But data-binding, e.g. from IList<dynamic> to your controls is still fully functional (Windows Forms and WPF). ● !!You can't access properties of anonymous types in non-friend assemblies!! – Anonymous types are internal and accessing them publicly may fail. – => Keep using them in the same assembly! ● This is just one selected example of how dynamic typing simplifies coding problems. Passing anonymous types' instances to methods accepting dynamic arguments is used with view models in ASP.Net MVC. ● Basically dynamic makes it possible to use otherwise only locally known anonymous types in other methods. ● Databinding in WPF is less "sensitive", because it also accepts different types having equally named properties. The default behavior in Windows Forms requires identical types. ● Situation in non-friend assemblies: On accessing the anonymous type's instance's properties (via a dynamically typed symbol) you'll get a RuntimeBinderException on the caller side, because the properties couldn't be bound. ● More: ● The type dynamic enables us to solve a problem on programming of generics: we can call arbitrary methods on unconstrained types' instances! Esp. we can call operators in generics with dynamic dispatching! ● .Net remoting: Also can we use dynamic dispatch to access the interface of proxy objects on marshaled instances w/o having the object's type in avail.
  • 6. 6 Leering at JavaScript: Dynamic Objects <Safari Web Inspector as REPL> Shows how we can exploit dynamic objects with dynamic properties in JavaScript. Key aspects of dynamic programming: (1. Dynamic Typing) (2. Late Binding) (3. Duck Typing) 4. Dynamic Objects ● The ability to modify objects during run time is another aspect of dynamic programming that is shown here. -> Dynamic objects.
  • 7. 7 Dynamic Objects with .Net ExpandoObjects ● Dynamic programming allows creating types, whose interfaces change at run time. – These interface changes are based on how you use instances of such dynamic types. ● Dynamic objects are objects that have their own late binding logic! – (In contrast to static objects that get bound by the compiler (early binding).) – We can create own dynamic APIs to put mighty data driven APIs into effect! – The easiest way to get this is a dynamic property bag, via the type ExpandoObject. – ExpandoObjects are similar to JavaScript's dynamic objects that work like dictionaries. – In many dynamic languages (e.g. JavaScript, Python) all objects are property bags. ● How to make use of .Net's ExpandoObject: – Import the namespace System.Dynamic. – Create a new ExpandoObject and assign it to a dynamic to enable dynamic dispatch. – Add/modify members during run time and exploit ExpandoObjects as dictionaries. ● In static typing types are immutable, if you don’t have the source code. - In dynamic typing this is no longer the case, because the dynamic type information of an object is part of the object's value! ● You should also check, whether a member of a dynamic object is really present, before accessing it (RuntimeBinderException). - This is a duck-typing aspect (Does "it" lay eggs?)! ● As a matter of fact in .Net there also exists the type IExpando, which is implemented by JScript .Net objects (and by dynamic objects in some situations). ● ExpandoObjects can also have functions as properties of a Delegate type! ● Interoperability when hosting a DLR scripting language: Expose your C# objects to IronRuby as ExpandoObjects! ● The class ExpandoObject is sealed. The discussion of more flexible dynamic objects is discussed in the next lecture.
  • 8. 8 ExpandoObjects in Action <DynamicObjects> Shows the basic usage of ExpandoObjects. Key aspects of dynamic programming: (1. Dynamic Typing) (2. Late Binding) (3. Duck Typing) 4. Dynamic Objects