[clpe] novidades do .net framework 4.0
DESCRIPTION
TRANSCRIPT
![Page 1: [CLPE] Novidades do .net Framework 4.0](https://reader033.vdocuments.pub/reader033/viewer/2022061118/545d44ebaf7959be098b4b8c/html5/thumbnails/1.jpg)
Novidades do .NET Framework 4e C# 4.0
“Keep it simple”
![Page 2: [CLPE] Novidades do .net Framework 4.0](https://reader033.vdocuments.pub/reader033/viewer/2022061118/545d44ebaf7959be098b4b8c/html5/thumbnails/2.jpg)
Quem sou?
• Felipe Pimentel• MCP, MCTS e MCPD• Sócio e fundador da Ificomm Tecnologia • Arquiteto e consultor.• Líder do DotNetArchitects PE
![Page 3: [CLPE] Novidades do .net Framework 4.0](https://reader033.vdocuments.pub/reader033/viewer/2022061118/545d44ebaf7959be098b4b8c/html5/thumbnails/3.jpg)
Contatos
• Twitter: http://twitter.com/felipe_pimentel• Email: [email protected]• Blog: http://blog.ificomm.com• Grupo: http://pe.dotnetarchitects.net
![Page 4: [CLPE] Novidades do .net Framework 4.0](https://reader033.vdocuments.pub/reader033/viewer/2022061118/545d44ebaf7959be098b4b8c/html5/thumbnails/4.jpg)
Novidades não faltam
• ASP.NET WebForm• ASP.NET MVC• Mudanças na CLR, C# e VB • Data Access• Serviços • WorkFlows• WPF• MEF• ...
![Page 5: [CLPE] Novidades do .net Framework 4.0](https://reader033.vdocuments.pub/reader033/viewer/2022061118/545d44ebaf7959be098b4b8c/html5/thumbnails/5.jpg)
Agenda
• Code Contract• MEF – Managed Extensibily Framework• DLR – Dynamic Language Runtime• Parallel Extension• Principais novidades no C# 4.0
![Page 6: [CLPE] Novidades do .net Framework 4.0](https://reader033.vdocuments.pub/reader033/viewer/2022061118/545d44ebaf7959be098b4b8c/html5/thumbnails/6.jpg)
A Look Back…
.NET 1.0.NET 1.0 .NET 1.1.NET 1.1 .NET 2.0.NET 2.0
3.03.03.53.5
.NET 4.NET 4
2002 2003 2008 CTP2005-08
CLR 1.0CLR 1.0 CLR 1.1CLR 1.1 CLR 2.0CLR 2.0 CLR 4CLR 4
SP1SP1
![Page 7: [CLPE] Novidades do .net Framework 4.0](https://reader033.vdocuments.pub/reader033/viewer/2022061118/545d44ebaf7959be098b4b8c/html5/thumbnails/7.jpg)
The .NET Framework
Base Class LibrariesBase Class Libraries
The CLRJIT & NGENJIT & NGEN
Garbage CollectorGarbage Collector
Security Model
Security Model
Exception HandlingException Handling
Loader & Binder
Loader & Binder
WPFWPF Win FormsWin
Forms DLRDLR ASP.NET
ASP.NET WCFWCF And
more!And
more!LINQLINQ
![Page 8: [CLPE] Novidades do .net Framework 4.0](https://reader033.vdocuments.pub/reader033/viewer/2022061118/545d44ebaf7959be098b4b8c/html5/thumbnails/8.jpg)
Code Contract
• O que é garantido? (Pré-condição)• O que é esperado? (Pós-condição)• O que muda? (Invariante)
![Page 9: [CLPE] Novidades do .net Framework 4.0](https://reader033.vdocuments.pub/reader033/viewer/2022061118/545d44ebaf7959be098b4b8c/html5/thumbnails/9.jpg)
Code Contract
![Page 10: [CLPE] Novidades do .net Framework 4.0](https://reader033.vdocuments.pub/reader033/viewer/2022061118/545d44ebaf7959be098b4b8c/html5/thumbnails/10.jpg)
Code Contract
![Page 11: [CLPE] Novidades do .net Framework 4.0](https://reader033.vdocuments.pub/reader033/viewer/2022061118/545d44ebaf7959be098b4b8c/html5/thumbnails/11.jpg)
Managed Extensibility Framework?
Framework de extensibilidade – para criação de um sistema de plugins. Plugins que podem ser usados em qualquer aplicação.
![Page 12: [CLPE] Novidades do .net Framework 4.0](https://reader033.vdocuments.pub/reader033/viewer/2022061118/545d44ebaf7959be098b4b8c/html5/thumbnails/12.jpg)
The Problem…
Original SoftwareDevelopment
SoftwareMaintenance
![Page 13: [CLPE] Novidades do .net Framework 4.0](https://reader033.vdocuments.pub/reader033/viewer/2022061118/545d44ebaf7959be098b4b8c/html5/thumbnails/13.jpg)
Open/Closed Principle
Aberto para extensões e fechados para modificações.
![Page 14: [CLPE] Novidades do .net Framework 4.0](https://reader033.vdocuments.pub/reader033/viewer/2022061118/545d44ebaf7959be098b4b8c/html5/thumbnails/14.jpg)
Dinamicamente composta ao invés de ser estaticamente compilada
![Page 15: [CLPE] Novidades do .net Framework 4.0](https://reader033.vdocuments.pub/reader033/viewer/2022061118/545d44ebaf7959be098b4b8c/html5/thumbnails/15.jpg)
![Page 16: [CLPE] Novidades do .net Framework 4.0](https://reader033.vdocuments.pub/reader033/viewer/2022061118/545d44ebaf7959be098b4b8c/html5/thumbnails/16.jpg)
The Parallel Computing Initiative
Resolvendo problemas de maneira concorrente
“Concurrency for the masses”
![Page 17: [CLPE] Novidades do .net Framework 4.0](https://reader033.vdocuments.pub/reader033/viewer/2022061118/545d44ebaf7959be098b4b8c/html5/thumbnails/17.jpg)
Parallel Computing with .NET 4
1. Task Parallel Library (TPL)
2. Parallel LINQ (PLINQ)
3. Coordination Data Structures (CDS)
4. System.Threading Improvements
![Page 18: [CLPE] Novidades do .net Framework 4.0](https://reader033.vdocuments.pub/reader033/viewer/2022061118/545d44ebaf7959be098b4b8c/html5/thumbnails/18.jpg)
Parallel LINQ
Parallel LINQ (PLINQ) enables developers to easily leverage manycore with a minimal impact to existing LINQ programming model
var q = from p in people where p.Name == queryInfo.Name && p.State == queryInfo.State && p.Year >= yearStart && p.Year <= yearEnd orderby p.Year ascending select p;
var q = from p in people where p.Name == queryInfo.Name && p.State == queryInfo.State && p.Year >= yearStart && p.Year <= yearEnd orderby p.Year ascending select p;
![Page 19: [CLPE] Novidades do .net Framework 4.0](https://reader033.vdocuments.pub/reader033/viewer/2022061118/545d44ebaf7959be098b4b8c/html5/thumbnails/19.jpg)
Parallel Static Class
![Page 20: [CLPE] Novidades do .net Framework 4.0](https://reader033.vdocuments.pub/reader033/viewer/2022061118/545d44ebaf7959be098b4b8c/html5/thumbnails/20.jpg)
Parallel Static Class
![Page 21: [CLPE] Novidades do .net Framework 4.0](https://reader033.vdocuments.pub/reader033/viewer/2022061118/545d44ebaf7959be098b4b8c/html5/thumbnails/21.jpg)
Threading Task
![Page 22: [CLPE] Novidades do .net Framework 4.0](https://reader033.vdocuments.pub/reader033/viewer/2022061118/545d44ebaf7959be098b4b8c/html5/thumbnails/22.jpg)
Why the DLR?
Common Language RuntimeCommon Language Runtime
Statically-Typed
C#C#VBVB
RubyRubyPythonPython
Dynamically-Typed
![Page 23: [CLPE] Novidades do .net Framework 4.0](https://reader033.vdocuments.pub/reader033/viewer/2022061118/545d44ebaf7959be098b4b8c/html5/thumbnails/23.jpg)
Why the DLR?
Common Language RuntimeCommon Language Runtime
Statically-Typed
C#C#VBVB
RubyRubyPythonPython
Dynamically-Typed
Dynamic Language RuntimeDynamic Language Runtime
![Page 24: [CLPE] Novidades do .net Framework 4.0](https://reader033.vdocuments.pub/reader033/viewer/2022061118/545d44ebaf7959be098b4b8c/html5/thumbnails/24.jpg)
.NET Dynamic Programming
PythonBinderPythonBinder
RubyBinderRuby
BinderCOM
BinderCOM
BinderJScriptBinderJScriptBinder
ObjectBinderObjectBinder
Dynamic Language RuntimeDynamic Language Runtime
Expression TreesExpression TreesExpression TreesExpression Trees Dynamic DispatchDynamic DispatchDynamic DispatchDynamic Dispatch Call Site CachingCall Site CachingCall Site CachingCall Site Caching
IronPythonIronPython IronRubyIronRuby C#C# VB.NETVB.NET Others…Others…
![Page 25: [CLPE] Novidades do .net Framework 4.0](https://reader033.vdocuments.pub/reader033/viewer/2022061118/545d44ebaf7959be098b4b8c/html5/thumbnails/25.jpg)
Dynamically Typed Objects
Calculator calc = GetCalculator();int sum = calc.Add(10, 20);Calculator calc = GetCalculator();int sum = calc.Add(10, 20);
object calc = GetCalculator();Type calcType = calc.GetType();object res = calcType.InvokeMember("Add", BindingFlags.InvokeMethod, null, new object[] { 10, 20 });int sum = Convert.ToInt32(res);
object calc = GetCalculator();Type calcType = calc.GetType();object res = calcType.InvokeMember("Add", BindingFlags.InvokeMethod, null, new object[] { 10, 20 });int sum = Convert.ToInt32(res);
ScriptObject calc = GetCalculator();object res = calc.Invoke("Add", 10, 20);int sum = Convert.ToInt32(res);
ScriptObject calc = GetCalculator();object res = calc.Invoke("Add", 10, 20);int sum = Convert.ToInt32(res);
dynamic calc = GetCalculator();int sum = calc.Add(10, 20);
dynamic calc = GetCalculator();int sum = calc.Add(10, 20);
Statically typed to be dynamic
Statically typed to be dynamic
Dynamic method invocation
Dynamic method invocation
Dynamic conversion
Dynamic conversion
![Page 26: [CLPE] Novidades do .net Framework 4.0](https://reader033.vdocuments.pub/reader033/viewer/2022061118/545d44ebaf7959be098b4b8c/html5/thumbnails/26.jpg)
.NET Framework Compatibility
![Page 27: [CLPE] Novidades do .net Framework 4.0](https://reader033.vdocuments.pub/reader033/viewer/2022061118/545d44ebaf7959be098b4b8c/html5/thumbnails/27.jpg)
.NET Framework Compatibility
• .NET 4.0 is a highly compatible release• .NET 4.0 does not auto–roll forward
– You must add a configuration file with a specific switch to get 3.5 apps to run on 4.0
![Page 28: [CLPE] Novidades do .net Framework 4.0](https://reader033.vdocuments.pub/reader033/viewer/2022061118/545d44ebaf7959be098b4b8c/html5/thumbnails/28.jpg)
.NET Framework Compatibility
Hang on… if 4.0 is compatible, why not run 3.5 apps automatically on 4.0?–The BEST thing is always to prefer running on the version of the framework you built against
• Contact [email protected] and submit your app for testing!
![Page 29: [CLPE] Novidades do .net Framework 4.0](https://reader033.vdocuments.pub/reader033/viewer/2022061118/545d44ebaf7959be098b4b8c/html5/thumbnails/29.jpg)
CLR 2 - Existing Side-By-Side
Host Process (i.e. Outlook)Host Process (i.e. Outlook)
.NET 2.0.NET 2.0
2.0 add-in
2.0 add-in
3.03.0
3.53.5
3.0 add-in
3.0 add-in
3.5 add-in
3.5 add-in
1.1 add-in
1.1 add-in
.NET 1.1.NET 1.1
![Page 30: [CLPE] Novidades do .net Framework 4.0](https://reader033.vdocuments.pub/reader033/viewer/2022061118/545d44ebaf7959be098b4b8c/html5/thumbnails/30.jpg)
CLR 4 - In-Process Side-By-Side
.NET 2.0.NET 2.0.NET 4.0.NET 4.0
2.0 add-in
2.0 add-in
3.03.0
3.53.5
Host Process (i.e. Outlook)Host Process (i.e. Outlook)
3.0 add-in
3.0 add-in
3.5 add-in
3.5 add-in
4.0 add-in
4.0 add-in
![Page 31: [CLPE] Novidades do .net Framework 4.0](https://reader033.vdocuments.pub/reader033/viewer/2022061118/545d44ebaf7959be098b4b8c/html5/thumbnails/31.jpg)
NOVIDADES DO C# 4.0
![Page 32: [CLPE] Novidades do .net Framework 4.0](https://reader033.vdocuments.pub/reader033/viewer/2022061118/545d44ebaf7959be098b4b8c/html5/thumbnails/32.jpg)
The Evolution of C#
C# 1.0C# 1.0
C# 2.0C# 2.0
C# 3.0C# 3.0
Managed Code
Generics
LINQ
C# 4.0C# 4.0
Dynamic
![Page 33: [CLPE] Novidades do .net Framework 4.0](https://reader033.vdocuments.pub/reader033/viewer/2022061118/545d44ebaf7959be098b4b8c/html5/thumbnails/33.jpg)
New C# 4.0 Features
1. Named and Optional Parameters
![Page 34: [CLPE] Novidades do .net Framework 4.0](https://reader033.vdocuments.pub/reader033/viewer/2022061118/545d44ebaf7959be098b4b8c/html5/thumbnails/34.jpg)
New C# 4.0 Features
• Covariance and Contravariance
![Page 35: [CLPE] Novidades do .net Framework 4.0](https://reader033.vdocuments.pub/reader033/viewer/2022061118/545d44ebaf7959be098b4b8c/html5/thumbnails/35.jpg)
Covariance
![Page 36: [CLPE] Novidades do .net Framework 4.0](https://reader033.vdocuments.pub/reader033/viewer/2022061118/545d44ebaf7959be098b4b8c/html5/thumbnails/36.jpg)
Contravariance
![Page 37: [CLPE] Novidades do .net Framework 4.0](https://reader033.vdocuments.pub/reader033/viewer/2022061118/545d44ebaf7959be098b4b8c/html5/thumbnails/37.jpg)
Dinamismo em C#
![Page 38: [CLPE] Novidades do .net Framework 4.0](https://reader033.vdocuments.pub/reader033/viewer/2022061118/545d44ebaf7959be098b4b8c/html5/thumbnails/38.jpg)
Tipo dynamic
• Resolução dinâmica de métodos, propriedades e eventos (em tempo de execução)
• Não efetua validação estática
![Page 39: [CLPE] Novidades do .net Framework 4.0](https://reader033.vdocuments.pub/reader033/viewer/2022061118/545d44ebaf7959be098b4b8c/html5/thumbnails/39.jpg)
ExpandoObject
• Permite criar novos objetos em tempo de execução
![Page 40: [CLPE] Novidades do .net Framework 4.0](https://reader033.vdocuments.pub/reader033/viewer/2022061118/545d44ebaf7959be098b4b8c/html5/thumbnails/40.jpg)
DynamicObject
• Facilita criação de classes dinâmicas
![Page 41: [CLPE] Novidades do .net Framework 4.0](https://reader033.vdocuments.pub/reader033/viewer/2022061118/545d44ebaf7959be098b4b8c/html5/thumbnails/41.jpg)
Contatos
• Twitter: http://twitter.com/felipe_pimentel• Email: [email protected]• Blog: http://blog.ificomm.com• Grupo: http://pe.dotnetarchitects.net
![Page 42: [CLPE] Novidades do .net Framework 4.0](https://reader033.vdocuments.pub/reader033/viewer/2022061118/545d44ebaf7959be098b4b8c/html5/thumbnails/42.jpg)
Dúvidas?
![Page 43: [CLPE] Novidades do .net Framework 4.0](https://reader033.vdocuments.pub/reader033/viewer/2022061118/545d44ebaf7959be098b4b8c/html5/thumbnails/43.jpg)
Obrigado!!!