当前位置: 首页>>代码示例>>C#>>正文


C# JsValue.Skip方法代码示例

本文整理汇总了C#中JsValue.Skip方法的典型用法代码示例。如果您正苦于以下问题:C# JsValue.Skip方法的具体用法?C# JsValue.Skip怎么用?C# JsValue.Skip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JsValue的用法示例。


在下文中一共展示了JsValue.Skip方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Bind

        private JsValue Bind(JsValue thisObj, JsValue[] arguments)
        {
            var target = thisObj.TryCast<ICallable>(x =>
            {
                throw new JavaScriptException(Engine.TypeError);
            });
            
            var thisArg = arguments.At(0);
            var f = new BindFunctionInstance(Engine) {Extensible = true};
            f.TargetFunction = thisObj;
            f.BoundThis = thisArg;
            f.BoundArgs = arguments.Skip(1).ToArray();
            f.Prototype = Engine.Function.PrototypeObject;

            var o = target as FunctionInstance;
            if (o != null)
            {
                var l = TypeConverter.ToNumber(o.Get("length")) - (arguments.Length - 1);
                f.FastAddProperty("length", System.Math.Max(l, 0), false, false, false); 
            }
            else
            {
                f.FastAddProperty("length", 0, false, false, false); 
            }
            

            var thrower = Engine.Function.ThrowTypeError;
            f.DefineOwnProperty("caller", new PropertyDescriptor(thrower, thrower, false, false), false);
            f.DefineOwnProperty("arguments", new PropertyDescriptor(thrower, thrower, false, false), false);


            return f;
        }
开发者ID:Rohansi,项目名称:jint,代码行数:33,代码来源:FunctionPrototype.cs

示例2: Splice

        private JsValue Splice(JsValue thisObj, JsValue[] arguments)
        {
            var start = arguments.At(0);
            var deleteCount = arguments.At(1);

            var o = TypeConverter.ToObject(Engine, thisObj);
            var a = Engine.Array.Construct(Arguments.Empty);
            var lenVal = o.Get("length");
            var len = TypeConverter.ToUint32(lenVal);
            var relativeStart = TypeConverter.ToInteger(start);

            uint actualStart;
            if (relativeStart < 0)
            {
                actualStart = (uint)System.Math.Max(len + relativeStart, 0);
            }
            else
            {
                actualStart = (uint)System.Math.Min(relativeStart, len);
            }

            var actualDeleteCount = System.Math.Min(System.Math.Max(TypeConverter.ToInteger(deleteCount), 0), len - actualStart);
            for (var k = 0; k < actualDeleteCount; k++)
            {
                var from = (actualStart + k).ToString();
                var fromPresent = o.HasProperty(from);
                if (fromPresent)
                {
                    var fromValue = o.Get(from); 
                    a.DefineOwnProperty(k.ToString(), new PropertyDescriptor(fromValue, true, true, true), false);
                }
            }
            
            var items = arguments.Skip(2).ToArray();
            if (items.Length < actualDeleteCount)
            {
                for (var k = actualStart; k < len - actualDeleteCount; k++)
                {
                    var from = (k + actualDeleteCount).ToString();
                    var to = (k + items.Length).ToString();
                    var fromPresent = o.HasProperty(from);
                    if (fromPresent)
                    {
                        var fromValue = o.Get(from);
                        o.Put(to, fromValue, true);
                    }
                    else
                    {
                        o.Delete(to, true);
                    }
                }
                for (var k = len; k > len - actualDeleteCount + items.Length; k-- )
                {
                    o.Delete((k - 1).ToString(), true);
                }
            }
            else if (items.Length > actualDeleteCount)
            {
                for (var k = len - actualDeleteCount; k > actualStart; k--)
                {
                    var from = (k + actualDeleteCount - 1).ToString();
                    var to = (k + items.Length - 1).ToString();
                    var fromPresent = o.HasProperty(from);
                    if (fromPresent)
                    {
                        var fromValue = o.Get(from);
                        o.Put(to, fromValue, true);
                    }
                    else
                    {
                        o.Delete(to, true);
                    }
                }
            }

            for(var k = 0; k< items.Length; k++)
            {
                var e = items[k];
                o.Put((k+actualStart).ToString(), e, true);
            }

            o.Put("length", len - actualDeleteCount + items.Length, true);
            return a;
        }
开发者ID:modulexcite,项目名称:Transformalize,代码行数:84,代码来源:ArrayPrototype.cs

示例3: CallImpl

        public JsValue CallImpl(JsValue thisObject, JsValue[] arguments)
        {
            var func = thisObject.TryCast<ICallable>();
            if (func == null)
            {
                throw new JavaScriptException(Engine.TypeError);
            }

            return func.Call(arguments.At(0), arguments.Length == 0 ? arguments : arguments.Skip(1).ToArray());
        }
开发者ID:Rohansi,项目名称:jint,代码行数:10,代码来源:FunctionPrototype.cs


注:本文中的JsValue.Skip方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。