public override object InvokeMember(Func <object> proceed, object self, string name, INamedEnumerable <object> args) { if (args.Any()) { return(proceed()); } return(proceed() ?? Nil.Instance); }
public override object InvokeMemberMissing(Func <object> proceed, object self, string name, INamedEnumerable <object> args) { if (!args.Any()) { return(GetMemberMissing(proceed, self, name)); } if (args.Count() == 1) { SetMemberMissing(proceed, self, name, args.Single()); return(self); } return(proceed()); }
public override object InvokeMember(Func <object> proceed, object self, string name, INamedEnumerable <object> args) { switch (name) { case "AddRange": _data.AddRange(((IEnumerable)args.Single()).OfType <object>()); return(self); case "Add": _data.AddRange(args); return(self); case "Insert": return(IfInitialInteger(args, (index, arr) => { _data.InsertRange(index, arr); return self; }, proceed)); case "RemoveAt": return(IfSingleInteger(args, index => { _data.RemoveAt(index); return self; }, proceed)); case "Contains": return(IfSingleArgument(args, arg => _data.Contains(arg), proceed)); case "IndexOf": return(IfSingleArgument(args, arg => _data.IndexOf(arg), proceed)); case "Remove": return(IfSingleArgument(args, arg => _data.Remove(arg), proceed)); case "CopyTo": return(IfArguments <object[], int>(args, (array, arrayIndex) => { _data.CopyTo(array, arrayIndex); return self; }, proceed)); } if (!args.Any()) { return(GetMember(proceed, self, name)); } return(proceed()); }