AjScript.Primitives.ArrayFunction.SliceFunction.Invoke C# (CSharp) 메소드

Invoke() 공개 메소드

public Invoke ( IContext context, object @this, object arguments ) : object
context IContext
@this object
arguments object
리턴 object
            public object Invoke(IContext context, object @this, object[] arguments)
            {
                ArrayObject array = (ArrayObject)@this;

                if (arguments != null && arguments.Length == 1)
                {
                    int from = (int)arguments[0];

                    if (from < 0)
                        return new ArrayObject(array.Function, array.Elements.Skip(array.Elements.Count + from));

                    return new ArrayObject(array.Function, array.Elements.Skip(from));
                }

                if (arguments != null && arguments.Length == 2)
                {
                    int from = (int)arguments[0];
                    int to = (int)arguments[1];

                    if (to < 0)
                        to = array.Elements.Count + to;

                    return new ArrayObject(array.Function, array.Elements.Skip(from).Take(to - from));
                }

                return new ArrayObject(array.Function, array.Elements);
            }
ArrayFunction.SliceFunction