コード例 #1
0
        internal override ScriptValue Get(ScriptValue property, ScriptValue reciever)
        {
            //https://tc39.github.io/ecma262/#sec-arguments-exotic-objects-get-p-receiver
            var isMapped = ParameterMap.HasOwnProperty(property);

            if (!isMapped)
            {
                return(base.Get(property, reciever));
            }

            return(ParameterMap.Get(property, ParameterMap));
        }
コード例 #2
0
        private string GetSignature()
        {
            if (_parameterMap.Get("oauth_signature_method") != "HMAC-SHA1")
            {
                throw new ArgumentException("SignatureMethod HMAC-SHA1 is mandatory");
            }

            var tokenSecret = string.IsNullOrEmpty(_tokenSecret) ? "" : EncodingUtility.UrlEncode(_tokenSecret);
            var secret      = EncodingUtility.UrlEncode(_consumerSecret) + '&' + tokenSecret;
            var hmacsha1    = new HMACSHA1 {
                Key = Encoding.ASCII.GetBytes(secret)
            };

            var signatureBase = GetSignatureBase();

            return(ComputeHash(hmacsha1, signatureBase));
        }
コード例 #3
0
        internal override bool DefineOwnProperty(ScriptValue property, PropertyDescriptor descriptor)
        {
            //https://tc39.github.io/ecma262/#sec-arguments-exotic-objects-defineownproperty-p-desc

            var isMapped = ParameterMap.HasOwnProperty(property);
            var newArgumentDescriptor = descriptor;

            if (isMapped && descriptor.IsDataDescriptor)
            {
                if (!descriptor.Value.HasValue && descriptor.Writable.HasValue && !descriptor.Writable)
                {
                    newArgumentDescriptor = new PropertyDescriptor(ParameterMap.Get(property), descriptor.Writable, descriptor.Enumerable, descriptor.Configurable);
                }
            }

            var allowed = base.DefineOwnProperty(property, newArgumentDescriptor);

            if (!allowed)
            {
                return(false);
            }

            if (isMapped)
            {
                if (descriptor.IsAccessorDescriptor)
                {
                    ParameterMap.Delete(property);
                }
                else
                {
                    if (descriptor.Value.HasValue)
                    {
                        var setStatus = Agent.Set(ParameterMap, property, descriptor.Value.Value, false);
                        Debug.Assert(setStatus);
                    }

                    if (descriptor.Writable.HasValue && !descriptor.Writable)
                    {
                        ParameterMap.Delete(property);
                    }
                }
            }

            return(true);
        }
コード例 #4
0
        internal override PropertyDescriptor GetOwnProperty(ScriptValue property)
        {
            //https://tc39.github.io/ecma262/#sec-arguments-exotic-objects-getownproperty-p

            var descriptor = base.GetOwnProperty(property);

            if (descriptor == null)
            {
                return(null);
            }

            var isMapped = ParameterMap.HasOwnProperty(property);

            if (isMapped)
            {
                descriptor.Value = ParameterMap.Get(property, ParameterMap);
            }

            return(descriptor);
        }
コード例 #5
0
ファイル: ArgumentsObject.cs プロジェクト: yarivat/Admin
        public override PropertyDescriptor GetOwnProperty(string propertyName)
        {
            if (!Strict && ParameterMap != null)
            {
                var desc = base.GetOwnProperty(propertyName);
                if (desc == PropertyDescriptor.Undefined)
                {
                    return(desc);
                }

                var isMapped = ParameterMap.GetOwnProperty(propertyName);
                if (isMapped != PropertyDescriptor.Undefined)
                {
                    desc.Value = ParameterMap.Get(propertyName);
                }

                return(desc);
            }

            return(base.GetOwnProperty(propertyName));
        }