Skip to content

Instantly share code, notes, and snippets.

@codeinvain
Created May 31, 2010 16:25
Show Gist options
  • Save codeinvain/419980 to your computer and use it in GitHub Desktop.
Save codeinvain/419980 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Browser;
using System.Dynamic;
namespace CodeInVain.Examples.Silverlight
{
class DynamicScriptObject:DynamicObject
{
private dynamic source;
public DynamicScriptObject(dynamic source)
{
this.source = source;
}
public override bool TryGetMember(GetMemberBinder binder, out object result)
{
string memberName = binder.Name;
result = null;
object value = null;
if (source is ScriptObject)
{
value = (source as ScriptObject).GetProperty(memberName);
}
if (value != null)
{
result = new DynamicScriptObject(value);
}
return true;
}
public dynamic Value
{
get { return source; }
}
public override string ToString()
{
return source.ToString();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment