Esempio n. 1
0
            public override object InvokeMember(Func <object> proceed, object self, string name, INamedEnumerable <object> args)
            {
                var argsCount = args.Count();

                if (name == "Add" && (argsCount == 1 || argsCount == 2))
                {
                    // pszmyd: Ignore null shapes
                    if (args.First() == null)
                    {
                        return(_parent);
                    }

                    dynamic parent = _parent;

                    dynamic zone = _zoneFactory();
                    zone.Parent   = _parent;
                    zone.ZoneName = _potentialZoneName;
                    parent[_potentialZoneName] = zone;

                    if (argsCount == 1)
                    {
                        return(zone.Add(args.Single()));
                    }

                    return(zone.Add(args.First(), (string)args.Last()));
                }
                return(proceed());
            }
 public override object InvokeMember(Func <object> proceed, dynamic self, string name, INamedEnumerable <object> args)
 {
     if (args.Count() == 1 && args.Named.Count() == 0)
     {
         Patch(self, name, args.Single());
     }
     return(proceed());
 }
Esempio n. 3
0
        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());
        }
Esempio n. 4
0
        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());
        }
Esempio n. 5
0
            public override object InvokeMember(Func<object> proceed, object self, string name, INamedEnumerable<object> args) {
                var argsCount = args.Count();
                if (name == "Add" && (argsCount == 1 || argsCount == 2)) {
                    // pszmyd: Ignore null shapes
                    if (args.First() == null)
                        return _parent;

                    dynamic parent = _parent;

                    dynamic zone = _zoneFactory();
                    zone.Parent = _parent;
                    zone.ZoneName = _potentialZoneName;
                    parent[_potentialZoneName] = zone;

                    if (argsCount == 1)
                        return zone.Add(args.Single());

                    return zone.Add(args.First(), (string)args.Last());
                }
                return proceed();
            }
 public override object InvokeMember(Func<object> proceed, dynamic self, string name, INamedEnumerable<object> args)
 {
     if (args.Count() == 1 && args.Named.Count() == 0)
         Patch(self, name, args.Single());
     return proceed();
 }