Skip to content

Instantly share code, notes, and snippets.

@einarwh
Created June 19, 2012 20:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save einarwh/2956270 to your computer and use it in GitHub Desktop.
Save einarwh/2956270 to your computer and use it in GitHub Desktop.
Capturing values from a method call.
public override bool TryInvokeMember(
InvokeMemberBinder binder,
object[] args,
out object result)
{
_props[binder.Name] = GetValue(args) ?? string.Empty;
result = this;
return true;
}
private string GetValue(object[] args)
{
if (args.Length > 0)
{
var arg = args[0] as string;
if (arg != null)
{
return arg;
}
}
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment