using System; using System.Collections.Generic; using System.Linq; namespace ClaySharp.Behaviors { public class NilResultBehavior : ClayBehavior { public override object GetMember(Func proceed, object self, string name) { return proceed() ?? Nil.Instance; } public override object GetIndex(Func proceed, object self, IEnumerable keys) { return proceed() ?? Nil.Instance; } public override object InvokeMember(Func proceed, object self, string name, INamedEnumerable args) { if (args.Any()) return proceed(); return proceed() ?? Nil.Instance; } } }