Skip to main content


Showing posts from September, 2009

BingyBot - A Google Wave Bot written in .NET, that interfaces with Bing APIs

After spending my last weekend hack on the API, I've rolled together my first simple .NET bot, the Bingy Bot. You can try Bingy either in the Google Wave Sandbox (add to your wave), or in these public test waves.

Google Wave Sandbox - A public wave where you can test BingyEmbedded Here - Check out this embedded page
See Bingy in action.

Bingy bot answers user's questions, and even allows users to create FAQ waves collaboratively.

See this Google WAVE FAQ here, built by asking questions to Bingy. If you've wave sand box access, you can invite to your wave.
Google Wave exposes an excellent API to create extensions, and to embed Waves. Some time back, I had a quick look towards the Wave Robot API, and thought it'll be great if I've a .NET client API to work on. So, when I saw Jon Skeet tweeted about his C# Wave Bot API Port some time back, I found it interesting.

About Bingy

Sing in the tune "Twinkle Twinkle..&quo…

ExpandoObject in C# 4.0 Inside Look - 'Attaching' Members (Properties, Methods etc) To Objects At Runtime

About .NET 4.0 Series - I'll be covering various aspects of .NET 4.0 and related technologies in these posts

In my previous post and related article, I gave a quick introduction towards creating and using your own custom dynamic types, inheriting from the DynamicObject class. .NET framework 4.0 has a cool new ExpandoObject class, in System.Dynamic namespace. What makes this special is, it allows you to create an object with members that can be dynamically added and removed at run time.
To clarify the point, have a look at this example.

dynamic obj = new ExpandoObject(); obj.Value = 10; var action = new Action<string >((line) => Console.WriteLine(line)); obj.WriteNow = action; obj.WriteNow(obj.Value.ToString());
And you'll get 10 as output in your console. As you can see, the property 'Value' and method 'WriteNow' is attached at runtime, when the invocation happens.

The objective of …

Fun with Dynamic Objects and MEF in C# 4.0

About .NET 4.0 Series - I'll be covering various aspects of .NET 4.0 and related technologies in these posts

C# 4.0 introduced the dynamic keyword, to support dynamic typing. If you assign an object to a dynamic type variable (like dynamic myvar=new MyObj() ), all method calls, property invocations and operator invocations on myvar will be delayed till the run time, and the compiler won't perform any type checks for myvar at compile time.

So, if you do something like myvar.SomethingInvalid(); it is valid at compile time, but invalid at runtime if the object you assigned to myvar doesn't have a SomethingInvalid() method.
The System.Dynamic namespace has various classes for supporting dynamic programming, mainly the DynamicObject class from which you can derive your own classes to do run time dispatching yourself.

A couple of points to note.
A dynamic call will be slower for the first time, and your calls will be jited and cached if possible for subsequent calls. As a first…