Common C static Dynamic D dynamic IronPython IronRuby C# VB.NET Others… Dynamic Language Runtime Expression Trees Object Binder Dynamic Dispatch JavaScript Binder Python Binder Call Site Caching Ruby Binder COM Binder Calculator calc = GetCalculator(); int sum = calc.Add(10, 20); object calc = GetCalculator(); Type calcType.

Download Report

Transcript Common C static Dynamic D dynamic IronPython IronRuby C# VB.NET Others… Dynamic Language Runtime Expression Trees Object Binder Dynamic Dispatch JavaScript Binder Python Binder Call Site Caching Ruby Binder COM Binder Calculator calc = GetCalculator(); int sum = calc.Add(10, 20); object calc = GetCalculator(); Type calcType.

Common
C
static
Dynamic
D
dynamic
IronPython
IronRuby
C#
VB.NET
Others…
Dynamic Language Runtime
Expression Trees
Object
Binder
Dynamic Dispatch
JavaScript
Binder
Python
Binder
Call Site Caching
Ruby
Binder
COM
Binder
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); ScriptObject calc = GetCalculator();
object res = calc.Invoke("Add", 10, 20);
int sum = Convert.ToInt32(res);
Statically typed to be
dynamic
dynamic calc = GetCalculator();
int sum = calc.Add(10, 20);
Dynamic conversion
Dynamic method
invocation
public class DynamicObject : IDynamicMetaObjectProvider
{
public virtual IEnumerable<string> GetDynamicMemberNames();
public virtual DynamicMetaObject GetMetaObject(Expression parameter);
public virtual bool TryBinaryOperation(BinaryOperationBinder binder, object arg, out object result);
public virtual bool TryConvert(ConvertBinder binder, out object result);
public virtual bool TryCreateInstance(CreateInstanceBinder binder, object[] args, out object result);
public virtual bool TryDeleteIndex(DeleteIndexBinder binder, object[] indexes);
public virtual bool TryDeleteMember(DeleteMemberBinder binder);
public virtual bool TryGetIndex(GetIndexBinder binder, object[] indexes, out object result);
public virtual bool TryGetMember(GetMemberBinder binder, out object result);
public virtual bool TryInvoke(InvokeBinder binder, object[] args, out object result);
public virtual bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result);
public virtual bool TrySetIndex(SetIndexBinder binder, object[] indexes, object value);
public virtual bool TrySetMember(SetMemberBinder binder, object value);
public virtual bool TryUnaryOperation(UnaryOperationBinder binder, out object result);
}
public StreamReader OpenTextFile(
string path,
Encoding encoding,
bool detectEncoding,
int bufferSize);
public StreamReader OpenTextFile(
string path,
Encoding encoding,
bool detectEncoding);
public StreamReader OpenTextFile(
string path,
Encoding encoding);
public StreamReader OpenTextFile(
string path);
Primary method
Secondary overloads
Call primary with default values
public StreamReader OpenTextFile(
string path,
Encoding encoding
encoding,= null,
bool detectEncoding
detectEncoding,= true,
int bufferSize
bufferSize);
= 1024);
Optional parameters
Named argument
OpenTextFile("foo.txt", Encoding.UTF8);
OpenTextFile("foo.txt", Encoding.UTF8, bufferSize: 4096);
Named arguments can be in
any order
OpenTextFile(
bufferSize: 4096,
path: "foo.txt",
detectEncoding: false);
Evaluated in
order written
Named arguments must be
last
Non-optional must be
specified
object fileName = "Test.docx";
object missing = System.Reflection.Missing.Value;
doc.SaveAs(ref fileName,
ref missing, ref missing,
ref missing, ref missing,
ref missing, ref missing,
ref missing, ref missing,
ref missing, ref missing,
ref
ref
ref
ref
ref
missing,
missing,
missing,
missing,
missing);
doc.SaveAs("Test.docx");
dangerous
string[] strings = GetStrings();
string last = strings[strings.Length – 1];
object strings = GetDynamicObject();
strings[strings.Length
––~–
1];
string last = (string)strings~[strings~.Length
strings[strings~.Length
strings~[strings~.Length
~(string)strings~[strings~.Length
–
1];
1];
1]; ~–
~–1];
1];
object strings = GetDynamicObject();
string last = ~(string)strings~[strings~.Length ~– 1];

object strings = GetDynamicObject();
string last;
dynamic { last = strings[strings.Length – 1]; }
object strings = GetDynamicObject();
string last;
dynamic { last = strings[strings.Length – 1]; }

object strings = GetDynamicObject();
string last = strings[dynamic(strings).Length – 1];
object strings = GetDynamicObject();
string last = strings[dynamic(strings).Length – 1];

dynamic strings = GetDynamicObject();
string last = strings[strings.Length – 1];
dynamic strings = GetDynamicObject();
string last = strings[strings.Length – 1];

dynamic Foo foo = GetDynamicFoo();

dynamic foo = GetDynamicFoo();

dynamic result = Math.Abs((double)d);

dynamic result = Math.Abs(d);

Math.Abs(d)
d(“Hello”)
d.Length
4 + d
d[“Hello”]
(double)d
new Foo(d)
M(d, GetFoo());
Bind with
runtime type
Bind with
compile-time type
dynamic
“use my runtime type for binding”
Type calcType = calc.GetType();
object res = calcType.InvokeMember("Add",
BindingFlags.InvokeMethod, null,
new object[] { 10, 20 });
int sum = Convert.ToInt32(res);
int sum = calc.Add(10, 20);
DEV307: F# in Microsoft Visual Studio 2010 (6/10 from 9:45am – 11:00am)
DEV315: Microsoft Visual Studio 2010 Tips and Tricks (6/8 from 5:00pm – 6:15pm)
DEV316: Modern Programming with C++Ox in Microsoft Visual C++ 2010 (6/8 from
3:15pm – 4:30pm)
DEV319: Scale and Productivity for C++ Developers with Microsoft Visual Studio 2010
(6/9 from 8:00am – 9:15am)
DEV401: Advanced Use of the new Microsoft Visual Basic 2010 Language Features (6/9
from 9:45am – 11:00am)
DEV404: C# in the Big World (6/8 from 1:30pm – 2:45pm)
DEV406: Integrating Dynamic Languages into Your Enterprise Applications (6/8 from 8am
– 9:15am)
DEV407: Maintaining and Modernizing Existing Applications with Microsoft Visual Studio
2010 (6/10 from 8:00am – 9:15am)
DEV03-INT: Meet the C# team (6/9 from 1:30-2:45pm)
DEV04-INT: Meet the VB team (6/10 from 3:15 – 4:30pm)
DEV09-INT: Microsoft Visual Basic and C# IDE Tips and Tricks (6/7 from 4:30pm -5:45pm)
DEV10-INT: Using Dynamic Languages to build Scriptable Applications ((6/9 from 8:00am
-9:15am)
DEV11 –INT: IronPython Tools (6/10 from 5:00pm – 6:15pm)
DEV05-HOL: Introduction to F#
http://www.microsoft.com/visualstudio/en-us/
http://blogs.msdn.com/b/somasegar/
http://msdn.com/data
http://blogs.msdn.com/adonet
http://blogs.msdn.com/astoriateam
http://blogs.msdn.com/efdesign
www.microsoft.com/teched
www.microsoft.com/learning
http://microsoft.com/technet
http://microsoft.com/msdn
Sign up for Tech·Ed 2011 and save $500
starting June 8 – June 31st
http://northamerica.msteched.com/registration
You can also register at the
North America 2011 kiosk located at registration
Join us in Atlanta next year